Class MessagePatternUtilDemo
java.lang.Object
com.ibm.icu.samples.text.messagepattern.MessagePatternUtilDemo
Demo code for MessagePattern class.
- Since:
- 2011-jul-14
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static final voidaddArgs(MessagePatternUtil.MessageNode msg, List<String> args) Adds the message's argument names to the args list.private static final Stringprivate static final voidgenCode(MessagePatternUtil.ArgNode arg, int depth, boolean firstResult) private static final voidThis is a prototype/demo/sample for how we could use the MessagePatternUtil class for generating something like JavaScript code for evaluating some of the MessageFormat syntax.private static final voidgenCode(MessagePatternUtil.MessageNode msg, int depth, boolean firstResult, String pluralNumber) private static final voidgenCodeForKeywordVariants(List<MessagePatternUtil.VariantNode> variants, int depth, boolean firstResult, String varName, String pluralNumber) private static final voidgenCodeForNumericVariants(List<MessagePatternUtil.VariantNode> variants, int depth, boolean firstResult, String varName, String pluralNumber) private static final voidgenCodeForPlural(MessagePatternUtil.ComplexArgStyleNode style, int depth, boolean firstResult, String argName) private static final voidgenCodeForSelect(MessagePatternUtil.ComplexArgStyleNode style, int depth, boolean firstResult, String argName) static voidprivate static final MessagePatternUtil.MessageNodeprivate static final voidprintArg(MessagePatternUtil.ArgNode arg, int depth) private static final voidprintComplexArgStyle(MessagePatternUtil.ComplexArgStyleNode style, int depth) private static final voidprintMessage(MessagePatternUtil.MessageNode msg, int depth)
-
Field Details
-
manySpaces
- See Also:
-
-
Constructor Details
-
MessagePatternUtilDemo
public MessagePatternUtilDemo()
-
-
Method Details
-
printMessage
-
printArg
-
printComplexArgStyle
private static final void printComplexArgStyle(MessagePatternUtil.ComplexArgStyleNode style, int depth) -
genCode
This is a prototype/demo/sample for how we could use the MessagePatternUtil class for generating something like JavaScript code for evaluating some of the MessageFormat syntax.This is not intended to be production code, nor to generate production code or even syntactically correct JavaScript.
- Parameters:
msg-
-
genCode
private static final void genCode(MessagePatternUtil.MessageNode msg, int depth, boolean firstResult, String pluralNumber) -
genCode
-
genCodeForPlural
private static final void genCodeForPlural(MessagePatternUtil.ComplexArgStyleNode style, int depth, boolean firstResult, String argName) -
genCodeForSelect
private static final void genCodeForSelect(MessagePatternUtil.ComplexArgStyleNode style, int depth, boolean firstResult, String argName) -
genCodeForNumericVariants
private static final void genCodeForNumericVariants(List<MessagePatternUtil.VariantNode> variants, int depth, boolean firstResult, String varName, String pluralNumber) -
genCodeForKeywordVariants
private static final void genCodeForKeywordVariants(List<MessagePatternUtil.VariantNode> variants, int depth, boolean firstResult, String varName, String pluralNumber) -
addArgs
Adds the message's argument names to the args list. Adds each argument only once, in the order of first appearance. Numbered arguments get an "arg_" prefix prepended.- Parameters:
msg-args-
-
escapeString
-
print
-
main
-