This is an abstract base class for OID classes. Each PC class has its own
implementation generated for it at runtime. These implementations have fast
implementations of various methods in the base class designed for different
data stores.
Implementations must define equals and hashcode so that OIDs for the same
class heirachy with the same datastore or application identity are equal and
have the same hashcode.
Some of the methods in this interface can be implemented by calling other
methods. This is deliberate as a generated hyperdrive OID class can
hardcode the return value and avoid having to dereference a field every
time. Example: OID.getClassIndex() == OID.getClassMetaData().index.
This interface must not extend Externalizable. Subclasses except for
NewObjectOID must implement Externalizable so they can be serialized
using writeObject. NewObjectOID must be serialized using the
FastExternalizable methods instead and this restriction enforces this
(NotSerializable exception if it happens).
Method Summary
public int
compareTo(Object o) The IBM VMs have a problem with unimplemented interface methods in
classes so we need this.
getBaseClassMetaData() Get the meta data for the least derived class in our heirachy.
This is getAvailableClassMetaData().top but this method can be
hardcoded in a generated class.
public int
getClassIndex() Return the index of our PC class in the meta data.
Populate this OID from the array of Objects supplied. These will
come from some sort of key generator (e.g. a JdbcKeyGenerator).
This is used to construct OIDs for newly created objects. Note that
data may contain extra garbage objects from previously usages.
Fill this OID from the given id. If objectIdClass is mapped then 'id' will
be assumed to be a instance of the objectIdClass, else 'id' is assumed to
be a 'pk' for a class with a single pk field.
Parameters: id -
fillFromIDString
public void fillFromIDString(String idString, int index)(Code)
Fill this OID from its toString. The classid will have already been
parsed out with index indicating the first character after the
separator.
If this is a real OID (i.e. it has been assigned in the database)
then return itself. Otherwise return the corresponding real OID or
this if none has been allocated yet. This differs from
OID.getRealOID() in that it always returns an OID reference
even if this is a new OID and no real OID has been allocated.
Get the meta data for the least derived class in our heirachy.
This is getAvailableClassMetaData().top but this method can be
hardcoded in a generated class. This will return null for
an untyped OID.
Return the index of our PC class in the meta data. This can be
called on an unresolved OID and the actual class may
be a subclass of the class for the returned index.
This is getAvailableClassMetaData().index but this method can be
hardcoded in a generated class.
Get the meta data for our class. This will throw a RuntimeException
if called on an unresolved or untyped OID.
See Also:OID.isResolved See Also:OID.resolve
Get the identity type of the class we are referencing. It is ok to
call this for an unresolved OID as the identity type is the same for
all classes in a heirachy.
If this is a real OID (i.e. it has been assigned in the database)
then return itself. Otherwise return the corresponding real OID or
null if none has been allocated yet.
Do we know the actual class of the object we are referencing? An
OID may be created from a reference to a base class. The actual
class of the object referenced might only be detirmined when its
State is fetched from the store.
See Also:OID.resolve
populateObjectIdClassInstance
public void populateObjectIdClassInstance(Object o)(Code)
Populate an instance of the objectid-class for our class from this
OID. This must throw a JDOFatalInternalException if invoked on an
OID for a datastore identity class.
Resolve this OID from the state. This will update our class index
to reflect the state. It is a NOP to call this on an already
resolved OID.
See Also:OID.isResolved