|
Sky View Café - Java | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.shetline.util.ExtendedMessageFormat
public class ExtendedMessageFormat
Method Summary | |
---|---|
static String |
format(String pattern,
Object... args)
Return a formatted string, filled in using a specified list of arguments, as per MessageFormat.format(String, Object...) , where pattern is additionally parsed
for xchoice format elements. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static String format(String pattern, Object... args)
Return a formatted string, filled in using a specified list of arguments, as per
MessageFormat.format(String, Object...)
, where pattern
is additionally parsed
for xchoice
format elements.
xchoice
format elements are designed primarily to handle grammatical rules for forming plurals
which are too complex to be handled using the simple numeric ranges of ChoiceFormat.
Here's a less-than-fully formal grammar for xchoice
:
xchoice-pattern: {arg-index,xchoice,case[;case]} (cases are tested from left to right, with the first matching case being used, any following cases being ignored) case: condition:matching-format condition: numeric-value (picked if args[arg-index] is equal) boolean-expr (picked if boolean-expr, with 'x' representing the value of args[arg-index], is true) * (matches everything - subsequent cases are ignored) empty-condition (same as *) matching-format: The text or subpattern that the entire xchoice element resolves to when its associated condition is true.
Whitespace is ignored except in matching-format, where it will be part of the resulting text. The delimiters ';' and ':' can be quoted with single quotes if they are needed as something other than pattern delimiters.
The following is an example pattern for showing "x file(s) extracted" in transliterated Russian, where x is a number of files, and the pattern takes care of the three different plural forms for "arkhiv" (file), and well as the matching verb required:
{0,number,integer} {0,xchoice,x == 1 || (x % 10 == 1 && x > 20):arkhiv izvlekal; (x >= 2 && x <= 4) || (x > 20 && x % 10 >= 2 && x % 10 <= 4):arkhiva izvlekali; :arkhivov izvlekali}.
pattern
- A formatting pattern.args
- Values to be applied to the formatting pattern.
MessageFormat.format(String, Object...)
|
Sky View Café - Java | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |