org.isam.exehda
Class HierarchicalId

java.lang.Object
  |
  +--org.isam.exehda.HierarchicalId
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
ApplicationId, CellId, HostId, ObjectId

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

Abstract super-class of all system-wide unique IDs. In order to guarantee unicity such IDs are build hierarchically. Hierarchical IDs are build up of two parts a parent ID as a local ID. Unicity is ensured if, for a given parent ID, the chosen local ID is unique.

Version:
$Date: 2004/12/31 21:17:49 $ $Revision: 1.2 $
Author:
last modified by $Author: lucc $
See Also:
ApplicationId, HostId, CellId, ObjectId, Serialized Form

Constructor Summary
protected HierarchicalId(HierarchicalId parentId)
          Creates a new HierachicalId instance.
 
Method Summary
 boolean equals(java.lang.Object o)
          Implements HierarchicalId equality semantics.
protected abstract  java.lang.Object getLocalId()
          Subclasses must overwrite this method and return an Object representation of the local id.
 HierarchicalId getParentId()
          Returns the parent Id of this Id.
protected abstract  java.lang.String getType()
          Subclasses must overwrite this method and return a String representation of the ID's type.
 int hashCode()
          Implements the hash code semantics for HierarchicalId objects so that those object would be used as keys in a java.util Hashtable.
 boolean isRoot()
          Returns whether this ID is a root ID.
 java.lang.String toString()
          Returns a String representation of this ID suitable to be used in debug messages.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

HierarchicalId

protected HierarchicalId(HierarchicalId parentId)
Creates a new HierachicalId instance.

Parameters:
parentId - the parent of the ID been instantiated; null means this is a root ID.
Method Detail

getParentId

public HierarchicalId getParentId()
Returns the parent Id of this Id.

Returns:
the parent ID or null if this is a root ID.

isRoot

public boolean isRoot()
Returns whether this ID is a root ID. Root IDs are those ID's who do not have a parent (i.e. parentId == null).

Returns:
true if this is a root ID, false otherwise.

toString

public java.lang.String toString()
Returns a String representation of this ID suitable to be used in debug messages.

Overrides:
toString in class java.lang.Object
Returns:
this ID formated as a String

equals

public boolean equals(java.lang.Object o)
Implements HierarchicalId equality semantics. Two HierarchicalIds are said to be equal if the equality holds for their local IDs, types and parent IDs respectively. This is a reference implementation. Subclasses are highly encouraged to overwrite this method with faster (optimized) implementations.

Overrides:
equals in class java.lang.Object
Parameters:
o - an Object value
Returns:
true if the given object is equals to this object, false otherwise.

hashCode

public int hashCode()
Implements the hash code semantics for HierarchicalId objects so that those object would be used as keys in a java.util Hashtable. This is a reference implementation. Subclasses are highly encouraged to overwrite this method with faster (optimized) implementations.

Overrides:
hashCode in class java.lang.Object
Returns:
a hash code for this object

getType

protected abstract java.lang.String getType()
Subclasses must overwrite this method and return a String representation of the ID's type.

Returns:
a String value

getLocalId

protected abstract java.lang.Object getLocalId()
Subclasses must overwrite this method and return an Object representation of the local id. Notice that, subclasses may actually store such ID using primitive types, in order to be more efficient, and just wrap such values in an Object when getLocalId() is invoked.

Returns:
an Object value