public interface LongConverter
The conversion allows encoding long values into compact, human-readable strings and vice versa, useful in contexts where storage efficiency or readability is a concern.
| 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 boolean |
allSafeChars(WireOut wireOut)
Deprecated.
|
default void |
append(net.openhft.chronicle.bytes.Bytes<?> bytes,
long value)
Converts the given long value to a string and appends it to the provided Bytes object.
|
void |
append(StringBuilder text,
long value)
Converts the given long value to a string and appends it to the provided StringBuilder.
|
default String |
asString(long value)
Converts the given long value to a string.
|
default CharSequence |
asText(int value)
Converts the provided integer value to a CharSequence representation.
|
default CharSequence |
asText(long value)
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 text)
Checks that the length of the provided text does not exceed the allowable maximum.
|
default void |
lengthCheck(CharSequence text,
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 text)
Parses the provided
CharSequence and returns the parsed results as a
long primitive. |
default long |
parse(CharSequence text,
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 text)
CharSequence and returns the parsed results as a
long primitive.text as an long primitive.IllegalArgumentException - if the text length is outside of range accepted by a specific converter.default long parse(CharSequence text, 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.
text - character sequence containing the string representation of the value.beginIndex - the beginning index, inclusive.endIndex - the ending index, exclusive.text as an long primitive.IllegalArgumentException - if any of the indices are invalid or the sub-sequence length is
outside of range accepted by a specific converter.void append(StringBuilder text, long value)
text - The StringBuilder to which the converted value is appended.value - The long value to convert.default void append(net.openhft.chronicle.bytes.Bytes<?> bytes,
long value)
bytes - The Bytes object to which the converted value is appended.value - The long value to convert.default String asString(long value)
value - The long value to convert.default CharSequence asText(int value)
value - The integer value to convert.default CharSequence asText(long value)
value - The long value to convert.default int maxParseLength()
default void lengthCheck(CharSequence text)
text - The text to check.IllegalArgumentException - if the text length exceeds the maximum allowable length.default void lengthCheck(CharSequence text, int beginIndex, int endIndex)
text - The text to check.beginIndex - the beginning index, inclusive.endIndex - the ending index, exclusive.IllegalArgumentException - if the text length exceeds the maximum allowable length.@Deprecated default boolean allSafeChars(WireOut wireOut)
WireOut object are "safe",
meaning they don't require additional quoting or escaping, especially in contexts
like YAML serialization.wireOut - The WireOut instance to check.true if no characters need escaping or additional quoting for YAML, false otherwise.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 © 2024. All rights reserved.