📄 deathobject.java
字号:
// You can redistribute this software and/or modify it under the terms of
// the Ozone Core License version 1 published by ozone-db.org.
//
// The original code and portions created by SMB are
// Copyright (C) 1997-@year@ by SMB GmbH. All rights reserved.
//
// $Id$
package org.ozoneDB.core.storage.classicStore;
import org.ozoneDB.core.*;
import org.ozoneDB.core.storage.classicStore.ClassicObjectContainer;
import org.ozoneDB.core.storage.classicStore.ClassicStore;
import org.ozoneDB.core.storage.classicStore.ClusterID;
import org.ozoneDB.util.*;
import org.ozoneDB.DxLib.*;
import org.ozoneDB.OzoneCompatible;
import org.ozoneDB.io.stream.ResolvingObjectInputStream;
import java.io.*;
/**
* Stellt einen eintrag in die objektliste des clusterspaces dar.
* Obj is the object id of the ref. object.
* Data der datenteil des objektes in byte form
* @author <a href="http://www.softwarebuero.de/">SMB</a>
*/
public class DeathObject extends DxObject {
public final static byte FREE = 0;
public final static byte DELETED = 1;
public final static byte FROZEN = 2;
public final static byte CHANGED = 3;
protected ObjectID oid;
protected byte[] data;
protected long size;
/**
* will be set while read the object state chunk (see
* Cluster.readObjects() and Cluster.appendObject())
*/
protected long stateSize;
protected byte state = FREE;
/** References for the double linked list */
public DeathObject previous;
public DeathObject next;
public DeathObject() {
}
public DeathObject( ObjectID _oid ) {
oid = _oid;
}
public final ObjectID objID() {
return oid;
}
public final byte[] data() {
return data;
}
public final void setData( byte[] _data ) {
data = _data;
setSize( data.length );
}
public final long size() {
return size;
}
public final void setSize( long s ) {
size = s;
}
public final byte state() {
return state;
}
public final ClusterID clusterID() {
return container().clusterID();
}
public final void setCluID( ClusterID _cid ) {
container().setClusterID( _cid );
}
public final ClassicObjectContainer container() {
return (ClassicObjectContainer)((ClassicStore)Env.currentEnv().getStoreManager()).objectSpace.objectForID( oid );
}
public final void setState( byte s ) {
state = s;
// Speicher freigeben, da DeathObject selbst nicht sofort aus dem
// ClusterSpace geloescht wird, sondern in priorityQueue referenziert
// wird.
if (state == DELETED) {
data = null;
oid = null;
}
}
public OzoneCompatible enlive() throws IOException {
if (data != null) {
try {
//env.logWriter.newEntry ("enlive data size: " + data.length, LogWriter.DEBUG3);
ByteArrayInputStream bs = new ByteArrayInputStream( data );
ObjectInput in = new ResolvingObjectInputStream( bs );
OzoneCompatible obj = (OzoneCompatible)in.readObject();
in.close();
bs.close();
// NEW: if an object is activated, we don't need the data any longer
data = null;
return obj;
} catch (Exception e) {
Env.currentEnv().logWriter.newEntry( this, e.toString(), LogWriter.WARN );
throw new IOException( e.toString() );
}
}
return null;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -