org.apache.activemq.util
Class IdGenerator

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

public class IdGenerator
extends java.lang.Object

Generator for Globally unique Strings.


Constructor Summary
IdGenerator()
           
IdGenerator(java.lang.String prefix)
          Construct an IdGenerator
 
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
 java.lang.String generateSanitizedId()
          Generate a unique ID - that is friendly for a URL or file system
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
static java.lang.String getSeedFromId(java.lang.String id)
          From a generated id - return the seed (i.e.
static long getSequenceFromId(java.lang.String id)
          From a generated id - return the generator count
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IdGenerator

public IdGenerator(java.lang.String prefix)
Construct an IdGenerator


IdGenerator

public IdGenerator()
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

Returns:
the local host name

generateId

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

Returns:
a unique id

generateSanitizedId

public java.lang.String generateSanitizedId()
Generate a unique ID - that is friendly for a URL or file system

Returns:
a unique id

getSeedFromId

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

Parameters:
id - the generated identifer
Returns:
the seed

getSequenceFromId

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

Parameters:
id -
Returns:
the count

compare

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

Parameters:
id1 -
id2 -
Returns:
0 if equal else a positive if id1 is > id2 ...


Copyright © 2005-2011. All Rights Reserved.