ICU-8228 Added the constants. Done before the end of the design review period, but don't anticipate any problems (can back out if needed).

X-SVN-Rev: 29222
This commit is contained in:
Mark Davis 2010-12-17 02:38:19 +00:00
parent 9eac5fb126
commit cb1a45d9da
4 changed files with 17 additions and 10 deletions

View file

@ -2039,8 +2039,6 @@ public class DecimalFormat extends NumberFormat {
0xFF0E, 0xFF0E,
0xFF61, 0xFF61).freeze();
private static final UnicodeSet EMPTY_SET = new UnicodeSet().freeze();
// When parsing a number with big exponential value, it requires to transform the
// value into a string representation to construct BigInteger instance. We want to
// set the maximum size because it can easily trigger OutOfMemoryException.
@ -2148,9 +2146,9 @@ public class DecimalFormat extends NumberFormat {
"com.ibm.icu.text.DecimalFormat.SkipExtendedSeparatorParsing", "false")
.equals("true");
UnicodeSet decimalEquiv = skipExtendedSeparatorParsing ? EMPTY_SET :
UnicodeSet decimalEquiv = skipExtendedSeparatorParsing ? UnicodeSet.EMPTY :
getEquivalentDecimals(decimal, strictParse);
UnicodeSet groupEquiv = skipExtendedSeparatorParsing ? EMPTY_SET :
UnicodeSet groupEquiv = skipExtendedSeparatorParsing ? UnicodeSet.EMPTY :
(strictParse ? strictDefaultGroupingSeparators : defaultGroupingSeparators);
// We have to track digitCount ourselves, because digits.count will pin when
@ -2477,7 +2475,7 @@ public class DecimalFormat extends NumberFormat {
* parsing number. This method may return an empty set.
*/
private UnicodeSet getEquivalentDecimals(char decimal, boolean strictParse) {
UnicodeSet equivSet = EMPTY_SET;
UnicodeSet equivSet = UnicodeSet.EMPTY;
if (strictParse) {
if (strictDotEquivalents.contains(decimal)) {
equivSet = strictDotEquivalents;

View file

@ -271,6 +271,17 @@ import com.ibm.icu.util.VersionInfo;
*/
public class UnicodeSet extends UnicodeFilter implements Iterable<String>, Comparable<UnicodeSet>, Freezable<UnicodeSet> {
/**
* Constant for the empty set.
* @draft 4.8
*/
public static final UnicodeSet EMPTY = new UnicodeSet().freeze();
/**
* Constant for the set of all code points. (Since UnicodeSets can include strings, does not include everything that a UnicodeSet can.)
* @draft 4.8
*/
public static final UnicodeSet ALL_CODEPOINTS = new UnicodeSet(0, 0x10FFFF).freeze();
private static final int LOW = 0x000000; // LOW <= all valid values. ZERO for codepoints
private static final int HIGH = 0x110000; // HIGH > all valid values. 10000 for code units.
// 110000 for codepoints

View file

@ -1510,8 +1510,6 @@ public abstract class Transliterator implements StringTransform {
return result;
}
static final UnicodeSet ALL_CODEPOINTS = new UnicodeSet(0,0x10FFFF).freeze();
/**
* Returns the set of all characters that may be modified in the
* input text by this Transliterator. This incorporates this
@ -1527,7 +1525,7 @@ public abstract class Transliterator implements StringTransform {
*/
public final UnicodeSet getSourceSet() {
UnicodeSet result = new UnicodeSet();
addSourceTargetSet(getFilterAsUnicodeSet(ALL_CODEPOINTS), result, new UnicodeSet());
addSourceTargetSet(getFilterAsUnicodeSet(UnicodeSet.ALL_CODEPOINTS), result, new UnicodeSet());
return result;
}
@ -1571,7 +1569,7 @@ public abstract class Transliterator implements StringTransform {
*/
public UnicodeSet getTargetSet() {
UnicodeSet result = new UnicodeSet();
addSourceTargetSet(getFilterAsUnicodeSet(ALL_CODEPOINTS), new UnicodeSet(), result);
addSourceTargetSet(getFilterAsUnicodeSet(UnicodeSet.ALL_CODEPOINTS), new UnicodeSet(), result);
return result;
}

View file

@ -3234,7 +3234,7 @@ public class TransliteratorTest extends TestFmwk {
{"[] title"},
{"[] upper"},
};
UnicodeSet expectedSource = new UnicodeSet().freeze();
UnicodeSet expectedSource = UnicodeSet.EMPTY;
for (String[] testPair : tests) {
String test = testPair[0];
Transliterator t0;