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

public Class CompositeFormat

extends Format
Class Inheritance
Annotations
@Deprecated
Imports
java.text.FieldPosition, .Format, .ParseException, .ParsePosition

Deprecated

As of 3.6, use Apache Commons Text CompositeFormat.

Formats using one formatter and parses using a different formatter. An example of use for this would be a webapp where data is taken in one way and stored in a database another way.

Field Summary

Modifier and TypeField and Description
private final Format
formatter

The formatter to use.

private final Format
parser

The parser to use.

private static final long
serialVersionUID

Hides java.text.Format.serialVersionUID.

Required for serialization support.

Constructor Summary

AccessConstructor and Description
public
CompositeFormat(final Format
implementation
parser
,
final Format
implementation
formatter
)

Create a format that points its parseObject method to one implementation and its format method to another.

Method Summary

Modifier and TypeMethod and Description
public StringBuffer

Returns:

toAppendTo
format
(final Object
the object to format
obj
,
final StringBuffer
the StringBuffer to append to
toAppendTo
,
final FieldPosition
the FieldPosition to use (or ignore).
pos
)

Implements abstract java.text.Format.format.

Uses the formatter Format instance.

public Format

Returns:

formatter Format implementation
getFormatter
()

Provides access to the parser Format implementation.

public Format

Returns:

parser Format implementation
getParser
()

Provides access to the parser Format implementation.

public Object

Returns:

the parsed Object
parseObject
(final String
the String source
source
,
final ParsePosition
the ParsePosition containing the position to parse from, will be updated according to parsing success (index) or failure (error index)
pos
)

Implements abstract java.text.Format.parseObject.

Uses the parser Format instance.

public String

Returns:

A reformatted String
reformat
(final String
String to reformat
input
)

Utility method to parse and then reformat a String.

Inherited from java.text.Format:
cloneformatformatToCharacterIteratorparseObject

Field Detail

formatterback to summary
private final Format formatter

The formatter to use.

parserback to summary
private final Format parser

The parser to use.

serialVersionUIDback to summary
private static final long serialVersionUID

Hides java.text.Format.serialVersionUID.

Required for serialization support.

See Also
java.io.Serializable

Constructor Detail

CompositeFormatback to summary
public CompositeFormat(final Format parser, final Format formatter)

Create a format that points its parseObject method to one implementation and its format method to another.

Parameters
parser:Format

implementation

formatter:Format

implementation

Method Detail

formatback to summary
public StringBuffer format(final Object obj, final StringBuffer toAppendTo, final FieldPosition pos)

Implements abstract java.text.Format.format.

Uses the formatter Format instance.

Parameters
obj:Object

the object to format

toAppendTo:StringBuffer

the StringBuffer to append to

pos:FieldPosition

the FieldPosition to use (or ignore).

Returns:StringBuffer

toAppendTo

Annotations
@Override
See Also
Format#format(Object, StringBuffer, FieldPosition)
getFormatterback to summary
public Format getFormatter()

Provides access to the parser Format implementation.

Returns:Format

formatter Format implementation

getParserback to summary
public Format getParser()

Provides access to the parser Format implementation.

Returns:Format

parser Format implementation

parseObjectback to summary
public Object parseObject(final String source, final ParsePosition pos)

Implements abstract java.text.Format.parseObject.

Uses the parser Format instance.

Parameters
source:String

the String source

pos:ParsePosition

the ParsePosition containing the position to parse from, will be updated according to parsing success (index) or failure (error index)

Returns:Object

the parsed Object

Annotations
@Override
See Also
Format#parseObject(String, ParsePosition)
reformatback to summary
public String reformat(final String input) throws ParseException

Utility method to parse and then reformat a String.

Parameters
input:String

String to reformat

Returns:String

A reformatted String

Exceptions
ParseException:
thrown by parseObject(String) call