public class CompositeFormat extends Format
Format.Field
Constructor and Description |
---|
CompositeFormat(Format parser,
Format formatter)
Create 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)
Uses the formatter Format instance.
|
Format |
getFormatter()
Provides access to the parser Format implementation.
|
Format |
getParser()
Provides access to the parser Format implementation.
|
Object |
parseObject(String source,
ParsePosition pos)
Uses the parser Format instance.
|
String |
reformat(String input)
Utility method to parse and then reformat 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 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 Format getParser()
public Format getFormatter()
public String reformat(String input) throws ParseException
input
- String to reformatParseException
- thrown by parseObject(String) callCopyright © 2014–2017 The Apache Software Foundation. All rights reserved.