/*
*******************************************************************************
- * Copyright (C) 1996-2013, International Business Machines Corporation and *
+ * Copyright (C) 1996-2014, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
import java.util.Set;
import com.ibm.icu.impl.ICUResourceBundle;
+import com.ibm.icu.text.DisplayContext;
import com.ibm.icu.util.Currency;
import com.ibm.icu.util.CurrencyAmount;
import com.ibm.icu.util.ULocale;
return parseStrict;
}
+ /**
+ * {@icu} Set a particular DisplayContext value in the formatter,
+ * such as CAPITALIZATION_FOR_STANDALONE.
+ *
+ * @param context The DisplayContext value to set.
+ * @draft ICU 53
+ * @provisional This API might change or be removed in a future release.
+ */
+ public void setContext(DisplayContext context) {
+ if (context.type() == DisplayContext.Type.CAPITALIZATION) {
+ capitalizationSetting = context;
+ }
+ }
+
+ /**
+ * {@icu} Get the formatter's DisplayContext value for the specified DisplayContext.Type,
+ * such as CAPITALIZATION.
+ *
+ * @param type the DisplayContext.Type whose value to return
+ * @return the current DisplayContext setting for the specified type
+ * @draft ICU 53
+ * @provisional This API might change or be removed in a future release.
+ */
+ public DisplayContext getContext(DisplayContext.Type type) {
+ return (type == DisplayContext.Type.CAPITALIZATION && capitalizationSetting != null)?
+ capitalizationSetting: DisplayContext.CAPITALIZATION_NONE;
+ }
+
//============== Locale Stuff =====================
/**
private static final long serialVersionUID = -2308460125733713944L;
/**
- * Empty constructor. Public for compatibily with JDK which lets the
+ * Empty constructor. Public for compatibility with JDK which lets the
* compiler generate a default public constructor even though this is
* an abstract class.
* @stable ICU 2.6
// new in ICU4J 3.6
private boolean parseStrict;
+ /*
+ * Capitalization setting, new in ICU 53
+ */
+ private transient DisplayContext capitalizationSetting = DisplayContext.CAPITALIZATION_NONE;
+
/**
* The instances of this inner class are used as attribute keys and values
* in AttributedCharacterIterator that
/*
*******************************************************************************
- * Copyright (C) 2001-2013, International Business Machines Corporation and *
+ * Copyright (C) 2001-2014, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
import com.ibm.icu.math.MathContext;
import com.ibm.icu.text.DecimalFormat;
import com.ibm.icu.text.DecimalFormatSymbols;
+import com.ibm.icu.text.DisplayContext;
import com.ibm.icu.text.MeasureFormat;
import com.ibm.icu.text.NumberFormat;
import com.ibm.icu.text.NumberFormat.NumberFormatFactory;
}
}
}
+
+ public void TestContext() {
+ // just a minimal sanity check for now
+ NumberFormat nfmt = NumberFormat.getInstance();
+ DisplayContext context = nfmt.getContext(DisplayContext.Type.CAPITALIZATION);
+ if (context != DisplayContext.CAPITALIZATION_NONE) {
+ errln("FAIL: Initial NumberFormat.getContext() is not CAPITALIZATION_NONE");
+ }
+ nfmt.setContext(DisplayContext.CAPITALIZATION_FOR_STANDALONE);
+ context = nfmt.getContext(DisplayContext.Type.CAPITALIZATION);
+ if (context != DisplayContext.CAPITALIZATION_FOR_STANDALONE) {
+ errln("FAIL: NumberFormat.getContext() does not return the value set, CAPITALIZATION_FOR_STANDALONE");
+ }
+ }
}