Package com.db4o.internal
Class ObjectReference
- java.lang.Object
-
- com.db4o.internal.Identifiable
-
- com.db4o.internal.ObjectReference
-
- All Implemented Interfaces:
Activator
,ObjectInfo
public class ObjectReference extends Identifiable implements ObjectInfo, Activator
A weak reference to an known object. "Known" ~ has been stored and/or retrieved within a transaction. References the corresponding ClassMetaData along with further metadata: internal id, UUID/version information, ...
-
-
Field Summary
Fields Modifier and Type Field Description int
_hcHashcode
-
Fields inherited from class com.db4o.internal.Identifiable
_id, _state
-
-
Constructor Summary
Constructors Constructor Description ObjectReference()
ObjectReference(int id)
ObjectReference(ClassMetadata classMetadata, int id)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
activate(ActivationPurpose purpose)
Method to be called to activate the host object.void
activate(Transaction ta, java.lang.Object obj, ActivationDepth depth)
void
activateOn(Transaction transaction, ActivationPurpose purpose)
ClassMetadata
classMetadata()
void
classMetadata(ClassMetadata classMetadata)
ObjectContainerBase
container()
void
deactivate(Transaction trans, ActivationDepth depth)
void
flagAsHandled(int callId)
void
flagForDelete(int callId)
long
getCommitTimestamp()
The serial timestamp the object is assigned to when it is committed.
You need to enable this feature before using it inFileConfiguration.generateCommitTimestamps(boolean)
.
All the objects commited within the same transaction will receive the same commitTimestamp.
db4o replication system (dRS) relies on this feature.byte
getIdentifier()
long
getInternalID()
returns the internal db4o ID.java.lang.Object
getObject()
returns the object that is referenced.java.lang.Object
getObjectReference()
Db4oUUID
getUUID()
returns a UUID representation of the referenced object.long
getVersion()
returns the transaction serial number ("version") the referenced object was stored with last.ObjectReference
hc_add(ObjectReference newRef)
HCTREEObjectReference
hc_find(java.lang.Object obj)
static int
hc_getCode(java.lang.Object obj)
ObjectReference
hc_remove(ObjectReference findRef)
void
hc_traverse(Visitor4 visitor)
ObjectReference
id_add(ObjectReference newRef)
IDTREEObjectReference
id_find(int id)
ObjectReference
id_remove(ObjectReference ref)
boolean
isFlaggedAsHandled(int callID)
boolean
isFlaggedForDelete()
boolean
isValid()
static boolean
isValidId(int id)
protected boolean
objectCanUpdate(Transaction transaction, java.lang.Object obj)
int
ownLength()
VirtualAttributes
produceVirtualAttributes()
java.lang.Object
read(Transaction trans, ByteArrayBuffer buffer, java.lang.Object obj, ActivationDepth instantiationDepth, int addToIDTree, boolean checkIDTree)
java.lang.Object
readPrefetch(Transaction trans, ByteArrayBuffer buffer, int addToIDTree)
void
readThis(Transaction trans, ByteArrayBuffer buffer)
void
ref_init()
void
setObject(java.lang.Object obj)
void
setObjectWeak(ObjectContainerBase container, java.lang.Object obj)
void
setVirtualAttributes(VirtualAttributes at)
java.lang.String
toString()
Transaction
transaction()
VirtualAttributes
virtualAttributes()
VirtualAttributes
virtualAttributes(Transaction trans)
VirtualAttributes
virtualAttributes(Transaction trans, boolean lastCommitted)
void
writeThis(Transaction trans, ByteArrayBuffer buffer)
void
writeUpdate(Transaction transaction, UpdateDepth updatedepth)
-
Methods inherited from class com.db4o.internal.Identifiable
beginProcessing, endProcessing, getID, hashCode, isActive, isDirty, isNew, setID, setStateClean, setStateDeactivated, setStateDirty
-
-
-
-
Constructor Detail
-
ObjectReference
public ObjectReference()
-
ObjectReference
public ObjectReference(int id)
-
ObjectReference
public ObjectReference(ClassMetadata classMetadata, int id)
-
-
Method Detail
-
activate
public void activate(ActivationPurpose purpose)
Description copied from interface:Activator
Method to be called to activate the host object.- Specified by:
activate
in interfaceActivator
- Parameters:
purpose
- for which purpose is the object being activated?ActivationPurpose.WRITE
will cause the object to be saved on the nextObjectContainer.commit()
operation.
-
activateOn
public void activateOn(Transaction transaction, ActivationPurpose purpose)
-
activate
public void activate(Transaction ta, java.lang.Object obj, ActivationDepth depth)
-
deactivate
public void deactivate(Transaction trans, ActivationDepth depth)
-
getIdentifier
public byte getIdentifier()
-
getInternalID
public long getInternalID()
Description copied from interface:ObjectInfo
returns the internal db4o ID.- Specified by:
getInternalID
in interfaceObjectInfo
-
getObject
public java.lang.Object getObject()
Description copied from interface:ObjectInfo
returns the object that is referenced.
This method may return null, if the object has been garbage collected.- Specified by:
getObject
in interfaceObjectInfo
- Returns:
- the referenced object or null, if the object has been garbage collected.
-
getObjectReference
public java.lang.Object getObjectReference()
-
container
public ObjectContainerBase container()
-
transaction
public Transaction transaction()
-
getUUID
public Db4oUUID getUUID()
Description copied from interface:ObjectInfo
returns a UUID representation of the referenced object. UUID generation has to be turned on, in order to be able to use this feature:FileConfiguration.generateUUIDs(com.db4o.config.ConfigScope)
- Specified by:
getUUID
in interfaceObjectInfo
- Returns:
- the UUID of the referenced object.
-
getVersion
public long getVersion()
Description copied from interface:ObjectInfo
returns the transaction serial number ("version") the referenced object was stored with last. Version number generation has to be turned on, in order to be able to use this feature:FileConfiguration.generateVersionNumbers(com.db4o.config.ConfigScope)
This feature was replaced byObjectInfo.getCommitTimestamp()
. The main difference is that the old version mechanism used to assign a serial timestamp to the object upon storing time, and the new commitTimestamp approach, assigns it upon commit time.- Specified by:
getVersion
in interfaceObjectInfo
- Returns:
- the version number.
-
getCommitTimestamp
public long getCommitTimestamp()
Description copied from interface:ObjectInfo
The serial timestamp the object is assigned to when it is committed.
You need to enable this feature before using it inFileConfiguration.generateCommitTimestamps(boolean)
.
All the objects commited within the same transaction will receive the same commitTimestamp.
db4o replication system (dRS) relies on this feature.- Specified by:
getCommitTimestamp
in interfaceObjectInfo
- Returns:
- the serial timestamp that was given to the object upon commit.
- See Also:
FileConfiguration.generateCommitTimestamps(boolean)
-
classMetadata
public final ClassMetadata classMetadata()
-
classMetadata
public void classMetadata(ClassMetadata classMetadata)
-
ownLength
public int ownLength()
-
produceVirtualAttributes
public VirtualAttributes produceVirtualAttributes()
-
read
public final java.lang.Object read(Transaction trans, ByteArrayBuffer buffer, java.lang.Object obj, ActivationDepth instantiationDepth, int addToIDTree, boolean checkIDTree)
-
readPrefetch
public java.lang.Object readPrefetch(Transaction trans, ByteArrayBuffer buffer, int addToIDTree)
-
readThis
public final void readThis(Transaction trans, ByteArrayBuffer buffer)
-
setObjectWeak
public void setObjectWeak(ObjectContainerBase container, java.lang.Object obj)
-
setObject
public void setObject(java.lang.Object obj)
-
flagForDelete
public void flagForDelete(int callId)
-
isFlaggedForDelete
public boolean isFlaggedForDelete()
-
flagAsHandled
public void flagAsHandled(int callId)
-
isFlaggedAsHandled
public final boolean isFlaggedAsHandled(int callID)
-
isValid
public final boolean isValid()
-
isValidId
public static final boolean isValidId(int id)
-
virtualAttributes
public VirtualAttributes virtualAttributes()
-
virtualAttributes
public VirtualAttributes virtualAttributes(Transaction trans, boolean lastCommitted)
-
virtualAttributes
public VirtualAttributes virtualAttributes(Transaction trans)
-
setVirtualAttributes
public void setVirtualAttributes(VirtualAttributes at)
-
writeThis
public void writeThis(Transaction trans, ByteArrayBuffer buffer)
-
writeUpdate
public void writeUpdate(Transaction transaction, UpdateDepth updatedepth)
-
objectCanUpdate
protected boolean objectCanUpdate(Transaction transaction, java.lang.Object obj)
-
ref_init
public void ref_init()
-
hc_add
public ObjectReference hc_add(ObjectReference newRef)
HCTREE
-
hc_find
public ObjectReference hc_find(java.lang.Object obj)
-
hc_getCode
public static int hc_getCode(java.lang.Object obj)
-
hc_remove
public ObjectReference hc_remove(ObjectReference findRef)
-
hc_traverse
public void hc_traverse(Visitor4 visitor)
-
id_add
public ObjectReference id_add(ObjectReference newRef)
IDTREE
-
id_find
public ObjectReference id_find(int id)
-
id_remove
public ObjectReference id_remove(ObjectReference ref)
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-