|
Préférences
Moteurs de recherche
|
||||||||||||||||||||||||
| JavaTM 2 Platform Std. Ed. v1.4.2
java.text
|
|||||||||||||||||||||||||
| Nested Class Summary | |
static class |
Format.Field
Defines constants that are used as attribute keys in the AttributedCharacterIterator returned
from Format.formatToCharacterIterator and as
field identifiers in FieldPosition. |
| Constructor Summary | |
Format()
|
|
| Method Summary | |
Object |
clone()
Creates and returns a copy of this object. |
String |
format(Object obj)
Formats an object to produce a string. |
abstract StringBuffer |
format(Object obj,
StringBuffer toAppendTo,
FieldPosition pos)
Formats an object and appends the resulting text to a given string buffer. |
AttributedCharacterIterator |
formatToCharacterIterator(Object obj)
Formats an Object producing an AttributedCharacterIterator. |
Object |
parseObject(String source)
Parses text from the beginning of the given string to produce an object. |
abstract Object |
parseObject(String source,
ParsePosition pos)
Parses text from a string to produce an object. |
| Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public Format()
| Method Detail |
public final String format(Object obj)
format(obj, new StringBuffer(), new FieldPosition(0)).toString();
obj - The object to format
IllegalArgumentException - if the Format cannot format the given
objectpublic abstract StringBuffer format(Object obj, StringBuffer toAppendTo, FieldPosition pos)
pos argument identifies a field used by the format,
then its indices are set to the beginning and end of the first such
field encountered.
obj - The object to formattoAppendTo - where the text is to be appendedpos - A FieldPosition identifying a field
in the formatted text
toAppendTo,
with formatted text appended
NullPointerException - if toAppendTo or
pos is null
IllegalArgumentException - if the Format cannot format the given
objectpublic AttributedCharacterIterator formatToCharacterIterator(Object obj)
AttributedCharacterIterator.
You can use the returned AttributedCharacterIterator
to build the resulting String, as well as to determine information
about the resulting String.
Each attribute key of the AttributedCharacterIterator will be of type
Field. It is up to each Format implementation
to define what the legal values are for each attribute in the
AttributedCharacterIterator, but typically the attribute
key is also used as the attribute value.
The default implementation creates an
AttributedCharacterIterator with no attributes. Subclasses
that support fields should override this and create an
AttributedCharacterIterator with meaningful attributes.
obj - The object to format
NullPointerException - if obj is null.
IllegalArgumentException - when the Format cannot format the
given object.public abstract Object parseObject(String source, ParsePosition pos)
The method attempts to parse text starting at the index given by
pos.
If parsing succeeds, then the index of pos is updated
to the index after the last character used (parsing does not necessarily
use all characters up to the end of the string), and the parsed
object is returned. The updated pos can be used to
indicate the starting point for the next call to this method.
If an error occurs, then the index of pos is not
changed, the error index of pos is set to the index of
the character where the error occurred, and null is returned.
source - A String, part of which should be parsed.pos - A ParsePosition object with index and error
index information as described above.
Object parsed from the string. In case of
error, returns null.
NullPointerException - if pos is null.public Object parseObject(String source) throws ParseException
source - A String whose beginning should be parsed.
Object parsed from the string.
ParseException - if the beginning of the specified string
cannot be parsed.public Object clone()
Cloneable