public final class NcnameCodec extends Object implements UuidCodec<String>
A UUID NCName is a shorter string representation that conforms to the constraints of various other identifiers such as NCName in XML documents.
The NcnameCodec turns a UUID into a string that does not start with
digits (0-9). But due to the default base-64-url encoding, it is case
sensitive and may contain '-' and '_'.
The Base32Codec can be passed to the NcnameCodec constructor
to generate base-32 NCNames. Due to the base-32 alphabet, it is case
insensitive and it contains only letters (a-zA-Z) and digits (2-7). This
encoding substitution can be done to avoid the characters '-' and '_' of the
base-64-url encoding, but it makes the NCName case insensitive.
The transformation scheme is outlined in this RFC: https://tools.ietf.org/html/draft-taylor-uuid-ncname-00. The draft describes schemes for base-64-url and base-32.
SlugCodec and NcnameCodec are very similar. The difference
between the two is the bit shift they do with the original UUID to transform
it into a string.
| Modifier and Type | Field and Description |
|---|---|
static NcnameCodec |
INSTANCE
A shared immutable instance using `base64url`
|
| Constructor and Description |
|---|
NcnameCodec()
Default constructor.
|
NcnameCodec(BaseNCodec codec)
Constructor with a base-n codec.
|
| Modifier and Type | Method and Description |
|---|---|
UUID |
decode(String ncname)
Get a UUID from a NCName.
|
String |
encode(UUID uuid)
Get a NCName from a UUID.
|
public static final NcnameCodec INSTANCE
public NcnameCodec()
public NcnameCodec(BaseNCodec codec)
codec - a base-n codecCopyright © 2024. All rights reserved.