1 9 package org.ozoneDB.core.storage.classicStore; 10 11 import org.ozoneDB.core.*; 12 import org.ozoneDB.core.storage.classicStore.ClassicObjectContainer; 13 import org.ozoneDB.core.storage.classicStore.ClassicStore; 14 import org.ozoneDB.core.storage.classicStore.ClusterID; 15 import org.ozoneDB.util.*; 16 import org.ozoneDB.DxLib.*; 17 import org.ozoneDB.OzoneCompatible; 18 import org.ozoneDB.io.stream.ResolvingObjectInputStream; 19 20 import java.io.*; 21 22 23 29 public class DeathObject extends DxObject { 30 public final static byte FREE = 0; 31 public final static byte DELETED = 1; 32 public final static byte FROZEN = 2; 33 public final static byte CHANGED = 3; 34 35 protected ObjectID oid; 36 protected byte[] data; 37 protected long size; 38 42 protected long stateSize; 43 protected byte state = FREE; 44 45 46 public DeathObject previous; 47 public DeathObject next; 48 49 50 public DeathObject() { 51 } 52 53 54 public DeathObject( ObjectID _oid ) { 55 oid = _oid; 56 } 57 58 59 public final ObjectID objID() { 60 return oid; 61 } 62 63 64 public final byte[] data() { 65 return data; 66 } 67 68 69 public final void setData( byte[] _data ) { 70 data = _data; 71 setSize( data.length ); 72 } 73 74 75 public final long size() { 76 return size; 77 } 78 79 80 public final void setSize( long s ) { 81 size = s; 82 } 83 84 85 public final byte state() { 86 return state; 87 } 88 89 90 public final ClusterID clusterID() { 91 return container().clusterID(); 92 } 93 94 95 public final void setCluID( ClusterID _cid ) { 96 container().setClusterID( _cid ); 97 } 98 99 100 public final ClassicObjectContainer container() { 101 return (ClassicObjectContainer)((ClassicStore)Env.currentEnv().getStoreManager()).objectSpace.objectForID( oid ); 102 } 103 104 105 public final void setState( byte s ) { 106 state = s; 107 if (state == DELETED) { 111 data = null; 112 oid = null; 113 } 114 } 115 116 117 public OzoneCompatible enlive() throws IOException { 118 if (data != null) { 119 try { 120 ByteArrayInputStream bs = new ByteArrayInputStream( data ); 122 ObjectInput in = new ResolvingObjectInputStream( bs ); 123 OzoneCompatible obj = (OzoneCompatible)in.readObject(); 124 in.close(); 125 bs.close(); 126 127 data = null; 129 130 return obj; 131 } catch (Exception e) { 132 Env.currentEnv().logWriter.newEntry( this, e.toString(), LogWriter.WARN ); 133 throw new IOException( e.toString() ); 134 } 135 } 136 return null; 137 } 138 } 139 | Popular Tags |