| java.lang.Object | ||
| ↳ | java.text.Format | |
| ↳ | java.text.MessageFormat | |
MessageFormat is used to format and parse arguments based on a pattern. The pattern specifies how each argument will be formatted and concatenated with other text to produce the formatted output.
| Nested Classes | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| MessageFormat.Field | The instances of this inner class are used as attribute keys in AttributedCharacterIterator that MessageFormat.formatToCharacterIterator() method returns. | ||||||||||
| Public Constructors | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
Constructs a new MessageFormat using the specified pattern and the
specified Locale for Formats.
| |||||||||||
Constructs a new MessageFormat using the specified pattern and the
default Locale for Formats.
| |||||||||||
| Public Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
Changes this MessageFormat to use the specified pattern.
| |||||||||||
Returns a new instance of MessageFormat with the same pattern and Formats
as this MessageFormat.
| |||||||||||
Compares the specified object to this MessageFormat and answer if they
are equal.
| |||||||||||
Formats the Object arguments using the specified MessageFormat pattern.
| |||||||||||
Formats the Object arguments into the specified StringBuffer using the
pattern of this MessageFormat.
| |||||||||||
Formats the specified object into the specified StringBuffer using the
pattern of this MessageFormat.
| |||||||||||
Formats the specified object using the rules of this MessageFormat and
returns an AttributedCharacterIterator with the formatted message and
attributes.
| |||||||||||
Returns the Formats of this MessageFormat.
| |||||||||||
Returns the formats used for each argument index.
| |||||||||||
Returns the Locale used when creating Formats.
| |||||||||||
Returns an integer hash code for the receiver.
| |||||||||||
Parse the message argument from the specified String starting at the
index specified by the ParsePosition.
| |||||||||||
Parse the message arguments from the specified String using the rules of
this MessageFormat.
| |||||||||||
Parse the message argument from the specified String starting at the
index specified by the ParsePosition.
| |||||||||||
Sets the specified Format used by this MessageFormat.
| |||||||||||
Sets the format used for argument at index
argIndexto
format | |||||||||||
Sets the Formats used by this MessageFormat.
| |||||||||||
Sets the formats used for each argument
The formats array
elements should be in the order of the argument indices. | |||||||||||
Sets the Locale to use when creating Formats.
| |||||||||||
Returns the pattern of this MessageFormat.
| |||||||||||
|
[Expand]
Inherited Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
From class java.text.Format
| |||||||||||
From class java.lang.Object
| |||||||||||
Constructs a new MessageFormat using the specified pattern and the specified Locale for Formats.
| template | the pattern |
|---|---|
| locale | the locale |
| IllegalArgumentException | when the pattern cannot be parsed |
|---|
Constructs a new MessageFormat using the specified pattern and the default Locale for Formats.
| template | the pattern |
|---|
| IllegalArgumentException | when the pattern cannot be parsed |
|---|
Changes this MessageFormat to use the specified pattern.
| template | the pattern |
|---|
| IllegalArgumentException | when the pattern cannot be parsed |
|---|
Returns a new instance of MessageFormat with the same pattern and Formats as this MessageFormat.
Compares the specified object to this MessageFormat and answer if they are equal. The object must be an instance of MessageFormat and have the same pattern.
| object | the object to compare with this object |
|---|
Formats the Object arguments using the specified MessageFormat pattern.
| template | the pattern |
|---|---|
| objects | the array of Objects to format |
| IllegalArgumentException | when the pattern cannot be parsed |
|---|
Formats the Object arguments into the specified StringBuffer using the pattern of this MessageFormat.
If Field Attribute of the FieldPosition supplied is MessageFormat.Field.ARGUMENT, then begin and end index of this field position is set to the location of the first occurrence of a message format argument. Otherwise the FieldPosition is ignored
| objects | the array of Objects to format |
|---|---|
| buffer | the StringBuffer |
| field | a FieldPosition. |
buffer
Formats the specified object into the specified StringBuffer using the pattern of this MessageFormat.
| object | the object to format, must be an array of Object |
|---|---|
| buffer | the StringBuffer |
| field | a FieldPosition which is ignored |
buffer| ClassCastException | when object is not an array of Object
|
|---|
Formats the specified object using the rules of this MessageFormat and returns an AttributedCharacterIterator with the formatted message and attributes. The AttributedCharacterIterator returned also includes the attributes from the formats of this MessageFormat.
| object | the object to format |
|---|
| IllegalArgumentException | when the arguments in the object array cannot be formatted by this Format |
|---|
Returns the Formats of this MessageFormat.
Returns the formats used for each argument index. If an argument is placed more than once in the pattern string, than returns the format of the last one.
Returns the Locale used when creating Formats.
Returns an integer hash code for the receiver. Objects which are equal answer the same value for this method.
Parse the message argument from the specified String starting at the index specified by the ParsePosition. If the string is successfully parsed, the index of the ParsePosition is updated to the index following the parsed text.
| string | the String to parse |
|---|---|
| position | the ParsePosition, updated on return with the index following the parsed text, or on error the index is unchanged and the error index is set to the index where the error occurred |
Parse the message arguments from the specified String using the rules of this MessageFormat.
| string | the String to parse |
|---|
| ParseException | when an error occurs during parsing |
|---|
Parse the message argument from the specified String starting at the index specified by the ParsePosition. If the string is successfully parsed, the index of the ParsePosition is updated to the index following the parsed text.
| string | the String to parse |
|---|---|
| position | the ParsePosition, updated on return with the index following the parsed text, or on error the index is unchanged and the error index is set to the index where the error occurred |
Sets the specified Format used by this MessageFormat.
| offset | the format to change |
|---|---|
| format | the Format |
Sets the format used for argument at index argIndexto
format
Sets the Formats used by this MessageFormat.
| formats | an array of Format |
|---|
Sets the formats used for each argument The formats array
elements should be in the order of the argument indices.
Sets the Locale to use when creating Formats.
| locale | the Locale |
|---|
Returns the pattern of this MessageFormat.