Class IdGenerator

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

public class IdGenerator extends Object
Generator for Globally unique Strings.
  • Field Details

  • Constructor Details

    • IdGenerator

      public IdGenerator(String prefix)
      Construct an IdGenerator
    • IdGenerator

      public IdGenerator()
  • Method Details

    • 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
    • sanitizeHostName

      public static String sanitizeHostName(String hostName)
    • 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
    • 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 ...