Class OIDGenerator

java.lang.Object
net.simplace.core.service.OIDGenerator

public class OIDGenerator extends Object
This class acts as a factory for unique object identifiers.
Author:
Andreas Enders
  • Method Details

    • getInstance

      public static OIDGenerator getInstance()
      Returns the singleton instance of OIDGenerator, creating it on first call.
      Returns:
      singleton instance of OIDGenerator
    • createOID

      public String createOID()
      Creates an object identifier as a string value without prefix.
      Returns:
      an object identifier of the form -CreationTime-Random
      See Also:
    • createID

      public long createID()
      Creates an object identifier as a 64 bit random number. Uniqueness is not checked.
      Returns:
      a random long value
    • createOID

      public String createOID(String aStartString)
      Creates an object identifier as a string value.

      Format: StartString-CreationTime-Random, where

      • StartString is the given prefix,
      • CreationTime is the time in milliseconds since January 1 1970,
      • Random is a non-negative 64 bit random number.
      CreationTime and Random are encoded with a base 64 alphabet. Identifiers created in the same millisecond differ in the random part: a random number already used in this millisecond is drawn again (no busy waiting for the next millisecond).
      Parameters:
      aStartString - prefix of the identifier
      Returns:
      an object identifier as a string value