|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.text.Format
java.text.MessageFormat
public class MessageFormat
Nested Class Summary | |
---|---|
static class |
MessageFormat.Field
|
Constructor Summary | |
---|---|
MessageFormat(String pattern)
Creates a new MessageFormat object with the specified pattern |
|
MessageFormat(String pattern,
Locale locale)
Creates a new MessageFormat object with the specified pattern |
Method Summary | |
---|---|
void |
applyPattern(String newPattern)
Applies the specified pattern to this MessageFormat. |
Object |
clone()
Overrides Format.clone() |
boolean |
equals(Object obj)
Overrides Format.equals(Object obj) |
StringBuffer |
format(Object[] arguments,
StringBuffer appendBuf,
FieldPosition fp)
Returns the pattern with the formatted objects. |
StringBuffer |
format(Object objectArray,
StringBuffer appendBuf,
FieldPosition fpos)
Returns the pattern with the formatted objects. |
static String |
format(String pattern,
Object... arguments)
A convinience method to format patterns. |
AttributedCharacterIterator |
formatToCharacterIterator(Object arguments)
A convinience method to format patterns. |
Format[] |
getFormats()
Returns an array with the Formats for the arguments. |
Format[] |
getFormatsByArgumentIndex()
Return the formatters used sorted by argument index. |
Locale |
getLocale()
Returns the locale. |
int |
hashCode()
Overrides Format.hashCode() |
Object[] |
parse(String sourceStr)
|
Object[] |
parse(String sourceStr,
ParsePosition pos)
Parse a string sourceStr against the pattern specified
to the MessageFormat constructor. |
Object |
parseObject(String sourceStr,
ParsePosition pos)
This method parses a String and converts the parsed
contents into an Object . |
void |
setFormat(int variableNum,
Format newFormat)
Sets the format for the argument at an specified index. |
void |
setFormatByArgumentIndex(int argumentIndex,
Format newFormat)
Set the format to used using the argument index number. |
void |
setFormats(Format[] newFormats)
Sets the formats for the arguments. |
void |
setFormatsByArgumentIndex(Format[] newFormats)
Set the format for argument using a specified array of formatters which is sorted according to the argument index. |
void |
setLocale(Locale loc)
Sets the locale. |
String |
toPattern()
Returns the pattern. |
Methods inherited from class java.text.Format |
---|
format, parseObject |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public MessageFormat(String pattern)
pattern
- The Patternpublic MessageFormat(String pattern, Locale locale)
pattern
- The Patternlocale
- The Locale to useMethod Detail |
---|
public void applyPattern(String newPattern)
newPattern
- The Patternpublic Object clone()
clone
in class Format
Object
.Cloneable
public boolean equals(Object obj)
equals
in class Object
obj
- the Object to compare to
Object.hashCode()
public AttributedCharacterIterator formatToCharacterIterator(Object arguments)
formatToCharacterIterator
in class Format
arguments
- The array containing the objects to be formatted.public static String format(String pattern, Object... arguments)
pattern
- The pattern used when formatting.arguments
- The array containing the objects to be formatted.public final StringBuffer format(Object[] arguments, StringBuffer appendBuf, FieldPosition fp)
arguments
- The array containing the objects to be formatted.appendBuf
- The StringBuffer where the text is appened.fp
- A FieldPosition object (it is ignored).public final StringBuffer format(Object objectArray, StringBuffer appendBuf, FieldPosition fpos)
format
in class Format
objectArray
- The object array to be formatted.appendBuf
- The StringBuffer where the text is appened.fpos
- A FieldPosition object (it is ignored).
StringBuffer
.public Format[] getFormats()
public Locale getLocale()
public int hashCode()
hashCode
in class Object
Object.equals(Object)
,
System.identityHashCode(Object)
public Object[] parse(String sourceStr, ParsePosition pos)
sourceStr
against the pattern specified
to the MessageFormat constructor.
sourceStr
- the string to be parsed.pos
- the current parse position (and eventually the error position).
public Object[] parse(String sourceStr) throws ParseException
ParseException
public Object parseObject(String sourceStr, ParsePosition pos)
Format
String
and converts the parsed
contents into an Object
.
parseObject
in class Format
sourceStr
- The String
to parse.pos
- The starting parse index on input, the ending parse
index on output.
Object
, or null
in
case of error.public void setFormat(int variableNum, Format newFormat)
variableNum
- The index.newFormat
- The Format object.public void setFormats(Format[] newFormats)
newFormats
- An array of Format objects.public void setLocale(Locale loc)
loc
- A Localepublic String toPattern()
public Format[] getFormatsByArgumentIndex()
setFormat
or setFormatByArgumentIndex
then it returns it at the right index. If not it uses the detected
formatters during a format
call. If nothing is known
about that argument index it just puts null at that position.
To get useful informations you may have to call format
at least once.
public void setFormatByArgumentIndex(int argumentIndex, Format newFormat)
argumentIndex
- the argument index.newFormat
- the format to use for this argument.public void setFormatsByArgumentIndex(Format[] newFormats)
newFormats
- array containing the new formats to set.
NullPointerException
- if newFormats is null
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |