public class CompositeFormat extends Format
Format.Field
Constructor and Description |
---|
CompositeFormat(Format parser,
Format formatter)
Constructs a format that points its parseObject method to one implementation
and its format method to another.
|
Modifier and Type | Method and Description |
---|---|
StringBuffer |
format(Object obj,
StringBuffer toAppendTo,
FieldPosition pos)
Formats the input.
|
Format |
getFormatter()
Gets the parser Format implementation.
|
Format |
getParser()
Gets the parser Format implementation.
|
Object |
parseObject(String source,
ParsePosition pos)
Parses the input.
|
String |
reformat(String input)
Parses and then reformats a String.
|
clone, format, formatToCharacterIterator, parseObject
public CompositeFormat(Format parser, Format formatter)
parser
- implementationformatter
- implementationpublic StringBuffer format(Object obj, StringBuffer toAppendTo, FieldPosition pos)
format
in class Format
obj
- the object to formattoAppendTo
- the StringBuffer
to append topos
- the FieldPosition to use (or ignore).toAppendTo
Format.format(Object, StringBuffer, FieldPosition)
public Format getFormatter()
public Format getParser()
public Object parseObject(String source, ParsePosition pos)
parseObject
in class Format
source
- the String sourcepos
- the ParsePosition containing the position to parse from, will
be updated according to parsing success (index) or failure
(error index)Format.parseObject(String, ParsePosition)
public String reformat(String input) throws ParseException
input
- String to reformatParseException
- thrown by parseObject(String) callCopyright © 2014–2022 The Apache Software Foundation. All rights reserved.