java.text
Class MessageFormat
- Cloneable, Serializable
clone , equals , extends Object> getClass , finalize , hashCode , notify , notifyAll , toString , wait , wait , wait |
MessageFormat
public MessageFormat(String pattern)
Creates a new MessageFormat object with
the specified pattern
MessageFormat
public MessageFormat(String pattern,
Locale locale)
Creates a new MessageFormat object with
the specified pattern
pattern
- The Patternlocale
- The Locale to use
applyPattern
public void applyPattern(String newPattern)
Applies the specified pattern to this MessageFormat.
format
public final StringBuffer format(arguments[] ,
StringBuffer appendBuf,
FieldPosition fp)
Returns the pattern with the formatted objects.
appendBuf
- The StringBuffer where the text is appened.fp
- A FieldPosition object (it is ignored).
format
public final StringBuffer format(Object objectArray,
StringBuffer appendBuf,
FieldPosition fpos)
Returns the pattern with the formatted objects. The first argument
must be a array of Objects.
This is equivalent to format((Object[]) objectArray, appendBuf, fpos)
- format in interface Format
objectArray
- The object array to be formatted.appendBuf
- The StringBuffer where the text is appened.fpos
- A FieldPosition object (it is ignored).
format
public static String format(String pattern,
java.lang.Object... arguments)
A convinience method to format patterns.
pattern
- The pattern used when formatting.arguments
- The array containing the objects to be formatted.
getFormats
public Format[] getFormats()
Returns an array with the Formats for
the arguments.
getFormatsByArgumentIndex
public Format[] getFormatsByArgumentIndex()
Return the formatters used sorted by argument index. It uses the
internal table to fill in this array: if a format has been
set using 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.
- an array of formatters sorted by argument index.
parse
public Object[] parse(String sourceStr,
ParsePosition pos)
Parse a string 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).
- the array of parsed objects sorted according to their argument number
in the pattern.
setFormat
public void setFormat(int variableNum,
Format newFormat)
Sets the format for the argument at an specified
index.
variableNum
- The index.newFormat
- The Format object.
setFormatByArgumentIndex
public void setFormatByArgumentIndex(int argumentIndex,
Format newFormat)
Set the format to used using the argument index number.
argumentIndex
- the argument index.newFormat
- the format to use for this argument.
setFormats
public void setFormats(Format[] newFormats)
Sets the formats for the arguments.
newFormats
- An array of Format objects.
setFormatsByArgumentIndex
public void setFormatsByArgumentIndex(Format[] newFormats)
Set the format for argument using a specified array of formatters
which is sorted according to the argument index. If the number of
elements in the array is fewer than the number of arguments only
the arguments specified by the array are touched.
newFormats
- array containing the new formats to set.
MessageFormat.java - Localized message formatting.
Copyright (C) 1999, 2001, 2002, 2004, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version.