import com.ibm.icu.text.MessagePattern;
import com.ibm.icu.text.MessagePatternUtil;
+import com.ibm.icu.text.MessagePatternUtil.VariantNode;
import java.util.ArrayList;
import java.util.List;
double value;
switch (argType) {
case CHOICE:
- System.out.println(indent + variant.getSelectorValue() + " " + variant.getSelector() + ":");
+ System.out.println(indent + variant.getSelectorValue() + " " +
+ variant.getSelector() + ":");
break;
case PLURAL:
value = variant.getSelectorValue();
if (!keywordVariants.isEmpty()) {
System.out.println(manySpaces.substring(0, depth * 2) +
"_keyword = PluralRules.select(" + pluralNumber + ")");
- genCodeForKeywordVariants(keywordVariants, depth++, firstResult, "_keyword", pluralNumber);
+ genCodeForKeywordVariants(keywordVariants, depth++, firstResult,
+ "_keyword", pluralNumber);
}
genCode(otherVariant.getMessage(), depth, firstResult, pluralNumber);
if (origDepth < depth) {
}
}
- private static final void genCodeForNumericVariants(List<MessagePatternUtil.VariantNode> variants,
+ private static final void genCodeForNumericVariants(List<VariantNode> variants,
int depth,
boolean firstResult,
String varName,
System.out.println(indent + "} else {");
}
- private static final void genCodeForKeywordVariants(List<MessagePatternUtil.VariantNode> variants,
+ private static final void genCodeForKeywordVariants(List<VariantNode> variants,
int depth,
boolean firstResult,
String varName,
msg="_'__{gender, select, female{Her n'ame is {person_name}.}"+
"other{His n'ame is {person_name}.}}__'_";
print(msg);
- print("{num,plural,offset:1 =0{no one} =1{one, that is one and # others} " +
- "one{one and # (probably 1) others} few{one and # others} " +
- "other{lots & lots}}");
+ print("{num,plural,offset:1 " +
+ "=0{no one} =1{one, that is one and # others} " +
+ "one{one and # (probably 1) others} few{one and # others} " +
+ "other{lots & lots}}");
print(
"{p1_gender,select," +
"female{" +
* Intended for use in tools when convenience is more important than
* minimizing runtime and object creations.
*
+ * <p>This class only has static methods.
+ * Each of the nested classes is immutable and thread-safe.
+ *
* <p>This class and its nested classes are not intended for public subclassing.
* @draft ICU 49
* @provisional This API might change or be removed in a future release.
/**
* Common base class for all elements in a tree of nodes
* returned by {@link MessagePatternUtil#buildMessageNode(MessagePattern)}.
+ * This class and all subclasses are immutable and thread-safe.
* @draft ICU 49
* @provisional This API might change or be removed in a future release.
*/
*/
@Override
public String toString() {
+ // Note: There is no specific subclass for REPLACE_NUMBER
+ // because it would not provide any additional API.
+ // Therefore we have a little bit of REPLACE_NUMBER-specific code
+ // here in the contents-node base class.
return "{REPLACE_NUMBER}";
}
import com.ibm.icu.text.MessagePattern;
import com.ibm.icu.text.MessagePatternUtil;
-import com.ibm.icu.text.MessagePatternUtil.MessageNode;
-import com.ibm.icu.text.MessagePatternUtil.MessageContentsNode;
-import com.ibm.icu.text.MessagePatternUtil.TextNode;
import com.ibm.icu.text.MessagePatternUtil.ArgNode;
import com.ibm.icu.text.MessagePatternUtil.ComplexArgStyleNode;
+import com.ibm.icu.text.MessagePatternUtil.MessageContentsNode;
+import com.ibm.icu.text.MessagePatternUtil.MessageNode;
+import com.ibm.icu.text.MessagePatternUtil.TextNode;
import com.ibm.icu.text.MessagePatternUtil.VariantNode;
/**
finishComplexArg().
expectTextThatContains("_z");
expect.checkMatches(msg);
+ // Plural with explicit offset:0.
+ msg = MessagePatternUtil.buildMessageNode(
+ "a_{0,plural,offset:0 other{num=#!}}_z");
+ expect = new ExpectMessageNode().
+ expectTextThatContains("a_").
+ expectPluralArg(0).
+ expectOffset(0).
+ expectVariant("other").
+ expectTextThatContains("num=").expectReplaceNumber().
+ expectTextThatContains("!").finishVariant().
+ finishComplexArg().
+ expectTextThatContains("_z");
+ expect.checkMatches(msg);
}
public void TestChoiceArg() {