org.apache.activemq.util
Class IdGenerator

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

public class IdGenerator
extends Object

Generator for Globally unique Strings.


Field Summary
static String PROPERTY_IDGENERATOR_PORT
           
 
Constructor Summary
IdGenerator()
           
IdGenerator(String prefix)
          Construct an IdGenerator
 
Method Summary
static int compare(String id1, String id2)
          Does a proper compare on the ids
 String generateId()
          Generate a unqiue id
 String generateSanitizedId()
          Generate a unique ID - that is friendly for a URL or file system
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
static String getSeedFromId(String id)
          From a generated id - return the seed (i.e.
static long getSequenceFromId(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
 

Field Detail

PROPERTY_IDGENERATOR_PORT

public static final String PROPERTY_IDGENERATOR_PORT
See Also:
Constant Field Values
Constructor Detail

IdGenerator

public IdGenerator(String prefix)
Construct an IdGenerator


IdGenerator

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

generateSanitizedId

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

Returns:
a unique id

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:
the seed

getSequenceFromId

public static long getSequenceFromId(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:
0 if equal else a positive if id1 is > id2 ...


Copyright © 2005–2013 The Apache Software Foundation. All rights reserved.