com.sptci.jdo
Class JDOObject

java.lang.Object
  extended by com.sptci.jdo.JDOObject
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.lang.Comparable<JDOObject>, javax.jdo.InstanceCallbacks, javax.jdo.listener.ClearCallback, javax.jdo.listener.DeleteCallback, javax.jdo.listener.LoadCallback, javax.jdo.listener.StoreCallback

public abstract class JDOObject
extends java.lang.Object
implements java.lang.Cloneable, java.lang.Comparable<JDOObject>, java.io.Serializable, javax.jdo.InstanceCallbacks

A base object from which all the JDO Object classes will be derived. Provides default implementations for common methods.

Version:
$Id: JDOObject.java,v 1.2 2006/02/15 00:48:26 rakesh Exp $
Author:
Rakesh Vidyadharan 05th February, 2006

Copyright 2006, Sans Pareil Technologies, Inc.

See Also:
Serialized Form

Field Summary
protected  int hash
          The integer that represents the hash code for this object.
protected static int HASH
          The default value to use for hash.
protected  java.util.Collection<java.lang.String> metaphones
          A collection of metaphone words used to perform a search across each Extent in the database for similar sounding words.
protected  java.util.Collection<java.lang.String> words
          A collection of words used to perform whole-word search across each Extent in the database.
 
Constructor Summary
protected JDOObject()
          Default constructor.
 
Method Summary
 java.lang.Object clone()
          Creates and returns a copy of this object.
 int compareTo(JDOObject object)
          Compares this object with the specified object for order.
protected abstract
<E extends JDOObject>
void
copy(E object)
          Copy constructor equivalent.
protected static com.thoughtworks.xstream.XStream createXStream()
          Return the utility used to convert the object to and from XML representation.
abstract  boolean equals(java.lang.Object object)
          Compare the specified object with this object for equality.
static JDOObject fromXML(java.lang.String xml)
          Parse the object out of the XML representation of this object.
abstract  int hashCode()
          Return a hash code for this object.
 void jdoPostLoad()
          InstanceCallbacks method implementation.
 void jdoPreClear()
          InstanceCallbacks method implementation.
 void jdoPreDelete()
          InstanceCallbacks method implementation.
 void jdoPreStore()
          InstanceCallbacks method implementation.
 void resetHash()
          Reset the hash value.
 java.lang.String toString()
          Return a string representation of this object.
 java.lang.String toXML()
          Return an XML representation of the fields of this object.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

HASH

protected static final int HASH
The default value to use for hash.

See Also:
Constant Field Values

hash

protected int hash
The integer that represents the hash code for this object.


words

protected transient java.util.Collection<java.lang.String> words
A collection of words used to perform whole-word search across each Extent in the database.


metaphones

protected transient java.util.Collection<java.lang.String> metaphones
A collection of metaphone words used to perform a search across each Extent in the database for similar sounding words.

Constructor Detail

JDOObject

protected JDOObject()
Default constructor. Initialise words and metaphones with empty collections. Cannot be instantiated.

Method Detail

toString

public java.lang.String toString()
Return a string representation of this object. Return an XML representation of the data-fields.

Overrides:
toString in class java.lang.Object
Returns:
String The xml representation of this class.
See Also:
toXML()

hashCode

public abstract int hashCode()
Return a hash code for this object.

Overrides:
hashCode in class java.lang.Object

equals

public abstract boolean equals(java.lang.Object object)
Compare the specified object with this object for equality. Returns true if the specified object is of the same type as this object, and the values of hashCode() match.

Overrides:
equals in class java.lang.Object
Parameters:
object - The object that is to compared with this object.
Returns:
boolean Returns true if the objects have the same hash code.

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Creates and returns a copy of this object. Implementation of the Cloneable interface. No special actions are performed. This method simply allows public access to the Object.clone method.

Overrides:
clone in class java.lang.Object
Returns:
Object A clone of this instance.
Throws:
java.lang.CloneNotSupportedException - If the super-class implementation throws an error.

compareTo

public int compareTo(JDOObject object)
Compares this object with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

Note: The default implementation just compares the hashCode() values. It is recommended that sub-classes over-ride this method for appropriate sort order.

Specified by:
compareTo in interface java.lang.Comparable<JDOObject>
Parameters:
object - The object that is to be compared with this object.
Returns:
int A negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

createXStream

protected static com.thoughtworks.xstream.XStream createXStream()
Return the utility used to convert the object to and from XML representation. This method must be used by the toXML() and fromXML(java.lang.String) methods to initialise the serialiser in a standard manner.


toXML

public java.lang.String toXML()
Return an XML representation of the fields of this object. It is recommended that sub-classes over-ride this method to specify good aliases for fully qualified class names to make the XML for readable.

Note: Currently this method uses the XStream API to convert the object into XML. This may be modified at a later date to convert into a TMS standard XML format.

Returns:
String - The string representation of this object.
See Also:
createXStream(), fromXML(java.lang.String)

fromXML

public static JDOObject fromXML(java.lang.String xml)
Parse the object out of the XML representation of this object. It is recommended that sub-classes over-ride this method to specify good aliases for fully qualified class names to make the XML for readable.

Parameters:
xml - The XML representation of this object.
Returns:
Program The object parsed out of the XML representation.
See Also:
createXStream(), toXML()

resetHash

public final void resetHash()
Reset the hash value.


copy

protected abstract <E extends JDOObject> void copy(E object)
Copy constructor equivalent. Update the fields of the class from the specified instance.

Parameters:
object - The instance from which the fields of this object are to be updated.

jdoPostLoad

public void jdoPostLoad()
InstanceCallbacks method implementation. No actions required by default.

Specified by:
jdoPostLoad in interface javax.jdo.listener.LoadCallback

jdoPreStore

public void jdoPreStore()
InstanceCallbacks method implementation. No actions required.

Specified by:
jdoPreStore in interface javax.jdo.listener.StoreCallback

jdoPreClear

public void jdoPreClear()
InstanceCallbacks method implementation. No actions required.

Specified by:
jdoPreClear in interface javax.jdo.listener.ClearCallback

jdoPreDelete

public void jdoPreDelete()
InstanceCallbacks method implementation. No actions required.

Specified by:
jdoPreDelete in interface javax.jdo.listener.DeleteCallback


Copyright © 2006 Sans Pareil Technologies, Inc. All Rights Reserved.