Class NameBasedGenerator


public class NameBasedGenerator extends StringArgGenerator
Implementation of UUID generator that uses one of name-based generation methods (versions 3 (MD5) and 5 (SHA1)).

As all JUG provided implementations, this generator is fully thread-safe; access to digester is synchronized as necessary.

Since:
3.0
  • Field Details

    • _utf8

      public static final Charset _utf8
    • NAMESPACE_DNS

      public static final UUID NAMESPACE_DNS
      Namespace used when name is a DNS name.
    • NAMESPACE_URL

      public static final UUID NAMESPACE_URL
      Namespace used when name is a URL.
    • NAMESPACE_OID

      public static final UUID NAMESPACE_OID
      Namespace used when name is an OID.
    • NAMESPACE_X500

      public static final UUID NAMESPACE_X500
      Namespace used when name is an X500 identifier
    • _namespace

      protected final UUID _namespace
      Namespace to use as prefix.
    • _digester

      protected final MessageDigest _digester
      Message digesster to use for hash calculation
    • _type

      protected final UUIDType _type
  • Constructor Details

    • NameBasedGenerator

      public NameBasedGenerator(UUID namespace, MessageDigest digester, UUIDType type)
      Parameters:
      namespace - of the namespace, as defined by the spec. UUID has 4 pre-defined "standard" name space strings that can be passed to UUID constructor (see example below). Note that this argument is optional; if no namespace is needed (for example when name includes namespace prefix), null may be passed.
      digester - Hashing algorithm to use.
  • Method Details

    • getType

      public UUIDType getType()
      Description copied from class: UUIDGenerator
      Accessor for determining type of UUIDs (version) that this generator instance will produce.
      Specified by:
      getType in class UUIDGenerator
    • getNamespace

      public UUID getNamespace()
    • generate

      public UUID generate(String name)
      Description copied from class: StringArgGenerator
      Method for generating name-based UUIDs using specified name (serialized to bytes using UTF-8 encoding)
      Specified by:
      generate in class StringArgGenerator
    • generate

      public UUID generate(byte[] nameBytes)
      Description copied from class: StringArgGenerator
      Method for generating name-based UUIDs using specified byte-serialization of name.
      Specified by:
      generate in class StringArgGenerator