public class IntOutput extends Object
| Modifier and Type | Field and Description |
|---|---|
static char[] |
digits |
static char[] |
digitsHex |
static char[] |
digitsHexLC |
static String |
MIN_INTEGER_STRING |
static String |
MIN_LONG_STRING |
static char[] |
tensDigits |
| Constructor and Description |
|---|
IntOutput() |
| Modifier and Type | Method and Description |
|---|---|
static void |
append1Hex(Appendable a,
int i)
Append an
int to an Appendable as a single hexadecimal digit. |
static void |
append1HexLC(Appendable a,
int i)
Append an
int to an Appendable as a single hexadecimal digit, using lower-case for the alphabetic
characters. |
static void |
append2Digits(Appendable a,
int i)
Append an
int to an Appendable as two decimal digits. |
static void |
append2Hex(Appendable a,
int i)
Append an
int to an Appendable as two hexadecimal digits. |
static void |
append2HexLC(Appendable a,
int i)
Append an
int to an Appendable as two hexadecimal digits, using lower-case for the alphabetic
characters. |
static void |
append3Digits(Appendable a,
int i)
Append an
int to an Appendable as three decimal digits. |
static void |
append4Hex(Appendable a,
int i)
Append an
int to an Appendable as four hexadecimal digits. |
static void |
append4HexLC(Appendable a,
int i)
Append an
int to an Appendable as four hexadecimal digits, using lower-case for the alphabetic
characters. |
static void |
append8Hex(Appendable a,
int i)
Append an
int to an Appendable as eight hexadecimal digits. |
static void |
append8HexLC(Appendable a,
int i)
Append an
int to an Appendable as eight hexadecimal digits, using lower-case for the alphabetic
characters. |
static void |
appendInt(Appendable a,
int i)
Append an
int left-trimmed to an Appendable. |
static void |
appendIntGrouped(Appendable a,
int i,
char groupingChar)
Append an
int left-trimmed to an Appendable with digits grouped in 3s and separated by the
specified grouping character. |
static void |
appendIntHex(Appendable a,
int i)
Append an
int left-trimmed to an Appendable in hexadecimal. |
static void |
appendIntHexLC(Appendable a,
int i)
Append an
int left-trimmed to an Appendable in hexadecimal, using lower-case for the alphabetic
characters. |
static void |
appendLong(Appendable a,
long n)
Append a
long left-trimmed to an Appendable. |
static void |
appendLongGrouped(Appendable a,
long n,
char groupingChar)
Append a
long left-trimmed to an Appendable with digits grouped in 3s and separated by the
specified grouping character. |
static void |
appendLongHex(Appendable a,
long n)
Append a
long left-trimmed to an Appendable in hexadecimal. |
static void |
appendLongHexLC(Appendable a,
long n)
Append a
long left-trimmed to an Appendable in hexadecimal, using lower-case for the alphabetic
characters. |
static void |
appendPositiveInt(Appendable a,
int i)
Append a positive
int left-trimmed to an Appendable. |
static void |
appendPositiveIntGrouped(Appendable a,
int i,
char groupingChar)
Append a positive
int left-trimmed to an Appendable with digits grouped in 3s and separated by
the specified grouping character. |
static void |
appendPositiveLong(Appendable a,
long n)
Append a positive
long left-trimmed to an Appendable. |
static void |
appendPositiveLongGrouped(Appendable a,
long n,
char groupingChar)
Append a positive
long left-trimmed to an Appendable with digits grouped in 3s and separated by
the specified grouping character. |
static void |
appendUnsignedInt(Appendable a,
int i)
Append an unsigned
int left-trimmed to an Appendable. |
static void |
appendUnsignedLong(Appendable a,
long n)
Append an unsigned
long left-trimmed to an Appendable. |
static void |
output1Hex(int i,
IntConsumer consumer)
Append an
int to an Appendable as a single hexadecimal digit. |
static void |
output1HexLC(int i,
IntConsumer consumer)
Append an
int to an Appendable as a single hexadecimal digit, using lower-case for the alphabetic
characters. |
static void |
output2Digits(int i,
IntConsumer consumer)
Output an
int using an IntConsumer as two decimal digits. |
static void |
output2Hex(int i,
IntConsumer consumer)
Output an
int using an IntConsumer as two hexadecimal digits. |
static void |
output2HexLC(int i,
IntConsumer consumer)
Output an
int using an IntConsumer as two hexadecimal digits, using lower-case for the alphabetic
characters. |
static void |
output3Digits(int i,
IntConsumer consumer)
Output an
int using an IntConsumer as three decimal digits. |
static void |
output4Hex(int i,
IntConsumer consumer)
Output an
int using an IntConsumer as four hexadecimal digits. |
static void |
output4HexLC(int i,
IntConsumer consumer)
Output an
int using an IntConsumer as four hexadecimal digits, using lower-case for the
alphabetic characters. |
static void |
output8Hex(int i,
IntConsumer consumer)
Append an
int to an Appendable as eight hexadecimal digits. |
static void |
output8HexLC(int i,
IntConsumer consumer)
Append an
int to an Appendable as eight hexadecimal digits, using lower-case for the alphabetic
characters. |
static void |
outputInt(int i,
IntConsumer consumer)
Output an
int left-trimmed using an IntConsumer. |
static void |
outputIntGrouped(int i,
char groupingChar,
IntConsumer consumer)
Output an
int left-trimmed using an IntConsumer with digits grouped in 3s and separated by the
specified grouping character. |
static void |
outputIntHex(int i,
IntConsumer consumer)
Output an
int left-trimmed using an IntConsumer in hexadecimal. |
static void |
outputIntHexLC(int i,
IntConsumer consumer)
Output an
int left-trimmed using an IntConsumer in hexadecimal, using lower-case for the
alphabetic characters. |
static void |
outputLong(long n,
IntConsumer consumer)
Output a
long left-trimmed using an IntConsumer. |
static void |
outputLongGrouped(long n,
char groupingChar,
IntConsumer consumer)
Output a
long left-trimmed using an IntConsumer with digits grouped in 3s and separated by the
specified grouping character. |
static void |
outputLongHex(long n,
IntConsumer consumer)
Append a
long left-trimmed to an Appendable in hexadecimal. |
static void |
outputLongHexLC(long n,
IntConsumer consumer)
Append a
long left-trimmed to an Appendable in hexadecimal, using lower-case for the alphabetic
characters. |
static void |
outputPositiveInt(int i,
IntConsumer consumer)
Output a positive
int left-trimmed using an IntConsumer. |
static void |
outputPositiveIntGrouped(int i,
char groupingChar,
IntConsumer consumer)
Output a positive
int left-trimmed using an IntConsumer with digits grouped in 3s and separated
by the specified grouping character. |
static void |
outputPositiveLong(long n,
IntConsumer consumer)
Output a positive
int left-trimmed using an IntConsumer. |
static void |
outputPositiveLongGrouped(long n,
char groupingChar,
IntConsumer consumer)
Output a positive
long left-trimmed using an IntConsumer with digits grouped in 3s and separated
by the specified grouping character. |
static void |
outputUnsignedInt(int i,
IntConsumer consumer)
Output an unsigned
int left-trimmed using an IntConsumer. |
static void |
outputUnsignedLong(long n,
IntConsumer consumer)
Output an unsigned
long left-trimmed using an IntConsumer. |
public static final char[] digits
public static final char[] tensDigits
public static final char[] digitsHex
public static final char[] digitsHexLC
public static final String MIN_INTEGER_STRING
public static final String MIN_LONG_STRING
public static void appendInt(Appendable a, int i) throws IOException
int left-trimmed to an Appendable. This method outputs the digits left to right,
avoiding the need to allocate a separate object to hold the string form.a - the Appendablei - the intIOException - if thrown by the Appendablepublic static void appendPositiveInt(Appendable a, int i) throws IOException
int left-trimmed to an Appendable. This method outputs the digits left to
right, avoiding the need to allocate a separate object to hold the string form.a - the Appendablei - the intIOException - if thrown by the Appendablepublic static void appendUnsignedInt(Appendable a, int i) throws IOException
int left-trimmed to an Appendable. This method outputs the digits left to
right, avoiding the need to allocate a separate object to hold the string form.a - the Appendablei - the intIOException - if thrown by the Appendablepublic static void appendLong(Appendable a, long n) throws IOException
long left-trimmed to an Appendable. This method outputs the digits left to right,
avoiding the need to allocate a separate object to hold the string form.a - the Appendablen - the longIOException - if thrown by the Appendablepublic static void appendPositiveLong(Appendable a, long n) throws IOException
long left-trimmed to an Appendable. This method outputs the digits left to
right, avoiding the need to allocate a separate object to hold the string form.a - the Appendablen - the longIOException - if thrown by the Appendablepublic static void appendUnsignedLong(Appendable a, long n) throws IOException
long left-trimmed to an Appendable. This method outputs the digits left to
right, avoiding the need to allocate a separate object to hold the string form.a - the Appendablen - the longIOException - if thrown by the Appendablepublic static void append2Digits(Appendable a, int i) throws IOException
int to an Appendable as two decimal digits. There is often a requirement to output a
number as 2 digits, for example the cents value in dollars and cents, or hours, minutes and seconds in a time
string. Note that there is no range check on the input value; to use this method in cases where the value is not
guaranteed to be in the range 00-99, use:
IntOutput.append2Digits(a, Math.abs(i) % 100);
a - the Appendablei - the intIOException - if thrown by the Appendablepublic static void append3Digits(Appendable a, int i) throws IOException
int to an Appendable as three decimal digits. There is less frequently a requirement
to output a number as 3 digits, for example the milliseconds in a time string. Note that there is no range check
on the input value; to use this method in cases where the value is not guaranteed to be in the range 000-999,
use:
IntOutput.append3Digits(a, Math.abs(i) % 1000);
a - the Appendablei - the intIOException - if thrown by the Appendablepublic static void appendIntGrouped(Appendable a, int i, char groupingChar) throws IOException
int left-trimmed to an Appendable with digits grouped in 3s and separated by the
specified grouping character.a - the Appendablei - the intgroupingChar - the grouping character (e.g. ',')IOException - if thrown by the Appendablepublic static void appendPositiveIntGrouped(Appendable a, int i, char groupingChar) throws IOException
int left-trimmed to an Appendable with digits grouped in 3s and separated by
the specified grouping character.a - the Appendablei - the intgroupingChar - the grouping character (e.g. ',')IOException - if thrown by the Appendablepublic static void appendLongGrouped(Appendable a, long n, char groupingChar) throws IOException
long left-trimmed to an Appendable with digits grouped in 3s and separated by the
specified grouping character.a - the Appendablen - the longgroupingChar - the grouping character (e.g. ',')IOException - if thrown by the Appendablepublic static void appendPositiveLongGrouped(Appendable a, long n, char groupingChar) throws IOException
long left-trimmed to an Appendable with digits grouped in 3s and separated by
the specified grouping character.a - the Appendablen - the longgroupingChar - the grouping character (e.g. ',')IOException - if thrown by the Appendablepublic static void appendIntHex(Appendable a, int i) throws IOException
int left-trimmed to an Appendable in hexadecimal. This method outputs the digits left
to right, avoiding the need to allocate a separate object to hold the string form.a - the Appendablei - the intIOException - if thrown by the Appendablepublic static void appendIntHexLC(Appendable a, int i) throws IOException
int left-trimmed to an Appendable in hexadecimal, using lower-case for the alphabetic
characters. This method outputs the digits left to right, avoiding the need to allocate a separate object to
hold the string form.a - the Appendablei - the intIOException - if thrown by the Appendablepublic static void appendLongHex(Appendable a, long n) throws IOException
long left-trimmed to an Appendable in hexadecimal. This method outputs the digits left
to right, avoiding the need to allocate a separate object to hold the string form.a - the Appendablen - the longIOException - if thrown by the Appendablepublic static void appendLongHexLC(Appendable a, long n) throws IOException
long left-trimmed to an Appendable in hexadecimal, using lower-case for the alphabetic
characters. This method outputs the digits left to right, avoiding the need to allocate a separate object to
hold the string form.a - the Appendablen - the longIOException - if thrown by the Appendablepublic static void append8Hex(Appendable a, int i) throws IOException
int to an Appendable as eight hexadecimal digits.a - the Appendablei - the intIOException - if thrown by the Appendablepublic static void append8HexLC(Appendable a, int i) throws IOException
int to an Appendable as eight hexadecimal digits, using lower-case for the alphabetic
characters.a - the Appendablei - the intIOException - if thrown by the Appendablepublic static void append4Hex(Appendable a, int i) throws IOException
int to an Appendable as four hexadecimal digits.a - the Appendablei - the intIOException - if thrown by the Appendablepublic static void append4HexLC(Appendable a, int i) throws IOException
int to an Appendable as four hexadecimal digits, using lower-case for the alphabetic
characters.a - the Appendablei - the intIOException - if thrown by the Appendablepublic static void append2Hex(Appendable a, int i) throws IOException
int to an Appendable as two hexadecimal digits.a - the Appendablei - the intIOException - if thrown by the Appendablepublic static void append2HexLC(Appendable a, int i) throws IOException
int to an Appendable as two hexadecimal digits, using lower-case for the alphabetic
characters.a - the Appendablei - the intIOException - if thrown by the Appendablepublic static void append1Hex(Appendable a, int i) throws IOException
int to an Appendable as a single hexadecimal digit.a - the Appendablei - the intIOException - if thrown by the Appendablepublic static void append1HexLC(Appendable a, int i) throws IOException
int to an Appendable as a single hexadecimal digit, using lower-case for the alphabetic
characters.a - the Appendablei - the intIOException - if thrown by the Appendablepublic static void outputInt(int i,
IntConsumer consumer)
int left-trimmed using an IntConsumer. This method outputs the digits left to right,
avoiding the need to allocate a separate object to hold the string form.i - the intconsumer - the IntConsumerpublic static void outputPositiveInt(int i,
IntConsumer consumer)
int left-trimmed using an IntConsumer. This method outputs the digits left to
right, avoiding the need to allocate a separate object to hold the string form.i - the intconsumer - the IntConsumerpublic static void outputUnsignedInt(int i,
IntConsumer consumer)
int left-trimmed using an IntConsumer. This method outputs the digits left to
right, avoiding the need to allocate a separate object to hold the string form.i - the intconsumer - the IntConsumerpublic static void outputLong(long n,
IntConsumer consumer)
long left-trimmed using an IntConsumer. This method outputs the digits left to right,
avoiding the need to allocate a separate object to hold the string form.n - the intconsumer - the IntConsumerpublic static void outputPositiveLong(long n,
IntConsumer consumer)
int left-trimmed using an IntConsumer. This method outputs the digits left to
right, avoiding the need to allocate a separate object to hold the string form.n - the longconsumer - the IntConsumerpublic static void outputUnsignedLong(long n,
IntConsumer consumer)
long left-trimmed using an IntConsumer. This method outputs the digits left
to right, avoiding the need to allocate a separate object to hold the string form.n - the longconsumer - the IntConsumerpublic static void output2Digits(int i,
IntConsumer consumer)
int using an IntConsumer as two decimal digits. There is often a requirement to output
a number as 2 digits, for example the cents value in dollars and cents, or hours, minutes and seconds in a time
string. Note that there is no range check on the input value; to use this method in cases where the value is not
guaranteed to be in the range 00-99, use:
IntOutput.output2Digits(Math.abs(i) % 100, ch -> sb.append((char)ch));
i - the intconsumer - the IntConsumerpublic static void output3Digits(int i,
IntConsumer consumer)
int using an IntConsumer as three decimal digits. There is less frequently a
requirement to output a number as 3 digits, for example the milliseconds in a time string. Note that there is no
range check on the input value; to use this method in cases where the value is not guaranteed to be in the range
000-999, use:
IntOutput.output3Digits(Math.abs(i) % 1000, ch -> sb.append((char)ch));
i - the intconsumer - the IntConsumerpublic static void outputIntGrouped(int i,
char groupingChar,
IntConsumer consumer)
int left-trimmed using an IntConsumer with digits grouped in 3s and separated by the
specified grouping character.i - the intgroupingChar - the grouping character (e.g. ',')consumer - the IntConsumerpublic static void outputPositiveIntGrouped(int i,
char groupingChar,
IntConsumer consumer)
int left-trimmed using an IntConsumer with digits grouped in 3s and separated
by the specified grouping character.i - the intgroupingChar - the grouping character (e.g. ',')consumer - the IntConsumerpublic static void outputLongGrouped(long n,
char groupingChar,
IntConsumer consumer)
long left-trimmed using an IntConsumer with digits grouped in 3s and separated by the
specified grouping character.n - the longgroupingChar - the grouping character (e.g. ',')consumer - the IntConsumerpublic static void outputPositiveLongGrouped(long n,
char groupingChar,
IntConsumer consumer)
long left-trimmed using an IntConsumer with digits grouped in 3s and separated
by the specified grouping character.n - the longgroupingChar - the grouping character (e.g. ',')consumer - the IntConsumerpublic static void outputIntHex(int i,
IntConsumer consumer)
int left-trimmed using an IntConsumer in hexadecimal. This method outputs the digits
left to right, avoiding the need to allocate a separate object to hold the string form.i - the intconsumer - the IntConsumerpublic static void outputIntHexLC(int i,
IntConsumer consumer)
int left-trimmed using an IntConsumer in hexadecimal, using lower-case for the
alphabetic characters. This method outputs the digits
left to right, avoiding the need to allocate a separate object to hold the string form.i - the intconsumer - the IntConsumerpublic static void outputLongHex(long n,
IntConsumer consumer)
long left-trimmed to an Appendable in hexadecimal. This method outputs the digits left
to right, avoiding the need to allocate a separate object to hold the string form.n - the longconsumer - the IntConsumerpublic static void outputLongHexLC(long n,
IntConsumer consumer)
long left-trimmed to an Appendable in hexadecimal, using lower-case for the alphabetic
characters. This method outputs the digits left to right, avoiding the need to allocate a separate object to
hold the string form.n - the longconsumer - the IntConsumerpublic static void output8Hex(int i,
IntConsumer consumer)
int to an Appendable as eight hexadecimal digits.i - the intconsumer - the IntConsumerpublic static void output8HexLC(int i,
IntConsumer consumer)
int to an Appendable as eight hexadecimal digits, using lower-case for the alphabetic
characters.i - the intconsumer - the IntConsumerpublic static void output4Hex(int i,
IntConsumer consumer)
int using an IntConsumer as four hexadecimal digits.i - the intconsumer - the IntConsumerpublic static void output4HexLC(int i,
IntConsumer consumer)
int using an IntConsumer as four hexadecimal digits, using lower-case for the
alphabetic characters.i - the intconsumer - the IntConsumerpublic static void output2Hex(int i,
IntConsumer consumer)
int using an IntConsumer as two hexadecimal digits.i - the intconsumer - the IntConsumerpublic static void output2HexLC(int i,
IntConsumer consumer)
int using an IntConsumer as two hexadecimal digits, using lower-case for the alphabetic
characters.i - the intconsumer - the IntConsumerpublic static void output1Hex(int i,
IntConsumer consumer)
int to an Appendable as a single hexadecimal digit.i - the intconsumer - the IntConsumerpublic static void output1HexLC(int i,
IntConsumer consumer)
int to an Appendable as a single hexadecimal digit, using lower-case for the alphabetic
characters.i - the intconsumer - the IntConsumerCopyright © 2022. All rights reserved.