hmi.util
Class Id

java.lang.Object
  extended by hmi.util.Id
All Implemented Interfaces:
Cloneable

public final class Id
extends Object
implements Cloneable

Id's are objects that uniquely characterize objects. Id's can only be obtained via the static forName() method. This method ensures that the Id object for a given String is unique. As a consequence one may assume that Id's can be compared for equality by means of the "==" test. This results in very efficient equality testing for Id's, even when these are based on (long) Strings like URI's etc.

Author:
Job Zwiers

Field Summary
private  int hash
           
private static int ID_HASHMAP_SIZE
           
private static Map<String,Id> ids
           
private  String idString
           
 
Constructor Summary
private Id(String idString)
           
 
Method Summary
 Object clone()
          Real cloning an Id is not permitted, as it would violate the assumption that Id's are unique objects.
static Id forName(String idString)
          returns the Id object for idString.
static Id getId(String idString)
          Equivalent to Id.forName. returns the Id object for idString.
 int hashCode()
          optimized hashCode, uses cached hash code of the id String
 String toString()
          The String representation of this Id object.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

idString

private String idString

hash

private int hash

ID_HASHMAP_SIZE

private static final int ID_HASHMAP_SIZE
See Also:
Constant Field Values

ids

private static Map<String,Id> ids
Constructor Detail

Id

private Id(String idString)
Method Detail

toString

public String toString()
The String representation of this Id object. Note that this String uniquely characterizes the Id object.

Overrides:
toString in class Object

hashCode

public int hashCode()
optimized hashCode, uses cached hash code of the id String

Overrides:
hashCode in class Object

clone

public Object clone()
Real cloning an Id is not permitted, as it would violate the assumption that Id's are unique objects. The Id.clone() operation still allows one to call clone() for Id Objects, but simply returns the Id object itself.

Overrides:
clone in class Object

forName

public static Id forName(String idString)
returns the Id object for idString. Repeated calls for the same String will return the same object.


getId

public static Id getId(String idString)
Equivalent to Id.forName. returns the Id object for idString. Repeated calls for the same String will return the same object.