org.jlf.dataMap
Class DataObject

java.lang.Object
  |
  +--org.jlf.dataMap.DataObject
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
DataMappedObject, DataMappedObjectKey

public abstract class DataObject
extends java.lang.Object
implements java.io.Serializable

Abstract class used as the base of all objects in the data mapping framework. It holds and manipulates collections of DataAttributes.

See Also:
DataAttribute, Serialized Form

Field Summary
protected static java.lang.String ATTRIBUTE_DESCRIPTOR_VECTOR_VARIABLE_NAME
           
protected  java.util.Hashtable attributes
          Holds all the lazy-initialized attributes for this particular business object.
protected static int INITIAL_ATTRIBUTE_DESCRIPTOR_HASHTABLE_SIZE
           
protected static int INITIAL_ATTRIBUTE_HASHTABLE_SIZE
           
 
Constructor Summary
DataObject()
           
 
Method Summary
protected  boolean attributeEquals(java.util.Hashtable mainAttributeTable, java.util.Hashtable comparisionAttributeTable)
          This is a helper method to compare two Hashtables of DataAttributes.
protected  java.util.Hashtable basicGetAttributeDescriptors()
          Returns a hash table of DataAttribute objects pertinent to the DataMappedObject.
 boolean equals(java.lang.Object object)
          Re-implement the equals method to compare two DataObjects.
 java.util.Set getAllAttributeNames()
          Returns a set of attribute names (Strings) for all of the attribute descriptors available to the object.
 DataAttribute getAttribute(java.lang.String name)
          Returns a attribute object for a particular attribute name.
 DataAttributeDescriptor getAttributeDescriptor(java.lang.String name)
          Returns a attribute descriptor for a particular attribute name.
protected  java.util.Hashtable getAttributeDescriptors()
          Returns a lazy-initialized collection of DataAttribute objects pertinent to the DataMappedObject.
 java.lang.Object getAttributeValue(java.lang.String name)
          Returns the value of an attribute object for a particular attribute name.
 double getDoubleAttribute(java.lang.String name)
          Returns the value of an attribute as a double.
 long getLongAttribute(java.lang.String name)
          Returns the value of an attribute as a long.
 java.lang.String getStringAttribute(java.lang.String name)
          Returns the value of an attribute as a String.
 boolean hasAttributeDefined(java.lang.String attributeName)
          Determines whether a data object has a named data attribute defined.
 int hashCode()
          Re-implement the hashCode() method to synch with equals(Object) method, hashing all of the attribute values.
 void setAttributeValue(java.lang.String name, java.lang.Object value)
          Passthrough method to set an attribute's value with a non-type-specific accessor.
 void setDoubleAttribute(java.lang.String name, double value)
          Sets the value of an attribute as a double.
 void setLongAttribute(java.lang.String name, long value)
          Sets the value of an attribute as a long.
 void setStringAttribute(java.lang.String name, java.lang.String value)
          Sets the value of an attribute as a String.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INITIAL_ATTRIBUTE_DESCRIPTOR_HASHTABLE_SIZE

protected static final int INITIAL_ATTRIBUTE_DESCRIPTOR_HASHTABLE_SIZE
See Also:
Constant Field Values

INITIAL_ATTRIBUTE_HASHTABLE_SIZE

protected static final int INITIAL_ATTRIBUTE_HASHTABLE_SIZE
See Also:
Constant Field Values

ATTRIBUTE_DESCRIPTOR_VECTOR_VARIABLE_NAME

protected static final java.lang.String ATTRIBUTE_DESCRIPTOR_VECTOR_VARIABLE_NAME
See Also:
Constant Field Values

attributes

protected java.util.Hashtable attributes
Holds all the lazy-initialized attributes for this particular business object.

Constructor Detail

DataObject

public DataObject()
Method Detail

basicGetAttributeDescriptors

protected java.util.Hashtable basicGetAttributeDescriptors()
Returns a hash table of DataAttribute objects pertinent to the DataMappedObject. This method is not lazy-initialized. Subclasses with attributes SHOULD OVERRIDE this method, calling the superclass method of same name and adding to the Hashtable any DataAttributeDescriptor objects pertinent. Use the attribute name as the key and a DataAttributeDescriptor object as the value.

At this level in the hierarchy, no attribute descriptors are known. Return an empty hash table that can be populated by the subclass(es).


getAttributeDescriptors

protected java.util.Hashtable getAttributeDescriptors()
Returns a lazy-initialized collection of DataAttribute objects pertinent to the DataMappedObject. This method uses a ClassInstanceVariable as a convenient way to do the lazy-initialization.


getAllAttributeNames

public java.util.Set getAllAttributeNames()
Returns a set of attribute names (Strings) for all of the attribute descriptors available to the object.


hasAttributeDefined

public boolean hasAttributeDefined(java.lang.String attributeName)
Determines whether a data object has a named data attribute defined.


getAttributeDescriptor

public DataAttributeDescriptor getAttributeDescriptor(java.lang.String name)
Returns a attribute descriptor for a particular attribute name.

Returns:
the DataAttributeDescriptor if found
Throws:
DataMapError - if attribute descriptor not found

getAttribute

public DataAttribute getAttribute(java.lang.String name)
Returns a attribute object for a particular attribute name.

Returns:
the DataAttribute if found
Throws:
DataMapError - if attribute name not found

getAttributeValue

public java.lang.Object getAttributeValue(java.lang.String name)
Returns the value of an attribute object for a particular attribute name. This is a non-type-specific accessor, generally you don't want this, instead you want a type-specific getter below.

Returns:
null if attribute's current value is null.

setAttributeValue

public void setAttributeValue(java.lang.String name,
                              java.lang.Object value)
Passthrough method to set an attribute's value with a non-type-specific accessor. Generally you don't want this, instead you want a type-specific setter below.


getStringAttribute

public java.lang.String getStringAttribute(java.lang.String name)
Returns the value of an attribute as a String. Pass-through method to the attribute's getStringValue() method.


setStringAttribute

public void setStringAttribute(java.lang.String name,
                               java.lang.String value)
Sets the value of an attribute as a String. Pass-through method to the attribute's setValue() method.


getLongAttribute

public long getLongAttribute(java.lang.String name)
Returns the value of an attribute as a long. Pass-through method to the attribute's getLongValue() method.


setLongAttribute

public void setLongAttribute(java.lang.String name,
                             long value)
Sets the value of an attribute as a long. Pass-through method to the attribute's setLongValue() method.


getDoubleAttribute

public double getDoubleAttribute(java.lang.String name)
Returns the value of an attribute as a double. Pass-through method to the attribute's getDoubleValue() method.


setDoubleAttribute

public void setDoubleAttribute(java.lang.String name,
                               double value)
Sets the value of an attribute as a double. Pass-through method to the attribute's setDoubleValue() method.


attributeEquals

protected boolean attributeEquals(java.util.Hashtable mainAttributeTable,
                                  java.util.Hashtable comparisionAttributeTable)
This is a helper method to compare two Hashtables of DataAttributes.


equals

public boolean equals(java.lang.Object object)
Re-implement the equals method to compare two DataObjects. This method considers them equal if the two have identical attribute names with identical values.

Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Re-implement the hashCode() method to synch with equals(Object) method, hashing all of the attribute values.

Overrides:
hashCode in class java.lang.Object