From fb6815fc9daa43cbdf877b9a7963df323348506f Mon Sep 17 00:00:00 2001 From: Doug Felt Date: Thu, 7 Jan 2010 01:18:16 +0000 Subject: [PATCH] ICU-4264 clean up message format docs a bit to clarify use of RBNF, shorten long lines X-SVN-Rev: 27158 --- .../src/com/ibm/icu/text/MessageFormat.java | 98 ++++++++++++------- 1 file changed, 61 insertions(+), 37 deletions(-) diff --git a/icu4j/main/classes/core/src/com/ibm/icu/text/MessageFormat.java b/icu4j/main/classes/core/src/com/ibm/icu/text/MessageFormat.java index db381130744..72d7b84f2de 100644 --- a/icu4j/main/classes/core/src/com/ibm/icu/text/MessageFormat.java +++ b/icu4j/main/classes/core/src/com/ibm/icu/text/MessageFormat.java @@ -1,6 +1,6 @@ /* ********************************************************************** -* Copyright (c) 2004-2009, International Business Machines +* Copyright (c) 2004-2010, International Business Machines * Corporation and others. All Rights Reserved. ********************************************************************** * Author: Alan Liu @@ -109,7 +109,7 @@ import com.ibm.icu.util.ULocale; * [:ID_START:][:ID_CONTINUE:]* * * FormatType: one of - * number date time choice + * number date time choice spellout ordinal duration plural * * FormatStyle: * short @@ -120,6 +120,7 @@ import com.ibm.icu.util.ULocale; * currency * percent * SubformatPattern + * RulesetName * * String: * StringPartopt @@ -139,6 +140,8 @@ import com.ibm.icu.util.ULocale; * UnquotedPattern * * + * RulesetName: + * UnquotedString *

* Within a String, "''" represents a single * quote. A QuotedString can contain arbitrary characters @@ -255,16 +258,19 @@ import com.ibm.icu.util.ULocale; * new ChoiceFormat(subformatPattern) * * spellout - * Ruleset name (optional) - * new RuleBasedNumberFormat(getLocale(), RuleBasedNumberFormat.SPELLOUT)
    .setDefaultRuleset(ruleset);
+ * RulesetName (optional) + * new RuleBasedNumberFormat(getLocale(), RuleBasedNumberFormat.SPELLOUT) + *
    .setDefaultRuleset(ruleset);
* * ordinal - * Ruleset name (optional) - * new RuleBasedNumberFormat(getLocale(), RuleBasedNumberFormat.ORDINAL)
    .setDefaultRuleset(ruleset);
+ * RulesetName (optional) + * new RuleBasedNumberFormat(getLocale(), RuleBasedNumberFormat.ORDINAL) + *
    .setDefaultRuleset(ruleset);
* * duration - * Ruleset name (optional) - * new RuleBasedNumberFormat(getLocale(), RuleBasedNumberFormat.DURATION)
    .setDefaultRuleset(ruleset);
+ * RulesetName (optional) + * new RuleBasedNumberFormat(getLocale(), RuleBasedNumberFormat.DURATION) + *
    .setDefaultRuleset(ruleset);
* * plural * SubformatPattern @@ -391,9 +397,6 @@ import com.ibm.icu.util.ULocale; * @author Mark Davis * @stable ICU 3.0 */ - // TODO: Update JavaDoc class description with regards to named arguments. - // TODO: Update JavaDoc class description with regards to PluralFormat - // integration. public class MessageFormat extends UFormat implements BaseFormat { // Generated by serialver from JDK 1.4.1_01 @@ -588,7 +591,6 @@ public class MessageFormat extends UFormat implements BaseFormat * null * instanceof Date - * DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT, getLocale()).format(argument) + * DateFormat.getDateTimeInstance(DateFormat.SHORT, + * DateFormat.SHORT, getLocale()).format(argument) * * null * instanceof String @@ -1083,7 +1088,9 @@ public class MessageFormat extends UFormat implements BaseFormat - * (new {@link #MessageFormat(String) MessageFormat}(pattern)).{@link #format(java.lang.Object[], java.lang.StringBuffer, java.text.FieldPosition) format}(arguments, new StringBuffer(), null).toString() + * (new {@link #MessageFormat(String) MessageFormat}(pattern)).{@link + * #format(java.lang.Object[], java.lang.StringBuffer, java.text.FieldPosition) + * format}(arguments, new StringBuffer(), null).toString() * * * @throws IllegalArgumentException if the pattern is invalid, @@ -1134,8 +1141,10 @@ public class MessageFormat extends UFormat implements BaseFormatStringBuffer. * This is equivalent to either of *

- * {@link #format(java.lang.Object[], java.lang.StringBuffer, java.text.FieldPosition) format}((Object[]) arguments, result, pos) - * {@link #format(java.util.Map, java.lang.StringBuffer, java.text.FieldPosition) format}((Map) arguments, result, pos) + * {@link #format(java.lang.Object[], java.lang.StringBuffer, + * java.text.FieldPosition) format}((Object[]) arguments, result, pos) + * {@link #format(java.util.Map, java.lang.StringBuffer, + * java.text.FieldPosition) format}((Map) arguments, result, pos) *
* A map must be provided if this format uses named arguments, otherwise * an IllegalArgumentException will be thrown. @@ -1177,7 +1186,8 @@ public class MessageFormat extends UFormat implements BaseFormatAttributedCharacterIterator is * the same that would be returned by *
- * {@link #format(java.lang.Object[], java.lang.StringBuffer, java.text.FieldPosition) format}(arguments, new StringBuffer(), null).toString() + * {@link #format(java.lang.Object[], java.lang.StringBuffer, + * java.text.FieldPosition) format}(arguments, new StringBuffer(), null).toString() *
*

* In addition, the AttributedCharacterIterator contains at @@ -1204,7 +1214,8 @@ public class MessageFormat extends UFormat implements BaseFormat iterators = new ArrayList(); + ArrayList iterators = + new ArrayList(); if (arguments == null) { throw new NullPointerException( @@ -1542,7 +1553,8 @@ public class MessageFormat extends UFormat implements BaseFormat characterIterators) { + FieldPosition fp, List characterIterators) { return subformat(arrayToMap(arguments), result, fp, characterIterators); } @@ -1662,7 +1674,7 @@ public class MessageFormat extends UFormat implements BaseFormat arguments, StringBuffer result, - FieldPosition fp, List characterIterators) { + FieldPosition fp, List characterIterators) { // note: this implementation assumes a fast substring & index. // if this is not true, would be better to append chars one by one. int lastOffset = 0; @@ -1735,9 +1747,11 @@ public class MessageFormat extends UFormat implements BaseFormat 0) { result.append(arg); characterIterators.add( - _createAttributedCharacterIterator( - arg, Field.ARGUMENT, - argumentNamesAreNumeric ? (Object)new Integer(argumentName) : (Object)argumentName)); + _createAttributedCharacterIterator( + arg, Field.ARGUMENT, + argumentNamesAreNumeric ? + (Object)new Integer(argumentName) : + (Object)argumentName)); last = result.length(); } } else { @@ -1900,7 +1916,8 @@ public class MessageFormat extends UFormat implements BaseFormat