org.datanucleus.cache
Class CachedPC

java.lang.Object
  extended by org.datanucleus.cache.CachedPC
All Implemented Interfaces:
java.io.Serializable

public class CachedPC
extends java.lang.Object
implements java.io.Serializable

An object that is stored in the Level2 Cache keyed by the identity of the persistable object. Comprises a persistable object, its loaded fields array, the version of the persistable object that is stored, and a map of relation field values. The loaded fields and version are used when re-instating the object getting it out of the cache in a consistent state for when it was put in the cache. The relation fields map is used to store the OIDs of any referenced persistable objects. If we have a field "otherObject" that stores a persistable object then we will have an entry keyed by "otherObject" and will contain the OID of the other persistable object. Similarly if we have a field "elements" that is a Collection of persistable objects then we will have an entry keyed by "elements" and will contain a Collection (of the correct instantiation type) containing the OIDs of the element objects. Similarly for Maps, arrays.

See Also:
Serialized Form

Constructor Summary
CachedPC(java.lang.Object pc, boolean[] loadedFields, java.lang.Object vers)
          Constructor.
 
Method Summary
 boolean[] getLoadedFields()
          Accessor for the loaded fields of this object
 java.lang.Class getPCClass()
          Accessor for the class of the persistable object.
 java.lang.Object getPersistableObject()
          Accessor for the persistable object
 java.lang.Object getRelationField(java.lang.String fieldName)
          Accessor for the value for the relation field at the field with the specified name.
 java.lang.String[] getRelationFieldNames()
           
 java.lang.Object getVersion()
          Version accessor.
 void setLoadedFields(boolean[] flds)
          Mutator for the loaded fields.
 void setRelationField(java.lang.String fieldName, java.lang.Object value)
          Setter for the value for the relation field with the specified name.
 void setVersion(java.lang.Object ver)
          Setter for the version.
 java.lang.String toString()
          Method to return a sting form of the cached object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CachedPC

public CachedPC(java.lang.Object pc,
                boolean[] loadedFields,
                java.lang.Object vers)
Constructor.

Parameters:
pc - The persistable object
loadedFields - The loaded fields
vers - The version (optional)
Method Detail

getPersistableObject

public java.lang.Object getPersistableObject()
Accessor for the persistable object

Returns:
The PC object

getPCClass

public java.lang.Class getPCClass()
Accessor for the class of the persistable object.

Returns:
The class of the object

getVersion

public java.lang.Object getVersion()
Version accessor.

Returns:
Version of cached object

setVersion

public void setVersion(java.lang.Object ver)
Setter for the version. Called when updating a stored CachedPC.

Parameters:
ver - New version

getLoadedFields

public boolean[] getLoadedFields()
Accessor for the loaded fields of this object

Returns:
The loaded fields

setLoadedFields

public void setLoadedFields(boolean[] flds)
Mutator for the loaded fields. Called when updating a stored CachedPC.

Parameters:
flds - The loaded fields

setRelationField

public void setRelationField(java.lang.String fieldName,
                             java.lang.Object value)
Setter for the value for the relation field with the specified name. Passing in null for the value will remove the relation field entry.

Parameters:
fieldName - Name of field
value - The value. For a field storing a PC object this is an OID. For a Collection field this is a Collection. For a Map field this is a Map

getRelationField

public java.lang.Object getRelationField(java.lang.String fieldName)
Accessor for the value for the relation field at the field with the specified name.

Parameters:
fieldName - Name of field
Returns:
The value

getRelationFieldNames

public java.lang.String[] getRelationFieldNames()

toString

public java.lang.String toString()
Method to return a sting form of the cached object. Returns something like "CachedPC : org.datanucleus.test.A@6295eb version=1 loadedFlags=[YY]"

Overrides:
toString in class java.lang.Object
Returns:
The string form


Copyright © 2011. All Rights Reserved.