Package org.apache.activemq.util
Class IdGenerator
- java.lang.Object
-
- org.apache.activemq.util.IdGenerator
-
public class IdGenerator extends Object
Generator for Globally unique Strings.
-
-
Field Summary
Fields Modifier and Type Field Description static String
PROPERTY_IDGENERATOR_HOSTNAME
static String
PROPERTY_IDGENERATOR_LOCALPORT
static String
PROPERTY_IDGENERATOR_PORT
-
Constructor Summary
Constructors Constructor Description IdGenerator()
IdGenerator(String prefix)
Construct an IdGenerator
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static int
compare(String id1, String id2)
Does a proper compare on the idsString
generateId()
Generate a unique idString
generateSanitizedId()
Generate a unique ID - that is friendly for a URL or file systemstatic String
getHostName()
As we have to find the hostname as a side-affect of generating a unique stub, we allow it's easy retrieval herestatic 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 countstatic String
sanitizeHostName(String hostName)
-
-
-
Field Detail
-
PROPERTY_IDGENERATOR_HOSTNAME
public static final String PROPERTY_IDGENERATOR_HOSTNAME
- See Also:
- Constant Field Values
-
PROPERTY_IDGENERATOR_LOCALPORT
public static final String PROPERTY_IDGENERATOR_LOCALPORT
- See Also:
- Constant Field Values
-
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 retrieval here- Returns:
- the local host name
-
generateId
public String generateId()
Generate a unique 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 identifier- Returns:
- the seed
-
getSequenceFromId
public static long getSequenceFromId(String id)
From a generated id - return the generator count- Parameters:
id
-- Returns:
- the count
-
-