| java.lang.Object java.text.Format java.text.MessageFormat
MessageFormat | public class MessageFormat extends Format (Code) | | 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.
|
Constructor Summary | |
public | MessageFormat(String template, Locale locale) Constructs a new MessageFormat using the specified pattern and the
specified Locale for Formats. | public | MessageFormat(String template) Constructs a new MessageFormat using the specified pattern and the
default Locale for Formats. |
Method Summary | |
public void | applyPattern(String template) Changes this MessageFormat to use the specified pattern. | public Object | clone() Answers a new instance of MessageFormat with the same pattern and Formats
as this MessageFormat. | public boolean | equals(Object object) Compares the specified object to this MessageFormat and answer if they
are equal. | final public StringBuffer | format(Object[] objects, StringBuffer buffer, FieldPosition field) 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. | final public StringBuffer | format(Object object, StringBuffer buffer, FieldPosition field) Formats the specified object into the specified StringBuffer using the
pattern of this MessageFormat. | public static String | format(String template, Object... objects) Formats the Object arguments using the specified MessageFormat pattern. | public AttributedCharacterIterator | formatToCharacterIterator(Object object) Formats the specified object using the rules of this MessageFormat and
returns an AttributedCharacterIterator with the formatted message and
attributes. | public Format[] | getFormats() Answers the Formats of this MessageFormat. | public Format[] | getFormatsByArgumentIndex() Answers the formats used for each argument index. | public Locale | getLocale() Answers the Locale used when creating Formats. | public int | hashCode() Answers an integer hash code for the receiver. | public Object[] | parse(String string) Parse the message arguments from the specified String using the rules of
this MessageFormat. | public Object[] | parse(String string, ParsePosition position) Parse the message argument from the specified String starting at the
index specified by the ParsePosition. | public Object | parseObject(String string, ParsePosition position) Parse the message argument from the specified String starting at the
index specified by the ParsePosition. | public void | setFormat(int offset, Format format) Sets the specified Format used by this MessageFormat. | public void | setFormatByArgumentIndex(int argIndex, Format format) | public void | setFormats(Format[] formats) Sets the Formats used by this MessageFormat. | public void | setFormatsByArgumentIndex(Format[] formats) Sets the formats used for each argument The formats array
elements should be in the order of the argument indices. | public void | setLocale(Locale locale) Sets the Locale to use when creating Formats. | public String | toPattern() Answers the pattern of this MessageFormat. |
MessageFormat | public MessageFormat(String template, Locale locale)(Code) | | Constructs a new MessageFormat using the specified pattern and the
specified Locale for Formats.
Parameters: template - the pattern Parameters: locale - the locale exception: IllegalArgumentException - when the pattern cannot be parsed |
MessageFormat | public MessageFormat(String template)(Code) | | Constructs a new MessageFormat using the specified pattern and the
default Locale for Formats.
Parameters: template - the pattern exception: IllegalArgumentException - when the pattern cannot be parsed |
applyPattern | public void applyPattern(String template)(Code) | | Changes this MessageFormat to use the specified pattern.
Parameters: template - the pattern exception: IllegalArgumentException - when the pattern cannot be parsed |
clone | public Object clone()(Code) | | Answers a new instance of MessageFormat with the same pattern and Formats
as this MessageFormat.
a shallow copy of this MessageFormat See Also: java.lang.Cloneable |
equals | public boolean equals(Object object)(Code) | | 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.
Parameters: object - the object to compare with this object true if the specified object is equal to this MessageFormat,false otherwise See Also: MessageFormat.hashCode |
format | final public StringBuffer format(Object[] objects, StringBuffer buffer, FieldPosition field)(Code) | | 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
Parameters: objects - the array of Objects to format Parameters: buffer - the StringBuffer Parameters: field - a FieldPosition. the StringBuffer parameter buffer |
format | final public StringBuffer format(Object object, StringBuffer buffer, FieldPosition field)(Code) | | Formats the specified object into the specified StringBuffer using the
pattern of this MessageFormat.
Parameters: object - the object to format, must be an array of Object Parameters: buffer - the StringBuffer Parameters: field - a FieldPosition which is ignored the StringBuffer parameter buffer exception: ClassCastException - when object is not an array of Object |
format | public static String format(String template, Object... objects)(Code) | | Formats the Object arguments using the specified MessageFormat pattern.
Parameters: template - the pattern Parameters: objects - the array of Objects to format the formatted result exception: IllegalArgumentException - when the pattern cannot be parsed |
formatToCharacterIterator | public AttributedCharacterIterator formatToCharacterIterator(Object object)(Code) | | 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.
Parameters: object - the object to format an AttributedCharacterIterator with the formatted message andattributes exception: IllegalArgumentException - when the arguments in the object array cannot be formattedby this Format |
getFormats | public Format[] getFormats()(Code) | | Answers the Formats of this MessageFormat.
an array of Format |
getFormatsByArgumentIndex | public Format[] getFormatsByArgumentIndex()(Code) | | Answers 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.
an array of formats, ordered by argument index |
getLocale | public Locale getLocale()(Code) | | Answers the Locale used when creating Formats.
the Locale used to create Formats |
hashCode | public int hashCode()(Code) | | Answers an integer hash code for the receiver. Objects which are equal
answer the same value for this method.
the receiver's hash See Also: MessageFormat.equals |
parse | public Object[] parse(String string) throws ParseException(Code) | | Parse the message arguments from the specified String using the rules of
this MessageFormat.
Parameters: string - the String to parse the array of Object arguments resulting from the parse exception: ParseException - when an error occurs during parsing |
parse | public Object[] parse(String string, ParsePosition position)(Code) | | 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.
Parameters: string - the String to parse Parameters: position - the ParsePosition, updated on return with the index followingthe parsed text, or on error the index is unchanged and theerror index is set to the index where the error occurred the array of Object arguments resulting from the parse, or nullif there is an error |
parseObject | public Object parseObject(String string, ParsePosition position)(Code) | | 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.
Parameters: string - the String to parse Parameters: position - the ParsePosition, updated on return with the index followingthe parsed text, or on error the index is unchanged and theerror index is set to the index where the error occurred the array of Object arguments resulting from the parse, or nullif there is an error |
setFormat | public void setFormat(int offset, Format format)(Code) | | Sets the specified Format used by this MessageFormat.
Parameters: offset - the format to change Parameters: format - the Format |
setFormatByArgumentIndex | public void setFormatByArgumentIndex(int argIndex, Format format)(Code) | | Sets the format used for argument at index argIndex to
format
Parameters: argIndex - Parameters: format - |
setFormats | public void setFormats(Format[] formats)(Code) | | Sets the Formats used by this MessageFormat.
Parameters: formats - an array of Format |
setFormatsByArgumentIndex | public void setFormatsByArgumentIndex(Format[] formats)(Code) | | Sets the formats used for each argument The formats array
elements should be in the order of the argument indices.
Parameters: formats - |
setLocale | public void setLocale(Locale locale)(Code) | | Sets the Locale to use when creating Formats.
Parameters: locale - the Locale |
toPattern | public String toPattern()(Code) | | Answers the pattern of this MessageFormat.
the pattern |
Methods inherited from java.text.Format | public Object clone()(Code)(Java Doc) String convertPattern(String template, String fromChars, String toChars, boolean check)(Code)(Java Doc) final public String format(Object object)(Code)(Java Doc) abstract public StringBuffer format(Object object, StringBuffer buffer, FieldPosition field)(Code)(Java Doc) public AttributedCharacterIterator formatToCharacterIterator(Object object)(Code)(Java Doc) static Object getInternalField(String fieldName, Object target)(Code)(Java Doc) public Object parseObject(String string) throws ParseException(Code)(Java Doc) abstract public Object parseObject(String string, ParsePosition position)(Code)(Java Doc) static boolean upTo(String string, ParsePosition position, StringBuffer buffer, char stop)(Code)(Java Doc) static boolean upToWithQuotes(String string, ParsePosition position, StringBuffer buffer, char stop, char start)(Code)(Java Doc)
|
|
|