public class NameBasedGenerator extends StringArgGenerator
As all JUG provided implementations, this generator is fully thread-safe; access to digester is synchronized as necessary.
| Modifier and Type | Field and Description |
|---|---|
protected MessageDigest |
_digester
Message digesster to use for hash calculation
|
protected UUID |
_namespace
Namespace to use as prefix.
|
protected UUIDType |
_type |
static Charset |
_utf8 |
static UUID |
NAMESPACE_DNS
Namespace used when name is a DNS name.
|
static UUID |
NAMESPACE_OID
Namespace used when name is an OID.
|
static UUID |
NAMESPACE_URL
Namespace used when name is a URL.
|
static UUID |
NAMESPACE_X500
Namespace used when name is an X500 identifier
|
| Constructor and Description |
|---|
NameBasedGenerator(UUID namespace,
MessageDigest digester,
UUIDType type) |
| Modifier and Type | Method and Description |
|---|---|
UUID |
generate(byte[] nameBytes)
Method for generating name-based UUIDs using specified byte-serialization
of name.
|
UUID |
generate(String name)
Method for generating name-based UUIDs using specified name (serialized to
bytes using UTF-8 encoding)
|
UUID |
getNamespace() |
UUIDType |
getType()
Accessor for determining type of UUIDs (version) that this
generator instance will produce.
|
public static final Charset _utf8
public static final UUID NAMESPACE_DNS
public static final UUID NAMESPACE_URL
public static final UUID NAMESPACE_OID
public static final UUID NAMESPACE_X500
protected final UUID _namespace
protected final MessageDigest _digester
protected final UUIDType _type
public NameBasedGenerator(UUID namespace, MessageDigest digester, UUIDType type)
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.public UUIDType getType()
UUIDGeneratorgetType in class UUIDGeneratorpublic UUID getNamespace()
public UUID generate(String name)
StringArgGeneratorgenerate in class StringArgGeneratorpublic UUID generate(byte[] nameBytes)
StringArgGeneratorgenerate in class StringArgGeneratorCopyright © 2023 FasterXML.com. All rights reserved.