org.activemq.util
Class IdGenerator

java.lang.Object
  extended by org.activemq.util.IdGenerator

public class IdGenerator
extends Object

Generator for globally unique Strings

Version:
$Revision: 1.1.1.1 $

Constructor Summary
IdGenerator()
          Construct an IdGenerator
IdGenerator(String seed)
          Construct an IdGenerator using the seed provided
 
Method Summary
static int compare(String id1, String id2)
          Does a proper compare on the ids
 String generateId()
          Generate a unqiue id
static long getCountFromId(String id)
          From a generated id - return the generator count
static 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()
           
 String getSeed()
           
static String getSeedFromId(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
 

Constructor Detail

IdGenerator

public IdGenerator()
Construct an IdGenerator


IdGenerator

public IdGenerator(String seed)
Construct an IdGenerator using the seed provided

Parameters:
seed -
Method Detail

getHostName

public static 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

Returns:
the local host name

generateId

public String generateId()
Generate a unqiue id

Returns:
a unique id

getSeed

public String getSeed()
Returns:
the unique seed used by this generator

getNextSequence

public long getNextSequence()
Returns:
the next sequence

getNextShortSequence

public short getNextShortSequence()
Returns:
the next short sequence

getSeedFromId

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

Parameters:
id - the generated identifer
Returns:

getCountFromId

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

Parameters:
id -
Returns:
the count

compare

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

Parameters:
id1 -
id2 -
Returns:


Copyright © 2004-2010 Protique, Ltd.. All Rights Reserved.