org.tm4j.topicmap.utils
Class IDGeneratorImpl

java.lang.Object
  extended byorg.tm4j.topicmap.utils.IDGeneratorImpl
All Implemented Interfaces:
IDGenerator

public class IDGeneratorImpl
extends java.lang.Object
implements IDGenerator

The default IDGenerator implementation. This implementation returns a two-part, pseudo-unique ID. The first part of the ID is the time (in milliseconds) of the creation of the object, encoded as a base 30 string. The second part of the ID is a simple incrementing counter. This class does not generate truely unique IDs, but the degree of uniqueness should be sufficient for most applications.


Field Summary
protected  java.lang.String baseID
           
protected  long counter
           
 
Constructor Summary
IDGeneratorImpl()
          Constructs a new IDGeneratorImpl object, with the base part of the ID string set to the time of creation.
 
Method Summary
 java.lang.String getID()
          Returns a pseudo-unique identifier as a concatenation of the base identifier created in the object constructor followed by a dash (-) and then a simple, incrementing counter value (encoded in hexadecimal).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

baseID

protected java.lang.String baseID

counter

protected long counter
Constructor Detail

IDGeneratorImpl

public IDGeneratorImpl()
Constructs a new IDGeneratorImpl object, with the base part of the ID string set to the time of creation.

Method Detail

getID

public java.lang.String getID()
Returns a pseudo-unique identifier as a concatenation of the base identifier created in the object constructor followed by a dash (-) and then a simple, incrementing counter value (encoded in hexadecimal).

Specified by:
getID in interface IDGenerator