public interface PartsCodec
Encodes the parts of a time-based id as text; the only output of ids wider than 63 bits, such as
Layout.COSID_80 (D4). Replaces the 4.x Radix62CosIdGenerator, Radix36CosIdGenerator,
FriendlyCosIdGenerator and their state parsers.-
Method Summary
Modifier and TypeMethodDescriptionDecodes text produced byencode(IdParts).Encodes the parts of an id.static PartsCodecThe time part asyyyyMMddHHmmssSSSinzone, then the node and the sequence.static PartsCodecThe time part asyyyyMMddHHmmssSSSinzone, then the node and the sequence, padded or not.static PartsCodecEach part inradixat the fixed width its bits need, so the text sorts like the id.
-
Method Details
-
encode
Encodes the parts of an id. An implementation is thread-safe: the generators of a runtime call it concurrently.- Parameters:
parts- the parts- Returns:
- the text, never null
- Throws:
IllegalArgumentException- if the codec cannot encode the parts, such as parts wider than its layout
-
decode
Decodes text produced byencode(IdParts).- Parameters:
text- the text- Returns:
- the parts
- Throws:
IllegalArgumentException- if the text is not encoded parts
-
radix
Each part inradixat the fixed width its bits need, so the text sorts like the id.- Parameters:
layout- the layout of the partsradix- the base, from 2 to 62- Returns:
- the codec
-
friendly
The time part asyyyyMMddHHmmssSSSinzone, then the node and the sequence.As with
Friendly, the repeated hour when a daylight-saving zone goes back decodes to the earlier instant; use UTC or a fixed-offset zone when parts must decode exactly.- Parameters:
layout- the layout of the partszone- the time zone of the time part- Returns:
- the codec
-
friendly
The time part asyyyyMMddHHmmssSSSinzone, then the node and the sequence, padded or not.- Parameters:
layout- the layout of the partszone- the time zone of the time partpadStart- pad the node and the sequence to the width their bits need- Returns:
- the codec
-