public interface LongConverter
long values to and from textual
representations. Implementations are typically triggered by annotations such
as LongConversion to encode or decode fields using formats like
hexadecimal, base64 or symbolic alphabets.
Example usage:
LongConverter converter = LongConverter.forSymbols("0123456789ABCDEF");
long value = converter.parse("1A");
StringBuilder out = new StringBuilder();
converter.append(out, value);
LongConversion,
AbstractLongConverter| Modifier and Type | Method and Description |
|---|---|
default void |
addEncode(char alias,
char as)
Introduces a character alias for encoding, facilitating the interpretation of one character
as another during encoding.
|
default boolean |
allSafeChars()
Checks if the characters used are "safe",
meaning they don't require additional quoting or escaping, especially in contexts
like YAML serialization.
|
default void |
append(net.openhft.chronicle.bytes.Bytes<?> destination,
long numericValue)
Converts the given long value to a string and appends it to the provided Bytes object.
|
void |
append(StringBuilder destinationBuilder,
long numericValue)
Appends the textual form of the provided
long to the given
StringBuilder using the converter's formatting rules. |
default String |
asString(long numericValue)
Converts the given long value to a string.
|
default CharSequence |
asText(int numericValue)
Converts the provided integer value to a CharSequence representation.
|
default CharSequence |
asText(long numericValue)
Converts the provided long value to a CharSequence representation.
|
static LongConverter |
forSymbols(String chars)
Creates an instance of the appropriate implementation of
based on the length of the provided character set.
|
default void |
lengthCheck(CharSequence textToCheck)
Checks that the length of the provided text does not exceed the allowable maximum.
|
default void |
lengthCheck(CharSequence textToCheck,
int beginIndex,
int endIndex)
Checks that the length of the provided text does not exceed the allowable maximum.
|
default int |
maxParseLength()
Returns the maximum number of characters that this converter can parse.
|
static int |
maxParseLength(int based)
Calculates the maximum length of a parsed string based on the provided base.
|
long |
parse(CharSequence textToParse)
Parses the given character sequence, which represents a long value in a
specific format, into its numeric form.
|
default long |
parse(CharSequence textToParse,
int beginIndex,
int endIndex)
Parses a part of the provided
CharSequence and returns the parsed results as a
long primitive. |
static LongConverter forSymbols(String chars)
chars - A set of symbols or characters to be used in the conversion.PowerOfTwoLongConverter is returned; otherwise, a SymbolsLongConverter is returned.static int maxParseLength(int based)
based - The base for conversion.long parse(CharSequence textToParse)
textToParse - the character sequence to parse; must not be nulllong value represented by the textIllegalArgumentException - if the text cannot be parsed according to
the converter's rulesdefault long parse(CharSequence textToParse, int beginIndex, int endIndex)
CharSequence and returns the parsed results as a
long primitive.
The default implementation is garbage-producing and an implementing class is supposed to reimplement this method.
textToParse - character sequence containing the string representation of the valuebeginIndex - the beginning index, inclusive.endIndex - the ending index, exclusive.textToParse as a long valueIllegalArgumentException - if any of the indices are invalid or the sub-sequence length is
outside of range accepted by a specific converter.void append(StringBuilder destinationBuilder, long numericValue)
long to the given
StringBuilder using the converter's formatting rules.destinationBuilder - the builder to append tonumericValue - the long value to convertdefault void append(net.openhft.chronicle.bytes.Bytes<?> destination,
long numericValue)
destination - the Bytes object to append tonumericValue - the long value to convertdefault String asString(long numericValue)
numericValue - the long value to convertdefault CharSequence asText(int numericValue)
numericValue - the integer value to convertdefault CharSequence asText(long numericValue)
numericValue - the long value to convertdefault int maxParseLength()
default void lengthCheck(CharSequence textToCheck)
textToCheck - The text to checkIllegalArgumentException - if the text length exceeds the maximum allowable length.default void lengthCheck(CharSequence textToCheck, int beginIndex, int endIndex)
textToCheck - The text to checkbeginIndex - the beginning index, inclusive.endIndex - the ending index, exclusive.IllegalArgumentException - if the text length exceeds the maximum allowable length.default boolean allSafeChars()
true if no characters need escaping or additional quoting for JSON or YAML, false otherwise.default void addEncode(char alias,
char as)
alias - The character to treat as an alias.as - The character that the alias should be treated as.UnsupportedOperationException - If the operation is not supported.Copyright © 2026 Chronicle Software Ltd. All rights reserved.