org.ceryle.util
Class ID64Generator

java.lang.Object
  extended by org.ceryle.util.ID64Generator
All Implemented Interfaces:
IDGenerator

public class ID64Generator
extends Object
implements IDGenerator

A singleton class that generates a unique ID based on the millisecond timestamp value returned by System.currentTimeMillis() minus the offset from the Java epoch (midnight of January 1st, 1970) to the millenium, converted to a base 64 value. This is guaranteed to be unique within the JVM, as the generator will wait until the next millisecond before creating the next value if queried faster than one millisecond.

Implements the TM4J IDGenerator API.

Usage

     IDGenerator idg = ID64Generator.getInstance();
     String id = idg.getID();
  

Since:
1.4.2
Author:
Murray Altheim
See Also:
IDGenerator

Field Summary
static long MILLENIUM_MILLIS
          The number of milliseconds from the Java 'epoch' (Jan 1, 1970 at midnight) through the beginning of the millenium (Jan 1, 2000 at midnight).
 
Method Summary
 String getID()
          Return a unique ID.
static ID64Generator getInstance()
          Returns the single instance of this class.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MILLENIUM_MILLIS

public static final long MILLENIUM_MILLIS
The number of milliseconds from the Java 'epoch' (Jan 1, 1970 at midnight) through the beginning of the millenium (Jan 1, 2000 at midnight). This is used as the offset for the generated IDs.

See Also:
Constant Field Values
Method Detail

getID

public String getID()
Return a unique ID.

Specified by:
getID in interface IDGenerator

getInstance

public static ID64Generator getInstance()
Returns the single instance of this class.



The Ceryle Project. Copyright ©2001-2007 Murray Altheim, All Rights Reserved. See LICENSE included with distribution.