|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.zkoss.text.MessageFormats
public class MessageFormats
The message formatting relevant utilities.
See also java.text.MessageFormat.
| Nested Class Summary | |
|---|---|
static class |
MessageFormats.NameInfo
The name info returned by parseByName(java.lang.String)). |
| Constructor Summary | |
|---|---|
MessageFormats()
|
|
| Method Summary | |
|---|---|
static StringBuffer |
format(StringBuffer result,
String pattern,
Object[] args)
Creates a MessageFormat with the given pattern and uses it to format the given arguments, by use of StringBuffer and Locales.getCurrent(). |
static StringBuffer |
format(StringBuffer result,
String pattern,
Object[] args,
Locale locale)
Creates a MessageFormat with the given pattern and uses it to format the given arguments, by use of StringBuffer. |
static String |
format(String pattern,
Object[] args)
Creates a MessageFormat with the given pattern and uses it to format the given arguments, by use of Locales.getCurrent(). |
static String |
format(String pattern,
Object[] args,
Locale locale)
Creates a MessageFormat with the given pattern and uses it to format the given arguments. |
static String |
formatByName(String pattern,
Map<String,?> mapping)
Formats a pattern by substituting names with values found in the giving map, by use of Locales.getCurrent(). |
static String |
formatByName(String pattern,
Map<String,?> mapping,
Locale locale)
Formats a pattern by substituting names, enclosing with {}, with values found in the giving map. |
static MessageFormats.NameInfo |
parseByName(String pattern)
Parses a pattern and converts it to the format of java.text.MessageFormat. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public MessageFormats()
| Method Detail |
|---|
public static final String format(String pattern,
Object[] args,
Locale locale)
An extension to java.text.MessageFormat.format by allowing to specify a Locale.
locale - the locale; null for Locales.getCurrent()
public static final String format(String pattern,
Object[] args)
Locales.getCurrent().
Note: java.text.MessageFormat.format uses Locale.getDefault, which might not be correct in a multi-user environment.
public static final StringBuffer format(StringBuffer result,
String pattern,
Object[] args,
Locale locale)
If you want to concatenate a sequence of formated string, use this method.
public static final StringBuffer format(StringBuffer result,
String pattern,
Object[] args)
Locales.getCurrent().
public static final MessageFormats.NameInfo parseByName(String pattern)
Example: "{a} is {b,number} of {a}" will return
new NameInfo("{0} is {1,number} of {0}", {"a", "b"}).
formatByName(String, Map, Locale)
public static final String formatByName(String pattern,
Map<String,?> mapping,
Locale locale)
This is an extension to java.text.MessageFormat. The only difference is that this method use arbitrary name instead of a number. For example, it use {name} instead of {0}. The quotation rule and formating pattern are the same as java.text.MessageFormat. Example, {var,number,$'#',###}.
It actually uses parseByName(java.lang.String) to convert names to numbers,
and then passes to java.text.MessageFormat.
locale - the locale; null for
Locales.getCurrent()
IllegalArgumentException - if the pattern is invalidparseByName(java.lang.String)
public static final String formatByName(String pattern,
Map<String,?> mapping)
Locales.getCurrent().
parseByName(java.lang.String)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||