Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.activemq.util
Class IdGenerator  view IdGenerator download IdGenerator.java

java.lang.Object
  extended byorg.activemq.util.IdGenerator

public class IdGenerator
extends java.lang.Object

Generator for globally unique Strings

Version:
$Revision: 1.1.1.1 $

Field Summary
private static java.lang.String hostName
           
private static int instanceCount
           
private static org.apache.commons.logging.Log log
           
private  java.lang.String seed
           
private  long sequence
           
private  short shortSequence
           
private static java.lang.String UNIQUE_STUB
           
 
Constructor Summary
IdGenerator()
          Construct an IdGenerator
IdGenerator(java.lang.String seed)
          Construct an IdGenerator using the seed provided
 
Method Summary
static int compare(java.lang.String id1, java.lang.String id2)
          Does a proper compare on the ids
 java.lang.String generateId()
          Generate a unqiue id
static long getCountFromId(java.lang.String id)
          From a generated id - return the generator count
static java.lang.String getHostName()
          As we have to find the hostname as a side-affect of generating a unique stub, we allow it's easy retrevial here
 long getNextSequence()
           
 short getNextShortSequence()
           
 java.lang.String getSeed()
           
static java.lang.String getSeedFromId(java.lang.String id)
          From a generated id - return the seed (i.e.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

private static final org.apache.commons.logging.Log log

UNIQUE_STUB

private static final java.lang.String UNIQUE_STUB

instanceCount

private static int instanceCount

hostName

private static java.lang.String hostName

seed

private java.lang.String seed

sequence

private long sequence

shortSequence

private short shortSequence
Constructor Detail

IdGenerator

public IdGenerator()
Construct an IdGenerator


IdGenerator

public IdGenerator(java.lang.String seed)
Construct an IdGenerator using the seed provided

Method Detail

getHostName

public static java.lang.String getHostName()
As we have to find the hostname as a side-affect of generating a unique stub, we allow it's easy retrevial here


generateId

public java.lang.String generateId()
Generate a unqiue id


getSeed

public java.lang.String getSeed()

getNextSequence

public long getNextSequence()

getNextShortSequence

public short getNextShortSequence()

getSeedFromId

public static java.lang.String getSeedFromId(java.lang.String id)
From a generated id - return the seed (i.e. minus the count)


getCountFromId

public static long getCountFromId(java.lang.String id)
From a generated id - return the generator count


compare

public static int compare(java.lang.String id1,
                          java.lang.String id2)
Does a proper compare on the ids