org.apache.ojb.broker
Class Identity

java.lang.Object
  extended by org.apache.ojb.broker.Identity
All Implemented Interfaces:
java.io.Serializable

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

Represents the identity of an object.
It's composed of:

To create Identity objects it's strongly recommended to use the IdentityFactory, because in future releases of OJB the Identity constructors will be no longer reachable or forbidden to use.

NOTE: An Identity object must be unique accross extents. Means all objects with the same top-level class need unique PK values.

Version:
$Id: Identity.java 365231 2005-12-21 22:22:08Z tomdz $
Author:
Thomas Mahler
See Also:
IdentityFactory, Serialized Form

Constructor Summary
Identity(java.lang.Class realClass, java.lang.Class topLevel, java.lang.Object[] pkValues)
          For internal use only!
Identity(java.lang.Class realClass, java.lang.Class topLevel, java.lang.Object[] pkValues, boolean isTransient)
          For internal use only!.
Identity(java.lang.Object objectToIdentitify, PersistenceBroker targetBroker)
          Constructor for internal use.
Identity(java.lang.Object objectToIdentitify, PersistenceBroker targetBroker, ClassDescriptor cld)
          Constructor for internal use.
 
Method Summary
 boolean equals(java.lang.Object obj)
          
static Identity fromByteArray(byte[] anArray)
          Deprecated.  
 java.lang.Class getObjectsRealClass()
          Return the "real" class of the real subject.
 java.lang.Class getObjectsTopLevelClass()
          Returns the top-level class of the real subject (base class, base interface denoted in the repository or objects real class if no top-level was found).
 java.lang.Object[] getPrimaryKeyValues()
          Returns the primary key values of the real subject.
 int hashCode()
          
 boolean isTransient()
          Determines whether the identity is transient.
 byte[] serialize()
          Deprecated.  
 void setObjectsRealClass(java.lang.Class objectsRealClass)
          Set the real class of the subject.
 java.lang.String toString()
          return a String representation.
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Identity

public Identity(java.lang.Class realClass,
                java.lang.Class topLevel,
                java.lang.Object[] pkValues,
                boolean isTransient)
For internal use only!. Creates an em from a class and the objects primary key values. used for the definition of proxies.
OJB user have to use IdentityFactory to create object identity.

Parameters:
realClass - the concrete class of the object, or null if not known.
topLevel - the highest persistence-capable class or interface (in the inheritance hierarchy) that the identified object is an instance of
pkValues - (unique across the extents !)
isTransient - If true

Identity

public Identity(java.lang.Class realClass,
                java.lang.Class topLevel,
                java.lang.Object[] pkValues)
For internal use only! Creates an Identity from a class and the objects primary key values. used for the definition of proxies.
OJB user have to use IdentityFactory to create object identity.

Parameters:
realClass - the concrete class of the object, or null if not known.
topLevel - the highest persistence-capable class or interface (in the inheritance hierarchy) that the identified object is an instance of
pkValues - (unique across the extents !)

Identity

public Identity(java.lang.Object objectToIdentitify,
                PersistenceBroker targetBroker)
Constructor for internal use. Use IdentityFactory to create an object identity.

Parameters:
objectToIdentitify - The object for which to create the identity
targetBroker - The persistence broker

Identity

public Identity(java.lang.Object objectToIdentitify,
                PersistenceBroker targetBroker,
                ClassDescriptor cld)
Constructor for internal use. Use IdentityFactory to create an object identity.

Parameters:
objectToIdentitify - The object for which to create the identity
targetBroker - The persistence broker
cld - The class descriptor
Method Detail

fromByteArray

public static Identity fromByteArray(byte[] anArray)
                              throws PersistenceBrokerException
Deprecated. 

Factory method that returns an Identity object created from a serializated representation.

Parameters:
anArray - The serialized representation
Returns:
The identity
Throws:
PersistenceBrokerException
See Also:
#serialize}.

isTransient

public boolean isTransient()
Determines whether the identity is transient.

Returns:
true if the identity is transient

getObjectsTopLevelClass

public java.lang.Class getObjectsTopLevelClass()
Returns the top-level class of the real subject (base class, base interface denoted in the repository or objects real class if no top-level was found).

Returns:
The top level class

getObjectsRealClass

public java.lang.Class getObjectsRealClass()
Return the "real" class of the real subject.

Returns:
The real class

setObjectsRealClass

public void setObjectsRealClass(java.lang.Class objectsRealClass)
Set the real class of the subject.

Parameters:
objectsRealClass - The real class

serialize

public byte[] serialize()
                 throws PersistenceBrokerException
Deprecated. 

Return the serialized form of this Identity.

Returns:
The serialized representation
Throws:
PersistenceBrokerException
See Also:
fromByteArray(byte[])

toString

public java.lang.String toString()
return a String representation.

Overrides:
toString in class java.lang.Object
Returns:
java.lang.String

getPrimaryKeyValues

public java.lang.Object[] getPrimaryKeyValues()
Returns the primary key values of the real subject.

Returns:
The pk values

equals

public boolean equals(java.lang.Object obj)

Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()

Overrides:
hashCode in class java.lang.Object


(C) 2002 - 2006 Apache Software Foundation
All rights reserved. Published under the Apache License 2.0.
http://db.apache.org/ojb
Version: 1.0.4, 2005-12-30