org.eaglei.repository.rid
Class RIDGenerator

java.lang.Object
  extended by org.eaglei.repository.rid.RIDGenerator

public final class RIDGenerator
extends java.lang.Object


Field Summary
 boolean flag
           
 
Constructor Summary
protected RIDGenerator(TimeProvider testTP)
          Constructor for RIDGenerator.
 
Method Summary
 RIDSequence getIDSequence(int amount)
          getIDSequence
static RIDGenerator getInstance()
          getInstance
 boolean isUUID()
          Generates a new time field.
 java.util.UUID newID()
          newID
 java.util.UUID[] newIDs(int amount)
          newIDs
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

flag

public boolean flag
Constructor Detail

RIDGenerator

protected RIDGenerator(TimeProvider testTP)

Constructor for RIDGenerator.

Parameters:
testTP - a TimeProvider object.
Method Detail

getInstance

public static RIDGenerator getInstance()

getInstance

Returns:
a RIDGenerator object.

isUUID

public boolean isUUID()
Generates a new time field. Each time field is unique and larger than the previously generated time field.

Returns:
a new time value public static synchronized long newTime() { long timeNano=0l; long timeMilli=System.currentTimeMillis(); if (timeMilli > previousTime) { previousTime = timeNano; } else { if(timeMilli == previousTime) timeNano = ++previousTime; } // UTC time. //Convert to nanoseconds and add 122192928000000000 timeNano = (timeMilli * 10000) + 0x01B21DD213814000L; time |= (timeNano & 0xFFFF00000000L) >> 16; // time hi and version time |= 0x1000 | ((timeNano >> 48) & 0x0FFF); // version 1 return time; }

newID

public java.util.UUID newID()

newID

Returns:
a UUID object.

newIDs

public java.util.UUID[] newIDs(int amount)

newIDs

Parameters:
amount - a int.
Returns:
an array of UUID objects.

getIDSequence

public RIDSequence getIDSequence(int amount)

getIDSequence

Parameters:
amount - a int.
Returns:
a RIDSequence object.


Copyright © 2009-2011 Eagle-I. All Rights Reserved.