public class FormattableUtils
extends java.lang.Object
Provides utilities for working with the Formattable
interface.
The Formattable
interface provides basic control over formatting
when using a Formatter
. It is primarily concerned with numeric precision
and padding, and is not designed to allow generalised alternate formats.
Modifier and Type | Field and Description |
---|---|
private static java.lang.String |
SIMPLEST_FORMAT
A format that simply outputs the value as a string.
|
Constructor and Description |
---|
FormattableUtils()
FormattableUtils instances should NOT be constructed in
standard programming. |
Modifier and Type | Method and Description |
---|---|
static java.util.Formatter |
append(java.lang.CharSequence seq,
java.util.Formatter formatter,
int flags,
int width,
int precision)
Handles the common
Formattable operations of truncate-pad-append,
with no ellipsis on precision overflow, and padding width underflow with
spaces. |
static java.util.Formatter |
append(java.lang.CharSequence seq,
java.util.Formatter formatter,
int flags,
int width,
int precision,
char padChar)
Handles the common
Formattable operations of truncate-pad-append,
with no ellipsis on precision overflow. |
static java.util.Formatter |
append(java.lang.CharSequence seq,
java.util.Formatter formatter,
int flags,
int width,
int precision,
char padChar,
java.lang.CharSequence ellipsis)
Handles the common
Formattable operations of truncate-pad-append. |
static java.util.Formatter |
append(java.lang.CharSequence seq,
java.util.Formatter formatter,
int flags,
int width,
int precision,
java.lang.CharSequence ellipsis)
Handles the common
Formattable operations of truncate-pad-append,
padding width underflow with spaces. |
static java.lang.String |
toString(java.util.Formattable formattable)
Get the default formatted representation of the specified
Formattable . |
private static final java.lang.String SIMPLEST_FORMAT
public FormattableUtils()
FormattableUtils
instances should NOT be constructed in
standard programming. Instead, the methods of the class should be invoked
statically.
This constructor is public to permit tools that require a JavaBean instance to operate.
public static java.lang.String toString(java.util.Formattable formattable)
Formattable
.formattable
- the instance to convert to a string, not nullpublic static java.util.Formatter append(java.lang.CharSequence seq, java.util.Formatter formatter, int flags, int width, int precision)
Formattable
operations of truncate-pad-append,
with no ellipsis on precision overflow, and padding width underflow with
spaces.seq
- the string to handle, not nullformatter
- the destination formatter, not nullflags
- the flags for formatting, see Formattable
width
- the width of the output, see Formattable
precision
- the precision of the output, see Formattable
formatter
instance, not nullpublic static java.util.Formatter append(java.lang.CharSequence seq, java.util.Formatter formatter, int flags, int width, int precision, char padChar)
Formattable
operations of truncate-pad-append,
with no ellipsis on precision overflow.seq
- the string to handle, not nullformatter
- the destination formatter, not nullflags
- the flags for formatting, see Formattable
width
- the width of the output, see Formattable
precision
- the precision of the output, see Formattable
padChar
- the pad character to useformatter
instance, not nullpublic static java.util.Formatter append(java.lang.CharSequence seq, java.util.Formatter formatter, int flags, int width, int precision, java.lang.CharSequence ellipsis)
Formattable
operations of truncate-pad-append,
padding width underflow with spaces.seq
- the string to handle, not nullformatter
- the destination formatter, not nullflags
- the flags for formatting, see Formattable
width
- the width of the output, see Formattable
precision
- the precision of the output, see Formattable
ellipsis
- the ellipsis to use when precision dictates truncation, null or
empty causes a hard truncationformatter
instance, not nullpublic static java.util.Formatter append(java.lang.CharSequence seq, java.util.Formatter formatter, int flags, int width, int precision, char padChar, java.lang.CharSequence ellipsis)
Formattable
operations of truncate-pad-append.seq
- the string to handle, not nullformatter
- the destination formatter, not nullflags
- the flags for formatting, see Formattable
width
- the width of the output, see Formattable
precision
- the precision of the output, see Formattable
padChar
- the pad character to useellipsis
- the ellipsis to use when precision dictates truncation, null or
empty causes a hard truncationformatter
instance, not null