com.fasterxml.uuid
Class UUIDTimer

java.lang.Object
  extended by com.fasterxml.uuid.UUIDTimer

public final class UUIDTimer
extends Object

UUIDTimer produces the time stamps required for time-based UUIDs. It works as outlined in the UUID specification, with following implementation:

Some additional assumptions about calculating the timestamp:

Note about synchronization: this class is assumed to always be called from a synchronized context (caller locks on either this object, or a similar timer lock), and so has no method synchronization.


Field Summary
protected  Random mRnd
          Random number generator used to generate additional information to further reduce probability of collisions.
protected  TimestampSynchronizer mSync
          Object used to reliably ensure that no multiple JVMs generate UUIDs, and also that the time stamp value used for generating time-based UUIDs is monotonically increasing even if system clock moves backwards over a reboot (usually due to some system level problem).
 
Constructor Summary
UUIDTimer(Random rnd, TimestampSynchronizer sync)
           
 
Method Summary
 void getAndSetTimestamp(byte[] uuidBytes)
          Method for accessing timestamp to use for creating UUIDs.
 long getTimestamp(byte[] uuidBytes)
          Method that constructs timestamp unique and suitable to use for constructing UUIDs.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mSync

protected final TimestampSynchronizer mSync
Object used to reliably ensure that no multiple JVMs generate UUIDs, and also that the time stamp value used for generating time-based UUIDs is monotonically increasing even if system clock moves backwards over a reboot (usually due to some system level problem).

See TimestampSynchronizer for details.


mRnd

protected final Random mRnd
Random number generator used to generate additional information to further reduce probability of collisions.

Constructor Detail

UUIDTimer

public UUIDTimer(Random rnd,
                 TimestampSynchronizer sync)
          throws IOException
Throws:
IOException
Method Detail

getTimestamp

public final long getTimestamp(byte[] uuidBytes)
Method that constructs timestamp unique and suitable to use for constructing UUIDs.

Returns:
64-bit timestamp to use for constructing UUID

getAndSetTimestamp

public final void getAndSetTimestamp(byte[] uuidBytes)
Method for accessing timestamp to use for creating UUIDs.



Copyright © 2010 FasterXML.com. All Rights Reserved.