- java.lang.Object
-
- com.github.f4b6a3.uuid.codec.other.NcnameCodec
-
public final class NcnameCodec extends Object implements UuidCodec<String>
Codec for UUID NCNames.A UUID NCName is a shorter string representation that conforms to the constraints of various other identifiers such as NCName in XML documents.
The
NcnameCodecturns 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
Base32Codeccan be passed to theNcnameCodecconstructor 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.
SlugCodecandNcnameCodecare very similar. The difference between the two is the bit shift they do with the original UUID to transform it into a string.- See Also:
- UUID NCNames
-
-
Field Summary
Fields Modifier and Type Field Description static NcnameCodecINSTANCEA shared immutable instance using `base64url`
-
Constructor Summary
Constructors Constructor Description NcnameCodec()NcnameCodec(BaseNCodec codec)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description UUIDdecode(String ncname)Get a UUID from a NCName.Stringencode(UUID uuid)Get a NCName from a UUID.
-
-
-
Field Detail
-
INSTANCE
public static final NcnameCodec INSTANCE
A shared immutable instance using `base64url`
-
-
Constructor Detail
-
NcnameCodec
public NcnameCodec()
-
NcnameCodec
public NcnameCodec(BaseNCodec codec)
-
-