Top Description Fields Constructors Methods
org.apache.commons.lang3.text

public Class FormattableUtils

extends Object
Class Inheritance
Annotations
@Deprecated
Imports
java.util.Formattable, .FormattableFlags, .Formatter, org.apache.commons.lang3.ObjectUtils, .StringUtils, .Validate

Deprecated

As of 3.6, use Apache Commons Text FormattableUtils.

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 generalized alternate formats.

Since
3.0

Field Summary

Modifier and TypeField and Description
private static final String
SIMPLEST_FORMAT

A format that simply outputs the value as a string.

Constructor Summary

AccessConstructor and Description
public
FormattableUtils()

FormattableUtils instances should NOT be constructed in standard programming.

Method Summary

Modifier and TypeMethod and Description
public static Formatter

Returns:

the formatter instance, not null.
append
(final CharSequence
the string to handle, not null.
seq
,
final Formatter
the destination formatter, not null.
formatter
,
final int
the flags for formatting, see Formattable.
flags
,
final int
the width of the output, see Formattable.
width
,
final int
the precision of the output, see Formattable.
precision
)

Handles the common Formattable operations of truncate-pad-append, with no ellipsis on precision overflow, and padding width underflow with spaces.

public static Formatter

Returns:

the formatter instance, not null.
append
(final CharSequence
the string to handle, not null.
seq
,
final Formatter
the destination formatter, not null.
formatter
,
final int
the flags for formatting, see Formattable.
flags
,
final int
the width of the output, see Formattable.
width
,
final int
the precision of the output, see Formattable.
precision
,
final char
the pad character to use.
padChar
)

Handles the common Formattable operations of truncate-pad-append, with no ellipsis on precision overflow.

public static Formatter

Returns:

the formatter instance, not null.
append
(final CharSequence
the string to handle, not null.
seq
,
final Formatter
the destination formatter, not null.
formatter
,
final int
the flags for formatting, see Formattable.
flags
,
final int
the width of the output, see Formattable.
width
,
final int
the precision of the output, see Formattable.
precision
,
final char
the pad character to use.
padChar
,
final CharSequence
the ellipsis to use when precision dictates truncation, null or empty causes a hard truncation.
ellipsis
)

Handles the common Formattable operations of truncate-pad-append.

public static Formatter

Returns:

the formatter instance, not null.
append
(final CharSequence
the string to handle, not null
seq
,
final Formatter
the destination formatter, not null.
formatter
,
final int
the flags for formatting, see Formattable.
flags
,
final int
the width of the output, see Formattable.
width
,
final int
the precision of the output, see Formattable.
precision
,
final CharSequence
the ellipsis to use when precision dictates truncation, null or empty causes a hard truncation.
ellipsis
)

Handles the common Formattable operations of truncate-pad-append, padding width underflow with spaces.

public static String

Returns:

the resulting string, not null.
toString
(final Formattable
the instance to convert to a string, not null.
formattable
)

Gets the default formatted representation of the specified Formattable.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

SIMPLEST_FORMATback to summary
private static final String SIMPLEST_FORMAT

A format that simply outputs the value as a string.

Constructor Detail

FormattableUtilsback to summary
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.

Method Detail

appendback to summary
public static Formatter append(final CharSequence seq, final Formatter formatter, final int flags, final int width, final int precision)

Handles the common Formattable operations of truncate-pad-append, with no ellipsis on precision overflow, and padding width underflow with spaces.

Parameters
seq:CharSequence

the string to handle, not null.

formatter:Formatter

the destination formatter, not null.

flags:int

the flags for formatting, see Formattable.

width:int

the width of the output, see Formattable.

precision:int

the precision of the output, see Formattable.

Returns:Formatter

the formatter instance, not null.

appendback to summary
public static Formatter append(final CharSequence seq, final Formatter formatter, final int flags, final int width, final int precision, final char padChar)

Handles the common Formattable operations of truncate-pad-append, with no ellipsis on precision overflow.

Parameters
seq:CharSequence

the string to handle, not null.

formatter:Formatter

the destination formatter, not null.

flags:int

the flags for formatting, see Formattable.

width:int

the width of the output, see Formattable.

precision:int

the precision of the output, see Formattable.

padChar:char

the pad character to use.

Returns:Formatter

the formatter instance, not null.

appendback to summary
public static Formatter append(final CharSequence seq, final Formatter formatter, final int flags, final int width, final int precision, final char padChar, final CharSequence ellipsis)

Handles the common Formattable operations of truncate-pad-append.

Parameters
seq:CharSequence

the string to handle, not null.

formatter:Formatter

the destination formatter, not null.

flags:int

the flags for formatting, see Formattable.

width:int

the width of the output, see Formattable.

precision:int

the precision of the output, see Formattable.

padChar:char

the pad character to use.

ellipsis:CharSequence

the ellipsis to use when precision dictates truncation, null or empty causes a hard truncation.

Returns:Formatter

the formatter instance, not null.

appendback to summary
public static Formatter append(final CharSequence seq, final Formatter formatter, final int flags, final int width, final int precision, final CharSequence ellipsis)

Handles the common Formattable operations of truncate-pad-append, padding width underflow with spaces.

Parameters
seq:CharSequence

the string to handle, not null

formatter:Formatter

the destination formatter, not null.

flags:int

the flags for formatting, see Formattable.

width:int

the width of the output, see Formattable.

precision:int

the precision of the output, see Formattable.

ellipsis:CharSequence

the ellipsis to use when precision dictates truncation, null or empty causes a hard truncation.

Returns:Formatter

the formatter instance, not null.

toStringback to summary
public static String toString(final Formattable formattable)

Gets the default formatted representation of the specified Formattable.

Parameters
formattable:Formattable

the instance to convert to a string, not null.

Returns:String

the resulting string, not null.