ojb.broker
Class Identity

java.lang.Object
  |
  +--ojb.broker.Identity
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
PlzEntryIdentity

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

represents the identity of an object.

See Also:
Serialized Form

Constructor Summary
Identity(java.lang.Class aClass, java.lang.Object[] pkValues)
          creates an Identity from a class and the objects primary key values.
Identity(java.lang.Object objectToIdentitify)
          creates an Identity from an object.
 
Method Summary
 boolean equals(java.lang.Object o)
          Compare this Identity object to any other object.
static Identity fromByteArray(byte[] anArray)
          factory method that returns an Identity object from the serialized Identity in anArray.
 java.lang.Class getObjectsClass()
          return the Class of the real subject
 java.lang.Object[] getPrimaryKeyValues()
          return the list of Primary Key Values of the real subject
 int hashCode()
          Calculate a hashcode for this Identity.
 byte[] serialize()
          return a serialized Identity as byte[]
 java.lang.String toString()
          return a String representation.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Identity

public Identity(java.lang.Object objectToIdentitify)
creates an Identity from an object. Reads the objects primary key values.

Parameters:
objectToIdentitify - java.lang.Object

Identity

public Identity(java.lang.Class aClass,
                java.lang.Object[] pkValues)
creates an Identity from a class and the objects primary key values. used for the definition of proxies. Important note: The caller is responsible to assure that aClass is not a member of an extent, or that it is the base class of an extent!

Parameters:
aClass - java.lang.Class
pkValues - List
Method Detail

fromByteArray

public static Identity fromByteArray(byte[] anArray)
                              throws PersistenceBrokerException
factory method that returns an Identity object from the serialized Identity in anArray.

PersistenceBrokerException

getObjectsClass

public java.lang.Class getObjectsClass()
return the Class of the real subject

Returns:
java.lang.Class

serialize

public byte[] serialize()
                 throws PersistenceBrokerException
return a serialized Identity as byte[]

Returns:
byte[]
PersistenceBrokerException

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()
return the list of Primary Key Values of the real subject

Returns:
Object[]

equals

public boolean equals(java.lang.Object o)
Compare this Identity object to any other object. This comparison is delegated to the super-class.

Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Calculate a hashcode for this Identity. The Hashcode should be equal for Identities where Identity.equals() returns true. Therefore all primary key values that return a hashcode depending on its content (this is assumed for String and Number) are taken into account. Additionally the hashCode() of the Class this Identity is representing is taken into account.

Overrides:
hashCode in class java.lang.Object


Authors: Thomas Mahler and others. (C) 2000, 2001.
All rights reserved. Published under the Gnu Public License.
http://objectbridge.sourceforge.net
Version: 0.8.375, 2002-04-04