You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-dev@db.apache.org by br...@apache.org on 2003/10/18 11:29:39 UTC
cvs commit: db-ojb/src/java/org/apache/ojb/broker Identity.java
brj 2003/10/18 02:29:39
Modified: src/java/org/apache/ojb/broker Identity.java
Log:
javadoc updates
Revision Changes Path
1.27 +54 -49 db-ojb/src/java/org/apache/ojb/broker/Identity.java
Index: Identity.java
===================================================================
RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/Identity.java,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -r1.26 -r1.27
--- Identity.java 4 Sep 2003 14:18:48 -0000 1.26
+++ Identity.java 18 Oct 2003 09:29:38 -0000 1.27
@@ -77,6 +77,7 @@
/**
* represents the identity of an object.
+ * identity (it's primary keys) must be unique accross extents !
*
* @author <a href="mailto:thma@apache.org">Thomas Mahler<a>
* @version $Id$
@@ -87,35 +88,35 @@
* the top-level Class of the identified object<br>
* ie: an Interface
*/
- private Class objectsTopLevelClass;
+ private Class m_objectsTopLevelClass;
/**
* the real Class of the identified object<br>
* ie: the implementing Class
*/
- private Class objectsRealClass = null;
+ private Class m_objectsRealClass = null;
/**
* The ordered list of primary key values maintaining the objects identity in the underlying RDBMS
*/
- private Object[] pkValues;
- private String stringRepresentation = null;
- private Integer hashCode;
+ private Object[] m_pkValues;
+ private String m_stringRepresentation = null;
+ private Integer m_hashCode;
/**
* creates an Identity from a class and the objects primary key values.
* used for the definition of proxies.
*
- * @param realClass the highest persistence-capable class or
+ * @param realClass the concrete class of the object, or null if not known.
+ * @param topLevel the highest persistence-capable class or
* interface (in the inheritance hierarchy) that the identified object is an instance of
- * @param topLevel the concrete class of the object, or null if not known.
- * @param pkValues
+ * @param pkValues (unique across the extents !)
*/
public Identity(Class realClass, Class topLevel, Object[] pkValues)
{
- this.objectsTopLevelClass = topLevel;
- this.objectsRealClass = realClass;
- this.pkValues = pkValues;
+ m_objectsTopLevelClass = topLevel;
+ m_objectsRealClass = realClass;
+ m_pkValues = pkValues;
checkForPrimaryKeys();
}
@@ -138,9 +139,9 @@
{
VirtualProxy p = (VirtualProxy) objectToIdentitify;
Identity sourceOID = p.getIdentity();
- this.objectsTopLevelClass = sourceOID.objectsTopLevelClass;
- this.objectsRealClass = sourceOID.objectsRealClass;
- this.pkValues = sourceOID.pkValues;
+ m_objectsTopLevelClass = sourceOID.m_objectsTopLevelClass;
+ m_objectsRealClass = sourceOID.m_objectsRealClass;
+ m_pkValues = sourceOID.m_pkValues;
}
else if (objectToIdentitify instanceof Proxy)
{
@@ -149,20 +150,24 @@
// IndirectionHandler ih = (IndirectionHandler) h;
IndirectionHandler ih = (IndirectionHandler) Proxy.getInvocationHandler(objectToIdentitify);
Identity sourceOID = ih.getIdentity();
- this.objectsTopLevelClass = sourceOID.objectsTopLevelClass;
- this.objectsRealClass = sourceOID.objectsRealClass;
- this.pkValues = sourceOID.pkValues;
+ m_objectsTopLevelClass = sourceOID.m_objectsTopLevelClass;
+ m_objectsRealClass = sourceOID.m_objectsRealClass;
+ m_pkValues = sourceOID.m_pkValues;
}
else
{
- if (cld == null) cld = targetBroker.getClassDescriptor(objectToIdentitify.getClass());
+ if (cld == null)
+ {
+ cld = targetBroker.getClassDescriptor(objectToIdentitify.getClass());
+ }
+
// identities must be unique accross extents !
- this.objectsTopLevelClass = targetBroker.getTopLevelClass(objectToIdentitify.getClass());
- this.objectsRealClass = objectToIdentitify.getClass();
+ m_objectsTopLevelClass = targetBroker.getTopLevelClass(objectToIdentitify.getClass());
+ m_objectsRealClass = objectToIdentitify.getClass();
// BRJ: definitely do NOT convertToSql
// conversion is done when binding the sql-statement
- this.pkValues = targetBroker.serviceBrokerHelper().getKeyValues(cld, objectToIdentitify, false);
+ m_pkValues = targetBroker.serviceBrokerHelper().getKeyValues(cld, objectToIdentitify, false);
}
checkForPrimaryKeys();
@@ -209,7 +214,7 @@
*/
public Class getObjectsTopLevelClass()
{
- return objectsTopLevelClass;
+ return m_objectsTopLevelClass;
}
/**
@@ -217,7 +222,7 @@
*/
public Class getObjectsRealClass()
{
- return objectsRealClass;
+ return m_objectsRealClass;
}
/**
@@ -225,7 +230,7 @@
*/
public void setObjectsRealClass(Class objectsRealClass)
{
- this.objectsRealClass = objectsRealClass;
+ this.m_objectsRealClass = objectsRealClass;
}
/**
@@ -262,19 +267,19 @@
*/
public String toString()
{
- if (stringRepresentation == null)
+ if (m_stringRepresentation == null)
{
StringBuffer buf = new StringBuffer();
- buf.append(objectsTopLevelClass.getName());
- for (int i = 0; i < pkValues.length; i++)
+ buf.append(m_objectsTopLevelClass.getName());
+ for (int i = 0; i < m_pkValues.length; i++)
{
buf.append((i == 0) ? "{" : ",");
- buf.append(pkValues[i]);
+ buf.append(m_pkValues[i]);
}
buf.append("}");
- stringRepresentation = buf.toString();
+ m_stringRepresentation = buf.toString();
}
- return stringRepresentation;
+ return m_stringRepresentation;
}
@@ -287,26 +292,23 @@
protected void checkForPrimaryKeys() throws ClassNotPersistenceCapableException
{
// if no PKs are specified OJB can't handle this class !
- if (this.pkValues.length == 0)
+ if (m_pkValues.length == 0)
{
throw new ClassNotPersistenceCapableException(
"OJB needs at least one primary key attribute for class "
- + " objectsRealClass=" + this.objectsRealClass
- + ", objectTopLevelClass=" + this.objectsTopLevelClass);
+ + " objectsRealClass=" + m_objectsRealClass
+ + ", objectTopLevelClass=" + m_objectsTopLevelClass);
}
}
/**
- *
* return the list of Primary Key Values of the real subject
- *
* @return Object[]
- *
*/
public Object[] getPrimaryKeyValues()
{
- return pkValues;
+ return m_pkValues;
}
/**
@@ -316,22 +318,25 @@
public boolean equals(Object o)
{
boolean result;
+
if (o instanceof org.apache.ojb.broker.Identity)
{
Identity id = (Identity) o;
Object otherPkValues[] = id.getPrimaryKeyValues();
- result = this.getObjectsTopLevelClass().equals(id.getObjectsTopLevelClass());
- result = result && (pkValues.length == otherPkValues.length);
- for (int i = 0; result && i < pkValues.length; i++)
+
+ result = getObjectsTopLevelClass().equals(id.getObjectsTopLevelClass());
+ result = result && (m_pkValues.length == otherPkValues.length);
+ for (int i = 0; result && i < m_pkValues.length; i++)
{
- result = (pkValues[i] == null) ? (otherPkValues[i] == null)
- : pkValues[i].equals(otherPkValues[i]);
+ result = (m_pkValues[i] == null) ? (otherPkValues[i] == null)
+ : m_pkValues[i].equals(otherPkValues[i]);
}
}
else
{
result = super.equals(o);
}
+
return result;
}
@@ -348,16 +353,16 @@
// arminw:
// identity is quasi immutable, thus
// we can note hashCode
- if(hashCode == null)
+ if(m_hashCode == null)
{
- int result = this.getObjectsTopLevelClass().hashCode();
+ int result = getObjectsTopLevelClass().hashCode();
- for (int i = 0; i < pkValues.length; i++)
+ for (int i = 0; i < m_pkValues.length; i++)
{
- if (pkValues[i] != null) result ^= pkValues[i].hashCode();
+ if (m_pkValues[i] != null) result ^= m_pkValues[i].hashCode();
}
- hashCode = new Integer(result);
+ m_hashCode = new Integer(result);
}
- return hashCode.intValue();
+ return m_hashCode.intValue();
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org