mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-07 14:31:31 +00:00
ICU-8400 fixes for DOS line endings and missing svn properties. (BRS)
X-SVN-Rev: 29528
This commit is contained in:
parent
1997f5bee2
commit
7dcc85ac13
49 changed files with 30015 additions and 30068 deletions
53
.gitattributes
vendored
53
.gitattributes
vendored
|
@ -209,11 +209,8 @@ icu4c/source/tools/toolutil/toolutil.vcxproj -text
|
|||
icu4j/build.properties -text
|
||||
icu4j/demos/.settings/org.eclipse.core.resources.prefs -text
|
||||
icu4j/demos/manifest.stub -text
|
||||
icu4j/eclipse-build/eclipse_mod_classes.txt -text
|
||||
icu4j/eclipse-build/eclipse_mod_test_classes.txt -text
|
||||
icu4j/eclipse-build/features.template/com.ibm.icu.base/.project -text
|
||||
icu4j/eclipse-build/features.template/com.ibm.icu.base/build.properties -text
|
||||
icu4j/eclipse-build/features.template/com.ibm.icu.base/feature.xml -text
|
||||
icu4j/eclipse-build/plugins.template/com.ibm.icu.base.tests/.classpath -text
|
||||
icu4j/eclipse-build/plugins.template/com.ibm.icu.base.tests/.project -text
|
||||
icu4j/eclipse-build/plugins.template/com.ibm.icu.base.tests/.settings/org.eclipse.jdt.core.prefs -text
|
||||
|
@ -221,20 +218,6 @@ icu4j/eclipse-build/plugins.template/com.ibm.icu.base.tests/.settings/org.eclips
|
|||
icu4j/eclipse-build/plugins.template/com.ibm.icu.base.tests/META-INF/MANIFEST.MF -text
|
||||
icu4j/eclipse-build/plugins.template/com.ibm.icu.base.tests/build.properties -text
|
||||
icu4j/eclipse-build/plugins.template/com.ibm.icu.base.tests/plugin.properties -text
|
||||
icu4j/eclipse-build/plugins.template/com.ibm.icu.base.tests/src/com/ibm/icu/tests/BreakIteratorTest.java -text
|
||||
icu4j/eclipse-build/plugins.template/com.ibm.icu.base.tests/src/com/ibm/icu/tests/CalendarTest.java -text
|
||||
icu4j/eclipse-build/plugins.template/com.ibm.icu.base.tests/src/com/ibm/icu/tests/CollationKeyTest.java -text
|
||||
icu4j/eclipse-build/plugins.template/com.ibm.icu.base.tests/src/com/ibm/icu/tests/CollatorTest.java -text
|
||||
icu4j/eclipse-build/plugins.template/com.ibm.icu.base.tests/src/com/ibm/icu/tests/DateFormatSymbolsTest.java -text
|
||||
icu4j/eclipse-build/plugins.template/com.ibm.icu.base.tests/src/com/ibm/icu/tests/DateFormatTest.java -text
|
||||
icu4j/eclipse-build/plugins.template/com.ibm.icu.base.tests/src/com/ibm/icu/tests/DecimalFormatSymbolsTest.java -text
|
||||
icu4j/eclipse-build/plugins.template/com.ibm.icu.base.tests/src/com/ibm/icu/tests/DecimalFormatTest.java -text
|
||||
icu4j/eclipse-build/plugins.template/com.ibm.icu.base.tests/src/com/ibm/icu/tests/ICUTestCase.java -text
|
||||
icu4j/eclipse-build/plugins.template/com.ibm.icu.base.tests/src/com/ibm/icu/tests/MessageFormatTest.java -text
|
||||
icu4j/eclipse-build/plugins.template/com.ibm.icu.base.tests/src/com/ibm/icu/tests/NumberFormatTest.java -text
|
||||
icu4j/eclipse-build/plugins.template/com.ibm.icu.base.tests/src/com/ibm/icu/tests/SimpleDateFormatTest.java -text
|
||||
icu4j/eclipse-build/plugins.template/com.ibm.icu.base.tests/src/com/ibm/icu/tests/TimeZoneTest.java -text
|
||||
icu4j/eclipse-build/plugins.template/com.ibm.icu.base.tests/src/com/ibm/icu/tests/ULocaleTest.java -text
|
||||
icu4j/eclipse-build/plugins.template/com.ibm.icu.base/.classpath -text
|
||||
icu4j/eclipse-build/plugins.template/com.ibm.icu.base/.project -text
|
||||
icu4j/eclipse-build/plugins.template/com.ibm.icu.base/.settings/org.eclipse.jdt.core.prefs -text
|
||||
|
@ -242,37 +225,6 @@ icu4j/eclipse-build/plugins.template/com.ibm.icu.base/.settings/org.eclipse.jdt.
|
|||
icu4j/eclipse-build/plugins.template/com.ibm.icu.base/META-INF/MANIFEST.MF -text
|
||||
icu4j/eclipse-build/plugins.template/com.ibm.icu.base/build.properties -text
|
||||
icu4j/eclipse-build/plugins.template/com.ibm.icu.base/plugin.properties -text
|
||||
icu4j/eclipse-build/plugins.template/com.ibm.icu.base/src/com/ibm/icu/impl/ICUCache.java -text
|
||||
icu4j/eclipse-build/plugins.template/com.ibm.icu.base/src/com/ibm/icu/impl/LocaleIDParser.java -text
|
||||
icu4j/eclipse-build/plugins.template/com.ibm.icu.base/src/com/ibm/icu/impl/LocaleIDs.java -text
|
||||
icu4j/eclipse-build/plugins.template/com.ibm.icu.base/src/com/ibm/icu/impl/LocaleUtility.java -text
|
||||
icu4j/eclipse-build/plugins.template/com.ibm.icu.base/src/com/ibm/icu/impl/SimpleCache.java -text
|
||||
icu4j/eclipse-build/plugins.template/com.ibm.icu.base/src/com/ibm/icu/impl/locale/AsciiUtil.java -text
|
||||
icu4j/eclipse-build/plugins.template/com.ibm.icu.base/src/com/ibm/icu/math/BigDecimal.java -text
|
||||
icu4j/eclipse-build/plugins.template/com.ibm.icu.base/src/com/ibm/icu/math/MathContext.java -text
|
||||
icu4j/eclipse-build/plugins.template/com.ibm.icu.base/src/com/ibm/icu/text/Bidi.java -text
|
||||
icu4j/eclipse-build/plugins.template/com.ibm.icu.base/src/com/ibm/icu/text/BidiClassifier.java -text
|
||||
icu4j/eclipse-build/plugins.template/com.ibm.icu.base/src/com/ibm/icu/text/BidiRun.java -text
|
||||
icu4j/eclipse-build/plugins.template/com.ibm.icu.base/src/com/ibm/icu/text/BreakIterator.java -text
|
||||
icu4j/eclipse-build/plugins.template/com.ibm.icu.base/src/com/ibm/icu/text/CollationKey.java -text
|
||||
icu4j/eclipse-build/plugins.template/com.ibm.icu.base/src/com/ibm/icu/text/Collator.java -text
|
||||
icu4j/eclipse-build/plugins.template/com.ibm.icu.base/src/com/ibm/icu/text/CurrencyPluralInfo.java -text
|
||||
icu4j/eclipse-build/plugins.template/com.ibm.icu.base/src/com/ibm/icu/text/DateFormat.java -text
|
||||
icu4j/eclipse-build/plugins.template/com.ibm.icu.base/src/com/ibm/icu/text/DateFormatSymbols.java -text
|
||||
icu4j/eclipse-build/plugins.template/com.ibm.icu.base/src/com/ibm/icu/text/DecimalFormat.java -text
|
||||
icu4j/eclipse-build/plugins.template/com.ibm.icu.base/src/com/ibm/icu/text/DecimalFormatSymbols.java -text
|
||||
icu4j/eclipse-build/plugins.template/com.ibm.icu.base/src/com/ibm/icu/text/MessageFormat.java -text
|
||||
icu4j/eclipse-build/plugins.template/com.ibm.icu.base/src/com/ibm/icu/text/NumberFormat.java -text
|
||||
icu4j/eclipse-build/plugins.template/com.ibm.icu.base/src/com/ibm/icu/text/RawCollationKey.java -text
|
||||
icu4j/eclipse-build/plugins.template/com.ibm.icu.base/src/com/ibm/icu/text/SimpleDateFormat.java -text
|
||||
icu4j/eclipse-build/plugins.template/com.ibm.icu.base/src/com/ibm/icu/text/UFormat.java -text
|
||||
icu4j/eclipse-build/plugins.template/com.ibm.icu.base/src/com/ibm/icu/text/UnicodeSet.java -text
|
||||
icu4j/eclipse-build/plugins.template/com.ibm.icu.base/src/com/ibm/icu/util/Calendar.java -text
|
||||
icu4j/eclipse-build/plugins.template/com.ibm.icu.base/src/com/ibm/icu/util/Currency.java -text
|
||||
icu4j/eclipse-build/plugins.template/com.ibm.icu.base/src/com/ibm/icu/util/CurrencyAmount.java -text
|
||||
icu4j/eclipse-build/plugins.template/com.ibm.icu.base/src/com/ibm/icu/util/TimeZone.java -text
|
||||
icu4j/eclipse-build/plugins.template/com.ibm.icu.base/src/com/ibm/icu/util/ULocale.java -text
|
||||
icu4j/eclipse-build/plugins.template/com.ibm.icu.base/src/com/ibm/icu/util/VersionInfo.java -text
|
||||
icu4j/eclipse-build/plugins.template/com.ibm.icu.tests/META-INF/MANIFEST.MF -text
|
||||
icu4j/eclipse-build/plugins.template/com.ibm.icu.tests/plugin.properties -text
|
||||
icu4j/eclipse-build/plugins.template/com.ibm.icu/META-INF/MANIFEST.MF -text
|
||||
|
@ -292,7 +244,6 @@ icu4j/main/classes/core/.project -text
|
|||
icu4j/main/classes/core/.settings/org.eclipse.core.resources.prefs -text
|
||||
icu4j/main/classes/core/.settings/org.eclipse.jdt.core.prefs -text
|
||||
icu4j/main/classes/core/manifest.stub -text
|
||||
icu4j/main/classes/core/src/com/ibm/icu/lang/CharSequences.java -text
|
||||
icu4j/main/classes/currdata/.externalToolBuilders/copy-data-currdata.launch -text
|
||||
icu4j/main/classes/currdata/.settings/org.eclipse.core.resources.prefs -text
|
||||
icu4j/main/classes/currdata/.settings/org.eclipse.jdt.core.prefs -text
|
||||
|
@ -327,7 +278,6 @@ icu4j/main/classes/translit/.externalToolBuilders/copy-data-translit.launch -tex
|
|||
icu4j/main/classes/translit/.settings/org.eclipse.core.resources.prefs -text
|
||||
icu4j/main/classes/translit/.settings/org.eclipse.jdt.core.prefs -text
|
||||
icu4j/main/classes/translit/.settings/org.eclipse.jdt.ui.prefs -text
|
||||
icu4j/main/classes/translit/src/com/ibm/icu/text/SourceTargetUtility.java -text
|
||||
icu4j/main/classes/translit/translit-build.launch -text
|
||||
icu4j/main/shared/.project -text
|
||||
icu4j/main/shared/.settings/org.eclipse.core.resources.prefs -text
|
||||
|
@ -601,7 +551,6 @@ icu4j/main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.4/com.ibm
|
|||
icu4j/main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.4/com.ibm.icu.util.ULocale.dat -text
|
||||
icu4j/main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.4/com.ibm.icu.util.UResourceTypeMismatchException.dat -text
|
||||
icu4j/main/tests/core/src/com/ibm/icu/dev/test/serializable/data/ICU_4.4/com.ibm.icu.util.VTimeZone.dat -text
|
||||
icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/Timer.java -text
|
||||
icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/Trie2Test.setRanges1.16.tri2 -text
|
||||
icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/Trie2Test.setRanges1.32.tri2 -text
|
||||
icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/Trie2Test.setRanges2.16.tri2 -text
|
||||
|
@ -612,8 +561,6 @@ icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/Trie2Test.setRangesEmpty.16.
|
|||
icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/Trie2Test.setRangesEmpty.32.tri2 -text
|
||||
icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/Trie2Test.setRangesSingleValue.16.tri2 -text
|
||||
icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/Trie2Test.setRangesSingleValue.32.tri2 -text
|
||||
icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/TrieMap.java -text
|
||||
icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/TrieMapTest.java -text
|
||||
icu4j/main/tests/framework/.classpath -text
|
||||
icu4j/main/tests/framework/.project -text
|
||||
icu4j/main/tests/framework/.settings/org.eclipse.core.resources.prefs -text
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# Copyright (C) 2011, International Business Machines Corporation and
|
||||
# others. All Rights Reserved.
|
||||
|
||||
com/ibm/icu/lang/UCharacter.java
|
||||
com/ibm/icu/text/DecimalFormat.java
|
||||
# Copyright (C) 2011, International Business Machines Corporation and
|
||||
# others. All Rights Reserved.
|
||||
|
||||
com/ibm/icu/lang/UCharacter.java
|
||||
com/ibm/icu/text/DecimalFormat.java
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# Copyright (C) 2011, International Business Machines Corporation and
|
||||
# others. All Rights Reserved.
|
||||
|
||||
com/ibm/icu/dev/test/format/IntlTestDecimalFormatAPI.java
|
||||
com/ibm/icu/dev/test/format/NumberFormatTest.java
|
||||
com/ibm/icu/dev/test/serializable/CompatibilityTest.java
|
||||
com/ibm/icu/dev/test/serializable/CoverageTest.java
|
||||
# Copyright (C) 2011, International Business Machines Corporation and
|
||||
# others. All Rights Reserved.
|
||||
|
||||
com/ibm/icu/dev/test/format/IntlTestDecimalFormatAPI.java
|
||||
com/ibm/icu/dev/test/format/NumberFormatTest.java
|
||||
com/ibm/icu/dev/test/serializable/CompatibilityTest.java
|
||||
com/ibm/icu/dev/test/serializable/CoverageTest.java
|
||||
|
|
|
@ -1,33 +1,33 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<feature
|
||||
id="com.ibm.icu.base"
|
||||
label="com.ibm.icu.base"
|
||||
version="@BUILD_VERSION@">
|
||||
|
||||
<description url="http://www.example.com/description">
|
||||
[Enter Feature Description here.]
|
||||
</description>
|
||||
|
||||
<copyright url="http://www.example.com/copyright">
|
||||
[Enter Copyright Description here.]
|
||||
</copyright>
|
||||
|
||||
<license url="http://www.example.com/license">
|
||||
[Enter License Description here.]
|
||||
</license>
|
||||
|
||||
<plugin
|
||||
id="com.ibm.icu.base"
|
||||
download-size="0"
|
||||
install-size="0"
|
||||
version="@BUILD_VERSION@"
|
||||
unpack="false"/>
|
||||
|
||||
<plugin
|
||||
id="com.ibm.icu.base.source"
|
||||
download-size="0"
|
||||
install-size="0"
|
||||
version="@BUILD_VERSION@"
|
||||
unpack="false"/>
|
||||
|
||||
</feature>
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<feature
|
||||
id="com.ibm.icu.base"
|
||||
label="com.ibm.icu.base"
|
||||
version="@BUILD_VERSION@">
|
||||
|
||||
<description url="http://www.example.com/description">
|
||||
[Enter Feature Description here.]
|
||||
</description>
|
||||
|
||||
<copyright url="http://www.example.com/copyright">
|
||||
[Enter Copyright Description here.]
|
||||
</copyright>
|
||||
|
||||
<license url="http://www.example.com/license">
|
||||
[Enter License Description here.]
|
||||
</license>
|
||||
|
||||
<plugin
|
||||
id="com.ibm.icu.base"
|
||||
download-size="0"
|
||||
install-size="0"
|
||||
version="@BUILD_VERSION@"
|
||||
unpack="false"/>
|
||||
|
||||
<plugin
|
||||
id="com.ibm.icu.base.source"
|
||||
download-size="0"
|
||||
install-size="0"
|
||||
version="@BUILD_VERSION@"
|
||||
unpack="false"/>
|
||||
|
||||
</feature>
|
||||
|
|
|
@ -1,359 +1,359 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2006-2011, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
package com.ibm.icu.tests;
|
||||
|
||||
import java.text.CharacterIterator;
|
||||
import java.text.StringCharacterIterator;
|
||||
import java.util.Locale;
|
||||
|
||||
import com.ibm.icu.text.BreakIterator;
|
||||
import com.ibm.icu.util.ULocale;
|
||||
|
||||
public class BreakIteratorTest extends ICUTestCase {
|
||||
// ICU behaves a bit differently with this text, but the tested values aren't
|
||||
// affected. If Java changes behavior they might need to change.
|
||||
private static final String text = "Mr. and Mrs. Mumblety-Peg paid $35.97 for a new 12\" cockatoo. " +
|
||||
"When they got home they both cooed \"Isn't it lovely?\" and sighed softly. " +
|
||||
"\"Let's name it u\u0308\u5098!\" they said with glee.";
|
||||
private static int pos = text.indexOf("sn't");
|
||||
private static BreakIterator cbr;
|
||||
private static BreakIterator wbr;
|
||||
private static BreakIterator lbr;
|
||||
private static BreakIterator sbr;
|
||||
|
||||
static {
|
||||
cbr = BreakIterator.getCharacterInstance();
|
||||
cbr.setText(text);
|
||||
wbr = BreakIterator.getWordInstance();
|
||||
wbr.setText(text);
|
||||
lbr = BreakIterator.getLineInstance();
|
||||
lbr.setText(text);
|
||||
sbr = BreakIterator.getSentenceInstance();
|
||||
sbr.setText(text);
|
||||
|
||||
// diagnostic
|
||||
// dump(cbr);
|
||||
// dump(wbr);
|
||||
// dump(lbr);
|
||||
// dump(sbr);
|
||||
}
|
||||
|
||||
// private static void dump(BreakIterator bi) {
|
||||
// for (int ix = bi.first(), lim = text.length(); ix != lim;) {
|
||||
// int nx = bi.next();
|
||||
// if (nx < 0) nx = lim;
|
||||
// System.out.println(Integer.toString(ix) + ": " + text.substring(ix, nx));
|
||||
// ix = nx;
|
||||
// }
|
||||
// }
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.BreakIterator.hashCode()'
|
||||
*/
|
||||
public void testHashCode() {
|
||||
BreakIterator br = BreakIterator.getWordInstance();
|
||||
br.setText(text);
|
||||
BreakIterator brne = BreakIterator.getWordInstance();
|
||||
brne.setText(text + "X");
|
||||
wbr.first();
|
||||
testEHCS(br, wbr, brne);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.BreakIterator.BreakIterator(BreakIterator)'
|
||||
*/
|
||||
public void testBreakIterator() {
|
||||
// implicitly tested everywhere
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.BreakIterator.first()'
|
||||
*/
|
||||
public void testFirst() {
|
||||
assertEquals(0, cbr.first());
|
||||
assertEquals(0, wbr.first());
|
||||
assertEquals(0, lbr.first());
|
||||
assertEquals(0, sbr.first());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.BreakIterator.last()'
|
||||
*/
|
||||
public void testLast() {
|
||||
assertEquals(text.length(), cbr.last());
|
||||
assertEquals(text.length(), wbr.last());
|
||||
assertEquals(text.length(), lbr.last());
|
||||
assertEquals(text.length(), sbr.last());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.BreakIterator.next(int)'
|
||||
*/
|
||||
public void testNextInt() {
|
||||
cbr.first();
|
||||
wbr.first();
|
||||
lbr.first();
|
||||
sbr.first();
|
||||
assertEquals(2, cbr.next(2));
|
||||
assertEquals(3, wbr.next(2));
|
||||
assertEquals(8, lbr.next(2));
|
||||
assertEquals(62, sbr.next(2));
|
||||
|
||||
cbr.last();
|
||||
wbr.last();
|
||||
lbr.last();
|
||||
sbr.last();
|
||||
assertEquals(174, cbr.next(-2));
|
||||
assertEquals(171, wbr.next(-2));
|
||||
assertEquals(166, lbr.next(-2));
|
||||
assertEquals(135, sbr.next(-2));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.BreakIterator.next()'
|
||||
*/
|
||||
public void testNext() {
|
||||
cbr.first();
|
||||
wbr.first();
|
||||
lbr.first();
|
||||
sbr.first();
|
||||
assertEquals(1, cbr.next());
|
||||
assertEquals(2, wbr.next());
|
||||
assertEquals(4, lbr.next());
|
||||
assertEquals(13, sbr.next());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.BreakIterator.previous()'
|
||||
*/
|
||||
public void testPrevious() {
|
||||
cbr.last();
|
||||
wbr.last();
|
||||
lbr.last();
|
||||
sbr.last();
|
||||
assertEquals(175, cbr.previous());
|
||||
assertEquals(175, wbr.previous());
|
||||
assertEquals(171, lbr.previous());
|
||||
assertEquals(156, sbr.previous());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.BreakIterator.following(int)'
|
||||
*/
|
||||
public void testFollowing() {
|
||||
assertEquals(100, cbr.following(pos));
|
||||
assertEquals(103, wbr.following(pos));
|
||||
assertEquals(104, lbr.following(pos));
|
||||
assertEquals(116, sbr.following(pos));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.BreakIterator.preceding(int)'
|
||||
*/
|
||||
public void testPreceding() {
|
||||
assertEquals(98, cbr.preceding(pos));
|
||||
assertEquals(98, wbr.preceding(pos));
|
||||
assertEquals(97, lbr.preceding(pos));
|
||||
assertEquals(62, sbr.preceding(pos));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.BreakIterator.isBoundary(int)'
|
||||
*/
|
||||
public void testIsBoundary() {
|
||||
assertTrue(cbr.isBoundary(pos));
|
||||
assertFalse(wbr.isBoundary(pos));
|
||||
assertFalse(lbr.isBoundary(pos));
|
||||
assertFalse(sbr.isBoundary(pos));
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.BreakIterator.current()'
|
||||
*/
|
||||
public void testCurrent() {
|
||||
cbr.following(pos);
|
||||
wbr.following(pos);
|
||||
lbr.following(pos);
|
||||
sbr.following(pos);
|
||||
assertEquals(100, cbr.current());
|
||||
assertEquals(103, wbr.current());
|
||||
assertEquals(104, lbr.current());
|
||||
assertEquals(116, sbr.current());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.BreakIterator.getText()'
|
||||
*/
|
||||
public void testGetText() {
|
||||
CharacterIterator ci = cbr.getText();
|
||||
StringBuffer buf = new StringBuffer(ci.getEndIndex() - ci.getBeginIndex());
|
||||
for (char c = ci.first(); c != CharacterIterator.DONE; c = ci.next()) {
|
||||
buf.append(c);
|
||||
}
|
||||
String result = buf.toString();
|
||||
assertEquals(text, result);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.BreakIterator.setText(String)'
|
||||
*/
|
||||
public void testSetTextString() {
|
||||
// implicitly tested
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.BreakIterator.setText(CharacterIterator)'
|
||||
*/
|
||||
public void testSetTextCharacterIterator() {
|
||||
CharacterIterator ci = new StringCharacterIterator(text, pos);
|
||||
BreakIterator bi = BreakIterator.getWordInstance();
|
||||
bi.setText(ci);
|
||||
assertEquals(2, bi.next());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.BreakIterator.getWordInstance()'
|
||||
*/
|
||||
public void testGetWordInstance() {
|
||||
// implicitly tested
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.BreakIterator.getWordInstance(Locale)'
|
||||
*/
|
||||
public void testGetWordInstanceLocale() {
|
||||
assertNotNull(BreakIterator.getWordInstance(Locale.JAPAN));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.BreakIterator.getWordInstance(ULocale)'
|
||||
*/
|
||||
public void testGetWordInstanceULocale() {
|
||||
assertNotNull(BreakIterator.getWordInstance(ULocale.JAPAN));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.BreakIterator.getLineInstance()'
|
||||
*/
|
||||
public void testGetLineInstance() {
|
||||
// implicitly tested
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.BreakIterator.getLineInstance(Locale)'
|
||||
*/
|
||||
public void testGetLineInstanceLocale() {
|
||||
assertNotNull(BreakIterator.getLineInstance(Locale.JAPAN));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.BreakIterator.getLineInstance(ULocale)'
|
||||
*/
|
||||
public void testGetLineInstanceULocale() {
|
||||
assertNotNull(BreakIterator.getLineInstance(ULocale.JAPAN));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.BreakIterator.getCharacterInstance()'
|
||||
*/
|
||||
public void testGetCharacterInstance() {
|
||||
// implicitly tested
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.BreakIterator.getCharacterInstance(Locale)'
|
||||
*/
|
||||
public void testGetCharacterInstanceLocale() {
|
||||
assertNotNull(BreakIterator.getCharacterInstance(Locale.JAPAN));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.BreakIterator.getCharacterInstance(ULocale)'
|
||||
*/
|
||||
public void testGetCharacterInstanceULocale() {
|
||||
assertNotNull(BreakIterator.getCharacterInstance(ULocale.JAPAN));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.BreakIterator.getSentenceInstance()'
|
||||
*/
|
||||
public void testGetSentenceInstance() {
|
||||
// implicitly tested
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.BreakIterator.getSentenceInstance(Locale)'
|
||||
*/
|
||||
public void testGetSentenceInstanceLocale() {
|
||||
assertNotNull(BreakIterator.getSentenceInstance(Locale.JAPAN));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.BreakIterator.getSentenceInstance(ULocale)'
|
||||
*/
|
||||
public void testGetSentenceInstanceULocale() {
|
||||
assertNotNull(BreakIterator.getSentenceInstance(ULocale.JAPAN));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.BreakIterator.getTitleInstance()'
|
||||
*/
|
||||
public void testGetTitleInstance() {
|
||||
// not implemented
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.BreakIterator.getTitleInstance(Locale)'
|
||||
*/
|
||||
public void testGetTitleInstanceLocale() {
|
||||
// not implemented
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.BreakIterator.getTitleInstance(ULocale)'
|
||||
*/
|
||||
public void testGetTitleInstanceULocale() {
|
||||
// not implemented
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.BreakIterator.getAvailableLocales()'
|
||||
*/
|
||||
public void testGetAvailableLocales() {
|
||||
assertNotNull(BreakIterator.getAvailableLocales());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.BreakIterator.getAvailableULocales()'
|
||||
*/
|
||||
public void testGetAvailableULocales() {
|
||||
assertNotNull(BreakIterator.getAvailableULocales());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.BreakIterator.toString()'
|
||||
*/
|
||||
public void testToString() {
|
||||
assertNotNull(cbr.toString());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.BreakIterator.clone()'
|
||||
*/
|
||||
public void testClone() {
|
||||
// see testHashCode
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.BreakIterator.equals(Object)'
|
||||
*/
|
||||
public void testEqualsObject() {
|
||||
// see testHashCode
|
||||
}
|
||||
}
|
||||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2006-2011, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
package com.ibm.icu.tests;
|
||||
|
||||
import java.text.CharacterIterator;
|
||||
import java.text.StringCharacterIterator;
|
||||
import java.util.Locale;
|
||||
|
||||
import com.ibm.icu.text.BreakIterator;
|
||||
import com.ibm.icu.util.ULocale;
|
||||
|
||||
public class BreakIteratorTest extends ICUTestCase {
|
||||
// ICU behaves a bit differently with this text, but the tested values aren't
|
||||
// affected. If Java changes behavior they might need to change.
|
||||
private static final String text = "Mr. and Mrs. Mumblety-Peg paid $35.97 for a new 12\" cockatoo. " +
|
||||
"When they got home they both cooed \"Isn't it lovely?\" and sighed softly. " +
|
||||
"\"Let's name it u\u0308\u5098!\" they said with glee.";
|
||||
private static int pos = text.indexOf("sn't");
|
||||
private static BreakIterator cbr;
|
||||
private static BreakIterator wbr;
|
||||
private static BreakIterator lbr;
|
||||
private static BreakIterator sbr;
|
||||
|
||||
static {
|
||||
cbr = BreakIterator.getCharacterInstance();
|
||||
cbr.setText(text);
|
||||
wbr = BreakIterator.getWordInstance();
|
||||
wbr.setText(text);
|
||||
lbr = BreakIterator.getLineInstance();
|
||||
lbr.setText(text);
|
||||
sbr = BreakIterator.getSentenceInstance();
|
||||
sbr.setText(text);
|
||||
|
||||
// diagnostic
|
||||
// dump(cbr);
|
||||
// dump(wbr);
|
||||
// dump(lbr);
|
||||
// dump(sbr);
|
||||
}
|
||||
|
||||
// private static void dump(BreakIterator bi) {
|
||||
// for (int ix = bi.first(), lim = text.length(); ix != lim;) {
|
||||
// int nx = bi.next();
|
||||
// if (nx < 0) nx = lim;
|
||||
// System.out.println(Integer.toString(ix) + ": " + text.substring(ix, nx));
|
||||
// ix = nx;
|
||||
// }
|
||||
// }
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.BreakIterator.hashCode()'
|
||||
*/
|
||||
public void testHashCode() {
|
||||
BreakIterator br = BreakIterator.getWordInstance();
|
||||
br.setText(text);
|
||||
BreakIterator brne = BreakIterator.getWordInstance();
|
||||
brne.setText(text + "X");
|
||||
wbr.first();
|
||||
testEHCS(br, wbr, brne);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.BreakIterator.BreakIterator(BreakIterator)'
|
||||
*/
|
||||
public void testBreakIterator() {
|
||||
// implicitly tested everywhere
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.BreakIterator.first()'
|
||||
*/
|
||||
public void testFirst() {
|
||||
assertEquals(0, cbr.first());
|
||||
assertEquals(0, wbr.first());
|
||||
assertEquals(0, lbr.first());
|
||||
assertEquals(0, sbr.first());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.BreakIterator.last()'
|
||||
*/
|
||||
public void testLast() {
|
||||
assertEquals(text.length(), cbr.last());
|
||||
assertEquals(text.length(), wbr.last());
|
||||
assertEquals(text.length(), lbr.last());
|
||||
assertEquals(text.length(), sbr.last());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.BreakIterator.next(int)'
|
||||
*/
|
||||
public void testNextInt() {
|
||||
cbr.first();
|
||||
wbr.first();
|
||||
lbr.first();
|
||||
sbr.first();
|
||||
assertEquals(2, cbr.next(2));
|
||||
assertEquals(3, wbr.next(2));
|
||||
assertEquals(8, lbr.next(2));
|
||||
assertEquals(62, sbr.next(2));
|
||||
|
||||
cbr.last();
|
||||
wbr.last();
|
||||
lbr.last();
|
||||
sbr.last();
|
||||
assertEquals(174, cbr.next(-2));
|
||||
assertEquals(171, wbr.next(-2));
|
||||
assertEquals(166, lbr.next(-2));
|
||||
assertEquals(135, sbr.next(-2));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.BreakIterator.next()'
|
||||
*/
|
||||
public void testNext() {
|
||||
cbr.first();
|
||||
wbr.first();
|
||||
lbr.first();
|
||||
sbr.first();
|
||||
assertEquals(1, cbr.next());
|
||||
assertEquals(2, wbr.next());
|
||||
assertEquals(4, lbr.next());
|
||||
assertEquals(13, sbr.next());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.BreakIterator.previous()'
|
||||
*/
|
||||
public void testPrevious() {
|
||||
cbr.last();
|
||||
wbr.last();
|
||||
lbr.last();
|
||||
sbr.last();
|
||||
assertEquals(175, cbr.previous());
|
||||
assertEquals(175, wbr.previous());
|
||||
assertEquals(171, lbr.previous());
|
||||
assertEquals(156, sbr.previous());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.BreakIterator.following(int)'
|
||||
*/
|
||||
public void testFollowing() {
|
||||
assertEquals(100, cbr.following(pos));
|
||||
assertEquals(103, wbr.following(pos));
|
||||
assertEquals(104, lbr.following(pos));
|
||||
assertEquals(116, sbr.following(pos));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.BreakIterator.preceding(int)'
|
||||
*/
|
||||
public void testPreceding() {
|
||||
assertEquals(98, cbr.preceding(pos));
|
||||
assertEquals(98, wbr.preceding(pos));
|
||||
assertEquals(97, lbr.preceding(pos));
|
||||
assertEquals(62, sbr.preceding(pos));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.BreakIterator.isBoundary(int)'
|
||||
*/
|
||||
public void testIsBoundary() {
|
||||
assertTrue(cbr.isBoundary(pos));
|
||||
assertFalse(wbr.isBoundary(pos));
|
||||
assertFalse(lbr.isBoundary(pos));
|
||||
assertFalse(sbr.isBoundary(pos));
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.BreakIterator.current()'
|
||||
*/
|
||||
public void testCurrent() {
|
||||
cbr.following(pos);
|
||||
wbr.following(pos);
|
||||
lbr.following(pos);
|
||||
sbr.following(pos);
|
||||
assertEquals(100, cbr.current());
|
||||
assertEquals(103, wbr.current());
|
||||
assertEquals(104, lbr.current());
|
||||
assertEquals(116, sbr.current());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.BreakIterator.getText()'
|
||||
*/
|
||||
public void testGetText() {
|
||||
CharacterIterator ci = cbr.getText();
|
||||
StringBuffer buf = new StringBuffer(ci.getEndIndex() - ci.getBeginIndex());
|
||||
for (char c = ci.first(); c != CharacterIterator.DONE; c = ci.next()) {
|
||||
buf.append(c);
|
||||
}
|
||||
String result = buf.toString();
|
||||
assertEquals(text, result);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.BreakIterator.setText(String)'
|
||||
*/
|
||||
public void testSetTextString() {
|
||||
// implicitly tested
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.BreakIterator.setText(CharacterIterator)'
|
||||
*/
|
||||
public void testSetTextCharacterIterator() {
|
||||
CharacterIterator ci = new StringCharacterIterator(text, pos);
|
||||
BreakIterator bi = BreakIterator.getWordInstance();
|
||||
bi.setText(ci);
|
||||
assertEquals(2, bi.next());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.BreakIterator.getWordInstance()'
|
||||
*/
|
||||
public void testGetWordInstance() {
|
||||
// implicitly tested
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.BreakIterator.getWordInstance(Locale)'
|
||||
*/
|
||||
public void testGetWordInstanceLocale() {
|
||||
assertNotNull(BreakIterator.getWordInstance(Locale.JAPAN));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.BreakIterator.getWordInstance(ULocale)'
|
||||
*/
|
||||
public void testGetWordInstanceULocale() {
|
||||
assertNotNull(BreakIterator.getWordInstance(ULocale.JAPAN));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.BreakIterator.getLineInstance()'
|
||||
*/
|
||||
public void testGetLineInstance() {
|
||||
// implicitly tested
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.BreakIterator.getLineInstance(Locale)'
|
||||
*/
|
||||
public void testGetLineInstanceLocale() {
|
||||
assertNotNull(BreakIterator.getLineInstance(Locale.JAPAN));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.BreakIterator.getLineInstance(ULocale)'
|
||||
*/
|
||||
public void testGetLineInstanceULocale() {
|
||||
assertNotNull(BreakIterator.getLineInstance(ULocale.JAPAN));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.BreakIterator.getCharacterInstance()'
|
||||
*/
|
||||
public void testGetCharacterInstance() {
|
||||
// implicitly tested
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.BreakIterator.getCharacterInstance(Locale)'
|
||||
*/
|
||||
public void testGetCharacterInstanceLocale() {
|
||||
assertNotNull(BreakIterator.getCharacterInstance(Locale.JAPAN));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.BreakIterator.getCharacterInstance(ULocale)'
|
||||
*/
|
||||
public void testGetCharacterInstanceULocale() {
|
||||
assertNotNull(BreakIterator.getCharacterInstance(ULocale.JAPAN));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.BreakIterator.getSentenceInstance()'
|
||||
*/
|
||||
public void testGetSentenceInstance() {
|
||||
// implicitly tested
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.BreakIterator.getSentenceInstance(Locale)'
|
||||
*/
|
||||
public void testGetSentenceInstanceLocale() {
|
||||
assertNotNull(BreakIterator.getSentenceInstance(Locale.JAPAN));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.BreakIterator.getSentenceInstance(ULocale)'
|
||||
*/
|
||||
public void testGetSentenceInstanceULocale() {
|
||||
assertNotNull(BreakIterator.getSentenceInstance(ULocale.JAPAN));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.BreakIterator.getTitleInstance()'
|
||||
*/
|
||||
public void testGetTitleInstance() {
|
||||
// not implemented
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.BreakIterator.getTitleInstance(Locale)'
|
||||
*/
|
||||
public void testGetTitleInstanceLocale() {
|
||||
// not implemented
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.BreakIterator.getTitleInstance(ULocale)'
|
||||
*/
|
||||
public void testGetTitleInstanceULocale() {
|
||||
// not implemented
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.BreakIterator.getAvailableLocales()'
|
||||
*/
|
||||
public void testGetAvailableLocales() {
|
||||
assertNotNull(BreakIterator.getAvailableLocales());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.BreakIterator.getAvailableULocales()'
|
||||
*/
|
||||
public void testGetAvailableULocales() {
|
||||
assertNotNull(BreakIterator.getAvailableULocales());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.BreakIterator.toString()'
|
||||
*/
|
||||
public void testToString() {
|
||||
assertNotNull(cbr.toString());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.BreakIterator.clone()'
|
||||
*/
|
||||
public void testClone() {
|
||||
// see testHashCode
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.BreakIterator.equals(Object)'
|
||||
*/
|
||||
public void testEqualsObject() {
|
||||
// see testHashCode
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,102 +1,102 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2006-2011, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
package com.ibm.icu.tests;
|
||||
|
||||
import com.ibm.icu.text.CollationKey;
|
||||
import com.ibm.icu.text.Collator;
|
||||
|
||||
public class CollationKeyTest extends ICUTestCase {
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.CollationKey.hashCode()'
|
||||
*/
|
||||
public void testHashCode() {
|
||||
Collator c = Collator.getInstance();
|
||||
c.setStrength(Collator.PRIMARY);
|
||||
CollationKey k1 = c.getCollationKey("This");
|
||||
CollationKey k2 = c.getCollationKey("this");
|
||||
c.setStrength(Collator.TERTIARY);
|
||||
CollationKey kn = c.getCollationKey("this");
|
||||
testEHCS(k1, k2, kn);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.CollationKey.CollationKey(CollationKey)'
|
||||
*/
|
||||
public void testCollationKey() {
|
||||
// implicitly tested everywhere
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.CollationKey.compareTo(CollationKey)'
|
||||
*/
|
||||
public void testCompareToCollationKey() {
|
||||
Collator c = Collator.getInstance();
|
||||
c.setStrength(Collator.PRIMARY);
|
||||
CollationKey k1 = c.getCollationKey("This");
|
||||
CollationKey k2 = c.getCollationKey("this");
|
||||
c.setStrength(Collator.TERTIARY);
|
||||
CollationKey k3 = c.getCollationKey("this");
|
||||
assertTrue(0 == k1.compareTo(k2));
|
||||
assertFalse(0 == k1.compareTo(k3));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.CollationKey.compareTo(Object)'
|
||||
*/
|
||||
public void testCompareToObject() {
|
||||
Collator c = Collator.getInstance();
|
||||
c.setStrength(Collator.PRIMARY);
|
||||
CollationKey k1 = c.getCollationKey("This");
|
||||
CollationKey k2 = c.getCollationKey("this");
|
||||
assertTrue(0 == k1.compareTo(k2));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.CollationKey.equals(Object)'
|
||||
*/
|
||||
public void testEqualsObject() {
|
||||
Collator c = Collator.getInstance();
|
||||
c.setStrength(Collator.PRIMARY);
|
||||
CollationKey k1 = c.getCollationKey("This");
|
||||
CollationKey k2 = c.getCollationKey("this");
|
||||
assertTrue(k1.equals((Object)k2));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.CollationKey.toString()'
|
||||
*/
|
||||
public void testToString() {
|
||||
Collator c = Collator.getInstance();
|
||||
c.setStrength(Collator.PRIMARY);
|
||||
CollationKey k1 = c.getCollationKey("This");
|
||||
assertNotNull(k1.toString());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.CollationKey.getSourceString()'
|
||||
*/
|
||||
public void testGetSourceString() {
|
||||
Collator c = Collator.getInstance();
|
||||
c.setStrength(Collator.PRIMARY);
|
||||
CollationKey k1 = c.getCollationKey("This");
|
||||
assertEquals("This", k1.getSourceString());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.CollationKey.toByteArray()'
|
||||
*/
|
||||
public void testToByteArray() {
|
||||
Collator c = Collator.getInstance();
|
||||
c.setStrength(Collator.PRIMARY);
|
||||
CollationKey k1 = c.getCollationKey("This");
|
||||
byte[] key = k1.toByteArray();
|
||||
assertNotNull(key);
|
||||
assertTrue(0 < key.length);
|
||||
}
|
||||
}
|
||||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2006-2011, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
package com.ibm.icu.tests;
|
||||
|
||||
import com.ibm.icu.text.CollationKey;
|
||||
import com.ibm.icu.text.Collator;
|
||||
|
||||
public class CollationKeyTest extends ICUTestCase {
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.CollationKey.hashCode()'
|
||||
*/
|
||||
public void testHashCode() {
|
||||
Collator c = Collator.getInstance();
|
||||
c.setStrength(Collator.PRIMARY);
|
||||
CollationKey k1 = c.getCollationKey("This");
|
||||
CollationKey k2 = c.getCollationKey("this");
|
||||
c.setStrength(Collator.TERTIARY);
|
||||
CollationKey kn = c.getCollationKey("this");
|
||||
testEHCS(k1, k2, kn);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.CollationKey.CollationKey(CollationKey)'
|
||||
*/
|
||||
public void testCollationKey() {
|
||||
// implicitly tested everywhere
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.CollationKey.compareTo(CollationKey)'
|
||||
*/
|
||||
public void testCompareToCollationKey() {
|
||||
Collator c = Collator.getInstance();
|
||||
c.setStrength(Collator.PRIMARY);
|
||||
CollationKey k1 = c.getCollationKey("This");
|
||||
CollationKey k2 = c.getCollationKey("this");
|
||||
c.setStrength(Collator.TERTIARY);
|
||||
CollationKey k3 = c.getCollationKey("this");
|
||||
assertTrue(0 == k1.compareTo(k2));
|
||||
assertFalse(0 == k1.compareTo(k3));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.CollationKey.compareTo(Object)'
|
||||
*/
|
||||
public void testCompareToObject() {
|
||||
Collator c = Collator.getInstance();
|
||||
c.setStrength(Collator.PRIMARY);
|
||||
CollationKey k1 = c.getCollationKey("This");
|
||||
CollationKey k2 = c.getCollationKey("this");
|
||||
assertTrue(0 == k1.compareTo(k2));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.CollationKey.equals(Object)'
|
||||
*/
|
||||
public void testEqualsObject() {
|
||||
Collator c = Collator.getInstance();
|
||||
c.setStrength(Collator.PRIMARY);
|
||||
CollationKey k1 = c.getCollationKey("This");
|
||||
CollationKey k2 = c.getCollationKey("this");
|
||||
assertTrue(k1.equals((Object)k2));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.CollationKey.toString()'
|
||||
*/
|
||||
public void testToString() {
|
||||
Collator c = Collator.getInstance();
|
||||
c.setStrength(Collator.PRIMARY);
|
||||
CollationKey k1 = c.getCollationKey("This");
|
||||
assertNotNull(k1.toString());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.CollationKey.getSourceString()'
|
||||
*/
|
||||
public void testGetSourceString() {
|
||||
Collator c = Collator.getInstance();
|
||||
c.setStrength(Collator.PRIMARY);
|
||||
CollationKey k1 = c.getCollationKey("This");
|
||||
assertEquals("This", k1.getSourceString());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.CollationKey.toByteArray()'
|
||||
*/
|
||||
public void testToByteArray() {
|
||||
Collator c = Collator.getInstance();
|
||||
c.setStrength(Collator.PRIMARY);
|
||||
CollationKey k1 = c.getCollationKey("This");
|
||||
byte[] key = k1.toByteArray();
|
||||
assertNotNull(key);
|
||||
assertTrue(0 < key.length);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,205 +1,205 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2006-2011, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
package com.ibm.icu.tests;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import com.ibm.icu.text.CollationKey;
|
||||
import com.ibm.icu.text.Collator;
|
||||
import com.ibm.icu.util.ULocale;
|
||||
|
||||
public class CollatorTest extends ICUTestCase {
|
||||
private static final String s1 = "Fu\u0308nf"; // capital F + u + diaresis
|
||||
private static final String s2 = "fu\u0308nf"; // u + diaresis
|
||||
private static final String s3 = "f\u00fcnf"; // u-umlaut
|
||||
private static final String s4 = "fu\u0308\u0316nf"; // u + diaresis above + grave below
|
||||
private static final String s5 = "fu\u0316\u0308nf"; // u + grave below + diaresis above
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.Collator.hashCode()'
|
||||
*/
|
||||
public void testHashCode() {
|
||||
Collator c = Collator.getInstance();
|
||||
c.setStrength(Collator.SECONDARY);
|
||||
Collator c2 = Collator.getInstance();
|
||||
c2.setStrength(Collator.SECONDARY);
|
||||
Collator cn = Collator.getInstance();
|
||||
cn.setStrength(Collator.TERTIARY);
|
||||
testEHCS(c, c2, cn);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.Collator.Collator(Collator)'
|
||||
*/
|
||||
public void testCollator() {
|
||||
// implicitly tested everywhere
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.Collator.setStrength(int)'
|
||||
*/
|
||||
public void testSetStrength() {
|
||||
Collator c = Collator.getInstance();
|
||||
c.setStrength(Collator.PRIMARY);
|
||||
assertTrue(0 == c.compare(s1, s2));
|
||||
c.setStrength(Collator.SECONDARY);
|
||||
assertTrue(0 == c.compare(s1, s2));
|
||||
c.setStrength(Collator.TERTIARY);
|
||||
assertTrue(0 < c.compare(s1, s2));
|
||||
assertTrue(0 == c.compare(s2, s3));
|
||||
c.setStrength(Collator.QUATERNARY);
|
||||
assertTrue(0 > c.compare(s2, s3));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.Collator.setDecomposition(int)'
|
||||
*/
|
||||
public void testSetDecomposition() {
|
||||
Collator c = Collator.getInstance();
|
||||
c.setStrength(Collator.TERTIARY);
|
||||
assertTrue(0 != c.compare(s4, s5));
|
||||
c.setDecomposition(Collator.IDENTICAL);
|
||||
assertTrue(0 == c.compare(s4, s5));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.Collator.getInstance()'
|
||||
*/
|
||||
public void testGetInstance() {
|
||||
// implicitly tested everywhere
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.Collator.getInstance(ULocale)'
|
||||
*/
|
||||
public void testGetInstanceULocale() {
|
||||
Collator c = Collator.getInstance(ULocale.GERMANY);
|
||||
assertNotNull(c);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.Collator.getInstance(Locale)'
|
||||
*/
|
||||
public void testGetInstanceLocale() {
|
||||
Collator c = Collator.getInstance(Locale.GERMANY);
|
||||
assertNotNull(c);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.Collator.getAvailableLocales()'
|
||||
*/
|
||||
public void testGetAvailableLocales() {
|
||||
assertNotNull(Collator.getAvailableLocales());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.Collator.getAvailableULocales()'
|
||||
*/
|
||||
public void testGetAvailableULocales() {
|
||||
assertNotNull(Collator.getAvailableULocales());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.Collator.getKeywords()'
|
||||
*/
|
||||
public void testGetKeywords() {
|
||||
assertEquals(0, Collator.getKeywords().length);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.Collator.getKeywordValues(String)'
|
||||
*/
|
||||
public void testGetKeywordValues() {
|
||||
assertEquals(0, Collator.getKeywordValues("").length);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.Collator.getStrength()'
|
||||
*/
|
||||
public void testGetStrength() {
|
||||
Collator c = Collator.getInstance();
|
||||
c.setStrength(Collator.PRIMARY);
|
||||
assertEquals(Collator.PRIMARY, c.getStrength());
|
||||
c.setStrength(Collator.SECONDARY);
|
||||
assertEquals(Collator.SECONDARY, c.getStrength());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.Collator.getDecomposition()'
|
||||
*/
|
||||
public void testGetDecomposition() {
|
||||
Collator c = Collator.getInstance();
|
||||
c.setDecomposition(Collator.CANONICAL_DECOMPOSITION);
|
||||
assertEquals(Collator.CANONICAL_DECOMPOSITION, c.getDecomposition());
|
||||
c.setDecomposition(Collator.NO_DECOMPOSITION);
|
||||
assertEquals(Collator.NO_DECOMPOSITION, c.getDecomposition());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.Collator.compare(Object, Object)'
|
||||
*/
|
||||
public void testCompareObjectObject() {
|
||||
Collator c = Collator.getInstance();
|
||||
c.setStrength(Collator.PRIMARY);
|
||||
assertTrue(0 == c.compare((Object)s1, (Object)s2));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.Collator.equals(String, String)'
|
||||
*/
|
||||
public void testEqualsStringString() {
|
||||
Collator c = Collator.getInstance();
|
||||
c.setStrength(Collator.PRIMARY);
|
||||
assertTrue(c.equals(s1, s2));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.Collator.compare(String, String)'
|
||||
*/
|
||||
public void testCompareStringString() {
|
||||
Collator c = Collator.getInstance();
|
||||
c.setStrength(Collator.PRIMARY);
|
||||
assertTrue(0 == c.compare(s1, s2));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.Collator.getCollationKey(String)'
|
||||
*/
|
||||
public void testGetCollationKey() {
|
||||
Collator c = Collator.getInstance();
|
||||
c.setStrength(Collator.PRIMARY);
|
||||
CollationKey k1 = c.getCollationKey(s1);
|
||||
CollationKey k2 = c.getCollationKey(s2);
|
||||
assertTrue(k1.equals(k2));
|
||||
c.setStrength(Collator.TERTIARY);
|
||||
k1 = c.getCollationKey(s1);
|
||||
k2 = c.getCollationKey(s2);
|
||||
assertFalse(k1.equals(k2));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.Collator.toString()'
|
||||
*/
|
||||
public void testToString() {
|
||||
assertNotNull(Collator.getInstance().toString());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.Collator.clone()'
|
||||
*/
|
||||
public void testClone() {
|
||||
// tested above
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.Collator.equals(Object)'
|
||||
*/
|
||||
public void testEqualsObject() {
|
||||
// tested above
|
||||
}
|
||||
}
|
||||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2006-2011, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
package com.ibm.icu.tests;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import com.ibm.icu.text.CollationKey;
|
||||
import com.ibm.icu.text.Collator;
|
||||
import com.ibm.icu.util.ULocale;
|
||||
|
||||
public class CollatorTest extends ICUTestCase {
|
||||
private static final String s1 = "Fu\u0308nf"; // capital F + u + diaresis
|
||||
private static final String s2 = "fu\u0308nf"; // u + diaresis
|
||||
private static final String s3 = "f\u00fcnf"; // u-umlaut
|
||||
private static final String s4 = "fu\u0308\u0316nf"; // u + diaresis above + grave below
|
||||
private static final String s5 = "fu\u0316\u0308nf"; // u + grave below + diaresis above
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.Collator.hashCode()'
|
||||
*/
|
||||
public void testHashCode() {
|
||||
Collator c = Collator.getInstance();
|
||||
c.setStrength(Collator.SECONDARY);
|
||||
Collator c2 = Collator.getInstance();
|
||||
c2.setStrength(Collator.SECONDARY);
|
||||
Collator cn = Collator.getInstance();
|
||||
cn.setStrength(Collator.TERTIARY);
|
||||
testEHCS(c, c2, cn);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.Collator.Collator(Collator)'
|
||||
*/
|
||||
public void testCollator() {
|
||||
// implicitly tested everywhere
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.Collator.setStrength(int)'
|
||||
*/
|
||||
public void testSetStrength() {
|
||||
Collator c = Collator.getInstance();
|
||||
c.setStrength(Collator.PRIMARY);
|
||||
assertTrue(0 == c.compare(s1, s2));
|
||||
c.setStrength(Collator.SECONDARY);
|
||||
assertTrue(0 == c.compare(s1, s2));
|
||||
c.setStrength(Collator.TERTIARY);
|
||||
assertTrue(0 < c.compare(s1, s2));
|
||||
assertTrue(0 == c.compare(s2, s3));
|
||||
c.setStrength(Collator.QUATERNARY);
|
||||
assertTrue(0 > c.compare(s2, s3));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.Collator.setDecomposition(int)'
|
||||
*/
|
||||
public void testSetDecomposition() {
|
||||
Collator c = Collator.getInstance();
|
||||
c.setStrength(Collator.TERTIARY);
|
||||
assertTrue(0 != c.compare(s4, s5));
|
||||
c.setDecomposition(Collator.IDENTICAL);
|
||||
assertTrue(0 == c.compare(s4, s5));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.Collator.getInstance()'
|
||||
*/
|
||||
public void testGetInstance() {
|
||||
// implicitly tested everywhere
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.Collator.getInstance(ULocale)'
|
||||
*/
|
||||
public void testGetInstanceULocale() {
|
||||
Collator c = Collator.getInstance(ULocale.GERMANY);
|
||||
assertNotNull(c);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.Collator.getInstance(Locale)'
|
||||
*/
|
||||
public void testGetInstanceLocale() {
|
||||
Collator c = Collator.getInstance(Locale.GERMANY);
|
||||
assertNotNull(c);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.Collator.getAvailableLocales()'
|
||||
*/
|
||||
public void testGetAvailableLocales() {
|
||||
assertNotNull(Collator.getAvailableLocales());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.Collator.getAvailableULocales()'
|
||||
*/
|
||||
public void testGetAvailableULocales() {
|
||||
assertNotNull(Collator.getAvailableULocales());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.Collator.getKeywords()'
|
||||
*/
|
||||
public void testGetKeywords() {
|
||||
assertEquals(0, Collator.getKeywords().length);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.Collator.getKeywordValues(String)'
|
||||
*/
|
||||
public void testGetKeywordValues() {
|
||||
assertEquals(0, Collator.getKeywordValues("").length);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.Collator.getStrength()'
|
||||
*/
|
||||
public void testGetStrength() {
|
||||
Collator c = Collator.getInstance();
|
||||
c.setStrength(Collator.PRIMARY);
|
||||
assertEquals(Collator.PRIMARY, c.getStrength());
|
||||
c.setStrength(Collator.SECONDARY);
|
||||
assertEquals(Collator.SECONDARY, c.getStrength());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.Collator.getDecomposition()'
|
||||
*/
|
||||
public void testGetDecomposition() {
|
||||
Collator c = Collator.getInstance();
|
||||
c.setDecomposition(Collator.CANONICAL_DECOMPOSITION);
|
||||
assertEquals(Collator.CANONICAL_DECOMPOSITION, c.getDecomposition());
|
||||
c.setDecomposition(Collator.NO_DECOMPOSITION);
|
||||
assertEquals(Collator.NO_DECOMPOSITION, c.getDecomposition());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.Collator.compare(Object, Object)'
|
||||
*/
|
||||
public void testCompareObjectObject() {
|
||||
Collator c = Collator.getInstance();
|
||||
c.setStrength(Collator.PRIMARY);
|
||||
assertTrue(0 == c.compare((Object)s1, (Object)s2));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.Collator.equals(String, String)'
|
||||
*/
|
||||
public void testEqualsStringString() {
|
||||
Collator c = Collator.getInstance();
|
||||
c.setStrength(Collator.PRIMARY);
|
||||
assertTrue(c.equals(s1, s2));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.Collator.compare(String, String)'
|
||||
*/
|
||||
public void testCompareStringString() {
|
||||
Collator c = Collator.getInstance();
|
||||
c.setStrength(Collator.PRIMARY);
|
||||
assertTrue(0 == c.compare(s1, s2));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.Collator.getCollationKey(String)'
|
||||
*/
|
||||
public void testGetCollationKey() {
|
||||
Collator c = Collator.getInstance();
|
||||
c.setStrength(Collator.PRIMARY);
|
||||
CollationKey k1 = c.getCollationKey(s1);
|
||||
CollationKey k2 = c.getCollationKey(s2);
|
||||
assertTrue(k1.equals(k2));
|
||||
c.setStrength(Collator.TERTIARY);
|
||||
k1 = c.getCollationKey(s1);
|
||||
k2 = c.getCollationKey(s2);
|
||||
assertFalse(k1.equals(k2));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.Collator.toString()'
|
||||
*/
|
||||
public void testToString() {
|
||||
assertNotNull(Collator.getInstance().toString());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.Collator.clone()'
|
||||
*/
|
||||
public void testClone() {
|
||||
// tested above
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.Collator.equals(Object)'
|
||||
*/
|
||||
public void testEqualsObject() {
|
||||
// tested above
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,257 +1,257 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2006-2011, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
package com.ibm.icu.tests;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import com.ibm.icu.text.DateFormatSymbols;
|
||||
import com.ibm.icu.util.ULocale;
|
||||
|
||||
public class DateFormatSymbolsTest extends ICUTestCase {
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormatSymbols.hashCode()'
|
||||
*/
|
||||
public void testHashCode() {
|
||||
DateFormatSymbols dfs = new DateFormatSymbols(Locale.US);
|
||||
DateFormatSymbols dfs2 = new DateFormatSymbols(ULocale.US);
|
||||
DateFormatSymbols dfsn = new DateFormatSymbols(Locale.US);
|
||||
dfsn.setAmPmStrings(new String[] { "sw", "xw" });
|
||||
testEHCS(dfs, dfs2, dfsn);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormatSymbols.DateFormatSymbols(DateFormatSymbols)'
|
||||
*/
|
||||
public void testDateFormatSymbolsDateFormatSymbols() {
|
||||
// implicitly tested everywhere
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormatSymbols.DateFormatSymbols()'
|
||||
*/
|
||||
public void testDateFormatSymbols() {
|
||||
DateFormatSymbols dfs = new DateFormatSymbols();
|
||||
assertNotNull(dfs.getWeekdays());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormatSymbols.DateFormatSymbols(Locale)'
|
||||
*/
|
||||
public void testDateFormatSymbolsLocale() {
|
||||
DateFormatSymbols dfs = new DateFormatSymbols(Locale.US);
|
||||
assertNotNull(dfs.getWeekdays());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormatSymbols.DateFormatSymbols(ULocale)'
|
||||
*/
|
||||
public void testDateFormatSymbolsULocale() {
|
||||
DateFormatSymbols dfs = new DateFormatSymbols(ULocale.US);
|
||||
assertNotNull(dfs.getWeekdays());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormatSymbols.getEras()'
|
||||
*/
|
||||
public void testGetEras() {
|
||||
DateFormatSymbols dfs = new DateFormatSymbols(Locale.US);
|
||||
assertNotNull(dfs.getEras());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormatSymbols.setEras(String[])'
|
||||
*/
|
||||
public void testSetEras() {
|
||||
DateFormatSymbols dfs = new DateFormatSymbols(Locale.US);
|
||||
String[] oldvalue = dfs.getEras();
|
||||
String[] newvalue = (String[])oldvalue.clone();
|
||||
newvalue[0] = newvalue[0] + "!";
|
||||
dfs.setEras(newvalue);
|
||||
String[] result = dfs.getEras();
|
||||
assertArraysNotEqual(oldvalue, result);
|
||||
assertArraysEqual(newvalue, result);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormatSymbols.getMonths()'
|
||||
*/
|
||||
public void testGetMonths() {
|
||||
DateFormatSymbols dfs = new DateFormatSymbols(Locale.US);
|
||||
assertNotNull(dfs.getMonths());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormatSymbols.setMonths(String[])'
|
||||
*/
|
||||
public void testSetMonths() {
|
||||
DateFormatSymbols dfs = new DateFormatSymbols(Locale.US);
|
||||
String[] oldvalue = dfs.getMonths();
|
||||
String[] newvalue = (String[])oldvalue.clone();
|
||||
newvalue[0] = newvalue[0] + "!";
|
||||
dfs.setMonths(newvalue);
|
||||
String[] result = dfs.getMonths();
|
||||
assertArraysNotEqual(oldvalue, result);
|
||||
assertArraysEqual(newvalue, result);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormatSymbols.getShortMonths()'
|
||||
*/
|
||||
public void testGetShortMonths() {
|
||||
DateFormatSymbols dfs = new DateFormatSymbols(Locale.US);
|
||||
assertNotNull(dfs.getShortMonths());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormatSymbols.setShortMonths(String[])'
|
||||
*/
|
||||
public void testSetShortMonths() {
|
||||
DateFormatSymbols dfs = new DateFormatSymbols(Locale.US);
|
||||
String[] oldvalue = dfs.getShortMonths();
|
||||
String[] newvalue = (String[])oldvalue.clone();
|
||||
newvalue[0] = newvalue[0] + "!";
|
||||
dfs.setShortMonths(newvalue);
|
||||
String[] result = dfs.getShortMonths();
|
||||
assertArraysNotEqual(oldvalue, result);
|
||||
assertArraysEqual(newvalue, result);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormatSymbols.getWeekdays()'
|
||||
*/
|
||||
public void testGetWeekdays() {
|
||||
DateFormatSymbols dfs = new DateFormatSymbols(Locale.US);
|
||||
assertNotNull(dfs.getShortMonths());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormatSymbols.setWeekdays(String[])'
|
||||
*/
|
||||
public void testSetWeekdays() {
|
||||
DateFormatSymbols dfs = new DateFormatSymbols(Locale.US);
|
||||
String[] oldvalue = dfs.getWeekdays();
|
||||
String[] newvalue = (String[])oldvalue.clone();
|
||||
newvalue[0] = newvalue[0] + "!";
|
||||
dfs.setWeekdays(newvalue);
|
||||
String[] result = dfs.getWeekdays();
|
||||
assertArraysNotEqual(oldvalue, result);
|
||||
assertArraysEqual(newvalue, result);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormatSymbols.getShortWeekdays()'
|
||||
*/
|
||||
public void testGetShortWeekdays() {
|
||||
DateFormatSymbols dfs = new DateFormatSymbols(Locale.US);
|
||||
assertNotNull(dfs.getShortWeekdays());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormatSymbols.setShortWeekdays(String[])'
|
||||
*/
|
||||
public void testSetShortWeekdays() {
|
||||
DateFormatSymbols dfs = new DateFormatSymbols(Locale.US);
|
||||
String[] oldvalue = dfs.getShortWeekdays();
|
||||
String[] newvalue = (String[])oldvalue.clone();
|
||||
newvalue[0] = newvalue[0] + "!";
|
||||
dfs.setShortWeekdays(newvalue);
|
||||
String[] result = dfs.getShortWeekdays();
|
||||
assertArraysNotEqual(oldvalue, result);
|
||||
assertArraysEqual(newvalue, result);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormatSymbols.getAmPmStrings()'
|
||||
*/
|
||||
public void testGetAmPmStrings() {
|
||||
DateFormatSymbols dfs = new DateFormatSymbols(Locale.US);
|
||||
assertNotNull(dfs.getAmPmStrings());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormatSymbols.setAmPmStrings(String[])'
|
||||
*/
|
||||
public void testSetAmPmStrings() {
|
||||
DateFormatSymbols dfs = new DateFormatSymbols(Locale.US);
|
||||
String[] oldvalue = dfs.getAmPmStrings();
|
||||
String[] newvalue = (String[])oldvalue.clone();
|
||||
newvalue[0] = newvalue[0] + "!";
|
||||
dfs.setAmPmStrings(newvalue);
|
||||
String[] result = dfs.getAmPmStrings();
|
||||
assertArraysNotEqual(oldvalue, result);
|
||||
assertArraysEqual(newvalue, result);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormatSymbols.getZoneStrings()'
|
||||
*/
|
||||
public void testGetZoneStrings() {
|
||||
DateFormatSymbols dfs = new DateFormatSymbols(Locale.US);
|
||||
assertNotNull(dfs.getZoneStrings());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormatSymbols.setZoneStrings(String[][])'
|
||||
*/
|
||||
public void testSetZoneStrings() {
|
||||
DateFormatSymbols dfs = new DateFormatSymbols(Locale.US);
|
||||
String[][] oldvalue = dfs.getZoneStrings();
|
||||
String[][] newvalue = (String[][])cloneComplex(oldvalue);
|
||||
newvalue[0][0] = newvalue[0][0] + "!";
|
||||
dfs.setZoneStrings(newvalue);
|
||||
String[][] result = dfs.getZoneStrings();
|
||||
assertArraysNotEqual(oldvalue, result);
|
||||
assertArraysEqual(newvalue, result);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormatSymbols.getLocalPatternChars()'
|
||||
*/
|
||||
public void testGetLocalPatternChars() {
|
||||
DateFormatSymbols dfs = new DateFormatSymbols(Locale.US);
|
||||
assertNotNull(dfs.getLocalPatternChars());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormatSymbols.setLocalPatternChars(String)'
|
||||
*/
|
||||
public void testSetLocalPatternChars() {
|
||||
DateFormatSymbols dfs = new DateFormatSymbols(Locale.US);
|
||||
String pat = dfs.getLocalPatternChars();
|
||||
StringBuffer buf = new StringBuffer(pat);
|
||||
buf.setCharAt(0, (char)(pat.charAt(0) + 1));
|
||||
String pat2 = buf.toString();
|
||||
dfs.setLocalPatternChars(pat2);
|
||||
String pat3 = dfs.getLocalPatternChars();
|
||||
assertNotEqual(pat, pat2);
|
||||
assertEquals(pat2, pat3);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormatSymbols.toString()'
|
||||
*/
|
||||
public void testToString() {
|
||||
DateFormatSymbols dfs = new DateFormatSymbols(Locale.US);
|
||||
assertNotNull(dfs.toString());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormatSymbols.clone()'
|
||||
*/
|
||||
public void testClone() {
|
||||
// tested by testHashCode
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormatSymbols.equals(Object)'
|
||||
*/
|
||||
public void testEqualsObject() {
|
||||
// tested by testHashCode
|
||||
}
|
||||
}
|
||||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2006-2011, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
package com.ibm.icu.tests;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import com.ibm.icu.text.DateFormatSymbols;
|
||||
import com.ibm.icu.util.ULocale;
|
||||
|
||||
public class DateFormatSymbolsTest extends ICUTestCase {
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormatSymbols.hashCode()'
|
||||
*/
|
||||
public void testHashCode() {
|
||||
DateFormatSymbols dfs = new DateFormatSymbols(Locale.US);
|
||||
DateFormatSymbols dfs2 = new DateFormatSymbols(ULocale.US);
|
||||
DateFormatSymbols dfsn = new DateFormatSymbols(Locale.US);
|
||||
dfsn.setAmPmStrings(new String[] { "sw", "xw" });
|
||||
testEHCS(dfs, dfs2, dfsn);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormatSymbols.DateFormatSymbols(DateFormatSymbols)'
|
||||
*/
|
||||
public void testDateFormatSymbolsDateFormatSymbols() {
|
||||
// implicitly tested everywhere
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormatSymbols.DateFormatSymbols()'
|
||||
*/
|
||||
public void testDateFormatSymbols() {
|
||||
DateFormatSymbols dfs = new DateFormatSymbols();
|
||||
assertNotNull(dfs.getWeekdays());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormatSymbols.DateFormatSymbols(Locale)'
|
||||
*/
|
||||
public void testDateFormatSymbolsLocale() {
|
||||
DateFormatSymbols dfs = new DateFormatSymbols(Locale.US);
|
||||
assertNotNull(dfs.getWeekdays());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormatSymbols.DateFormatSymbols(ULocale)'
|
||||
*/
|
||||
public void testDateFormatSymbolsULocale() {
|
||||
DateFormatSymbols dfs = new DateFormatSymbols(ULocale.US);
|
||||
assertNotNull(dfs.getWeekdays());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormatSymbols.getEras()'
|
||||
*/
|
||||
public void testGetEras() {
|
||||
DateFormatSymbols dfs = new DateFormatSymbols(Locale.US);
|
||||
assertNotNull(dfs.getEras());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormatSymbols.setEras(String[])'
|
||||
*/
|
||||
public void testSetEras() {
|
||||
DateFormatSymbols dfs = new DateFormatSymbols(Locale.US);
|
||||
String[] oldvalue = dfs.getEras();
|
||||
String[] newvalue = (String[])oldvalue.clone();
|
||||
newvalue[0] = newvalue[0] + "!";
|
||||
dfs.setEras(newvalue);
|
||||
String[] result = dfs.getEras();
|
||||
assertArraysNotEqual(oldvalue, result);
|
||||
assertArraysEqual(newvalue, result);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormatSymbols.getMonths()'
|
||||
*/
|
||||
public void testGetMonths() {
|
||||
DateFormatSymbols dfs = new DateFormatSymbols(Locale.US);
|
||||
assertNotNull(dfs.getMonths());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormatSymbols.setMonths(String[])'
|
||||
*/
|
||||
public void testSetMonths() {
|
||||
DateFormatSymbols dfs = new DateFormatSymbols(Locale.US);
|
||||
String[] oldvalue = dfs.getMonths();
|
||||
String[] newvalue = (String[])oldvalue.clone();
|
||||
newvalue[0] = newvalue[0] + "!";
|
||||
dfs.setMonths(newvalue);
|
||||
String[] result = dfs.getMonths();
|
||||
assertArraysNotEqual(oldvalue, result);
|
||||
assertArraysEqual(newvalue, result);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormatSymbols.getShortMonths()'
|
||||
*/
|
||||
public void testGetShortMonths() {
|
||||
DateFormatSymbols dfs = new DateFormatSymbols(Locale.US);
|
||||
assertNotNull(dfs.getShortMonths());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormatSymbols.setShortMonths(String[])'
|
||||
*/
|
||||
public void testSetShortMonths() {
|
||||
DateFormatSymbols dfs = new DateFormatSymbols(Locale.US);
|
||||
String[] oldvalue = dfs.getShortMonths();
|
||||
String[] newvalue = (String[])oldvalue.clone();
|
||||
newvalue[0] = newvalue[0] + "!";
|
||||
dfs.setShortMonths(newvalue);
|
||||
String[] result = dfs.getShortMonths();
|
||||
assertArraysNotEqual(oldvalue, result);
|
||||
assertArraysEqual(newvalue, result);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormatSymbols.getWeekdays()'
|
||||
*/
|
||||
public void testGetWeekdays() {
|
||||
DateFormatSymbols dfs = new DateFormatSymbols(Locale.US);
|
||||
assertNotNull(dfs.getShortMonths());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormatSymbols.setWeekdays(String[])'
|
||||
*/
|
||||
public void testSetWeekdays() {
|
||||
DateFormatSymbols dfs = new DateFormatSymbols(Locale.US);
|
||||
String[] oldvalue = dfs.getWeekdays();
|
||||
String[] newvalue = (String[])oldvalue.clone();
|
||||
newvalue[0] = newvalue[0] + "!";
|
||||
dfs.setWeekdays(newvalue);
|
||||
String[] result = dfs.getWeekdays();
|
||||
assertArraysNotEqual(oldvalue, result);
|
||||
assertArraysEqual(newvalue, result);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormatSymbols.getShortWeekdays()'
|
||||
*/
|
||||
public void testGetShortWeekdays() {
|
||||
DateFormatSymbols dfs = new DateFormatSymbols(Locale.US);
|
||||
assertNotNull(dfs.getShortWeekdays());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormatSymbols.setShortWeekdays(String[])'
|
||||
*/
|
||||
public void testSetShortWeekdays() {
|
||||
DateFormatSymbols dfs = new DateFormatSymbols(Locale.US);
|
||||
String[] oldvalue = dfs.getShortWeekdays();
|
||||
String[] newvalue = (String[])oldvalue.clone();
|
||||
newvalue[0] = newvalue[0] + "!";
|
||||
dfs.setShortWeekdays(newvalue);
|
||||
String[] result = dfs.getShortWeekdays();
|
||||
assertArraysNotEqual(oldvalue, result);
|
||||
assertArraysEqual(newvalue, result);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormatSymbols.getAmPmStrings()'
|
||||
*/
|
||||
public void testGetAmPmStrings() {
|
||||
DateFormatSymbols dfs = new DateFormatSymbols(Locale.US);
|
||||
assertNotNull(dfs.getAmPmStrings());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormatSymbols.setAmPmStrings(String[])'
|
||||
*/
|
||||
public void testSetAmPmStrings() {
|
||||
DateFormatSymbols dfs = new DateFormatSymbols(Locale.US);
|
||||
String[] oldvalue = dfs.getAmPmStrings();
|
||||
String[] newvalue = (String[])oldvalue.clone();
|
||||
newvalue[0] = newvalue[0] + "!";
|
||||
dfs.setAmPmStrings(newvalue);
|
||||
String[] result = dfs.getAmPmStrings();
|
||||
assertArraysNotEqual(oldvalue, result);
|
||||
assertArraysEqual(newvalue, result);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormatSymbols.getZoneStrings()'
|
||||
*/
|
||||
public void testGetZoneStrings() {
|
||||
DateFormatSymbols dfs = new DateFormatSymbols(Locale.US);
|
||||
assertNotNull(dfs.getZoneStrings());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormatSymbols.setZoneStrings(String[][])'
|
||||
*/
|
||||
public void testSetZoneStrings() {
|
||||
DateFormatSymbols dfs = new DateFormatSymbols(Locale.US);
|
||||
String[][] oldvalue = dfs.getZoneStrings();
|
||||
String[][] newvalue = (String[][])cloneComplex(oldvalue);
|
||||
newvalue[0][0] = newvalue[0][0] + "!";
|
||||
dfs.setZoneStrings(newvalue);
|
||||
String[][] result = dfs.getZoneStrings();
|
||||
assertArraysNotEqual(oldvalue, result);
|
||||
assertArraysEqual(newvalue, result);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormatSymbols.getLocalPatternChars()'
|
||||
*/
|
||||
public void testGetLocalPatternChars() {
|
||||
DateFormatSymbols dfs = new DateFormatSymbols(Locale.US);
|
||||
assertNotNull(dfs.getLocalPatternChars());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormatSymbols.setLocalPatternChars(String)'
|
||||
*/
|
||||
public void testSetLocalPatternChars() {
|
||||
DateFormatSymbols dfs = new DateFormatSymbols(Locale.US);
|
||||
String pat = dfs.getLocalPatternChars();
|
||||
StringBuffer buf = new StringBuffer(pat);
|
||||
buf.setCharAt(0, (char)(pat.charAt(0) + 1));
|
||||
String pat2 = buf.toString();
|
||||
dfs.setLocalPatternChars(pat2);
|
||||
String pat3 = dfs.getLocalPatternChars();
|
||||
assertNotEqual(pat, pat2);
|
||||
assertEquals(pat2, pat3);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormatSymbols.toString()'
|
||||
*/
|
||||
public void testToString() {
|
||||
DateFormatSymbols dfs = new DateFormatSymbols(Locale.US);
|
||||
assertNotNull(dfs.toString());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormatSymbols.clone()'
|
||||
*/
|
||||
public void testClone() {
|
||||
// tested by testHashCode
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormatSymbols.equals(Object)'
|
||||
*/
|
||||
public void testEqualsObject() {
|
||||
// tested by testHashCode
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,454 +1,454 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2006-2011, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
package com.ibm.icu.tests;
|
||||
|
||||
import java.text.FieldPosition;
|
||||
import java.text.ParseException;
|
||||
import java.text.ParsePosition;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
|
||||
import com.ibm.icu.text.DateFormat;
|
||||
import com.ibm.icu.text.NumberFormat;
|
||||
import com.ibm.icu.util.Calendar;
|
||||
import com.ibm.icu.util.TimeZone;
|
||||
import com.ibm.icu.util.ULocale;
|
||||
|
||||
public class DateFormatTest extends ICUTestCase {
|
||||
private Calendar aCal;
|
||||
private Calendar anESTCal;
|
||||
private Date aDate;
|
||||
private String aDateString;
|
||||
private String aTimeString;
|
||||
private String anESTTimeString;
|
||||
private String aDateTimeString;
|
||||
private String aShortDateTimeString;
|
||||
private String aDefaultESTDateTimeString;
|
||||
private DateFormat aDF;
|
||||
private StringBuffer aBuf;
|
||||
private FieldPosition anFP;
|
||||
private FieldPosition anFPField;
|
||||
|
||||
private static int YEAR_POS_START = 8;
|
||||
private static int YEAR_POS_END = 12;
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
|
||||
java.util.GregorianCalendar gcal = new java.util.GregorianCalendar();
|
||||
gcal.clear();
|
||||
gcal.set(java.util.GregorianCalendar.YEAR, 1990);
|
||||
gcal.set(java.util.GregorianCalendar.MONTH, java.util.GregorianCalendar.DECEMBER);
|
||||
gcal.set(java.util.GregorianCalendar.DATE, 17);
|
||||
gcal.set(java.util.GregorianCalendar.HOUR, 5);
|
||||
gcal.set(java.util.GregorianCalendar.MINUTE, 17);
|
||||
aCal = new Calendar(gcal);
|
||||
anESTCal = Calendar.getInstance();
|
||||
anESTCal.setTimeZone(TimeZone.getTimeZone("EST"));
|
||||
aDate = gcal.getTime();
|
||||
aDateString = "Dec 17, 1990"; // medium -- the default
|
||||
aTimeString = "5:17:00 AM"; // medium
|
||||
anESTTimeString = "8:17:00 AM";
|
||||
aDateTimeString = "Dec 17, 1990 5:17:00 AM"; // medium, medium
|
||||
aDefaultESTDateTimeString = "Dec 17, 1990 8:17 AM"; // medium, short -- the default
|
||||
aShortDateTimeString = "12/17/90 5:17 AM"; // short, short
|
||||
aDF = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM, Locale.US);
|
||||
aBuf = new StringBuffer();
|
||||
anFP = new FieldPosition(DateFormat.YEAR_FIELD);
|
||||
anFPField = new FieldPosition(DateFormat.Field.YEAR);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormat.hashCode()'
|
||||
*/
|
||||
public final void testHashCode() {
|
||||
DateFormat df = DateFormat.getInstance();
|
||||
DateFormat eq = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
|
||||
testEHCS(df, eq, aDF);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormat.DateFormat(DateFormat)'
|
||||
*/
|
||||
public final void testDateFormat() {
|
||||
DateFormat df = new DateFormat(java.text.DateFormat.getInstance());
|
||||
assertEquals(DateFormat.getInstance(), df);
|
||||
}
|
||||
|
||||
private void assertEqualDateString(StringBuffer buf) {
|
||||
assertEquals(aDateTimeString, buf.toString());
|
||||
}
|
||||
|
||||
private void assertEqualDateString(String str) {
|
||||
assertEquals(aDateTimeString, str);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormat.format(Object, StringBuffer, FieldPosition)'
|
||||
*/
|
||||
public final void testFormatObjectStringBufferFieldPosition() {
|
||||
assertEqualDateString(aDF.format(aDate, aBuf, anFP));
|
||||
assertEquals(YEAR_POS_START, anFP.getBeginIndex());
|
||||
assertEquals(YEAR_POS_END, anFP.getEndIndex());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormat.format(Calendar, StringBuffer, FieldPosition)'
|
||||
*/
|
||||
public final void testFormatCalendarStringBufferFieldPosition() {
|
||||
assertEqualDateString(aDF.format(aCal, aBuf, anFP));
|
||||
assertEquals(YEAR_POS_START, anFP.getBeginIndex());
|
||||
assertEquals(YEAR_POS_END, anFP.getEndIndex());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormat.format(Date, StringBuffer, FieldPosition)'
|
||||
*/
|
||||
public final void testFormatDateStringBufferFieldPosition() {
|
||||
assertEqualDateString(aDF.format(aDate, aBuf, anFPField));
|
||||
assertEquals(YEAR_POS_START, anFPField.getBeginIndex());
|
||||
assertEquals(YEAR_POS_END, anFPField.getEndIndex());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormat.format(Date)'
|
||||
*/
|
||||
public final void testFormatDate() {
|
||||
assertEqualDateString(aDF.format(aDate));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormat.parse(String)'
|
||||
*/
|
||||
public final void testParseString() throws Exception {
|
||||
assertEquals(aDate, aDF.parse(aDateTimeString));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormat.parse(String, Calendar, ParsePosition)'
|
||||
*/
|
||||
public final void testParseStringCalendarParsePosition() {
|
||||
aDF.parse(aDateTimeString, aCal, new ParsePosition(0));
|
||||
assertEquals(aDate, aCal.getTime());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormat.parse(String, ParsePosition)'
|
||||
*/
|
||||
public final void testParseStringParsePosition() {
|
||||
assertEquals(aDate, aDF.parse(aDateTimeString, new ParsePosition(0)));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormat.parseObject(String, ParsePosition)'
|
||||
*/
|
||||
public final void testParseObjectStringParsePosition() {
|
||||
assertEquals(aDate, aDF.parseObject(aDateTimeString, new ParsePosition(0)));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormat.getTimeInstance()'
|
||||
*/
|
||||
public final void testGetTimeInstance() {
|
||||
assertEquals(aTimeString, DateFormat.getTimeInstance().format(aDate));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormat.getTimeInstance(int)'
|
||||
*/
|
||||
public final void testGetTimeInstanceInt() {
|
||||
assertEquals(aTimeString, DateFormat.getTimeInstance(DateFormat.MEDIUM).format(aDate));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormat.getTimeInstance(int, Locale)'
|
||||
*/
|
||||
public final void testGetTimeInstanceIntLocale() {
|
||||
assertEquals(aTimeString, DateFormat.getTimeInstance(DateFormat.MEDIUM, Locale.US).format(aDate));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormat.getTimeInstance(int, ULocale)'
|
||||
*/
|
||||
public final void testGetTimeInstanceIntULocale() {
|
||||
assertEquals(aTimeString, DateFormat.getTimeInstance(DateFormat.MEDIUM, ULocale.US).format(aDate));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormat.getDateInstance()'
|
||||
*/
|
||||
public final void testGetDateInstance() {
|
||||
assertEquals(aDateString, DateFormat.getDateInstance().format(aDate));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormat.getDateInstance(int)'
|
||||
*/
|
||||
public final void testGetDateInstanceInt() {
|
||||
assertEquals(aDateString, DateFormat.getDateInstance(DateFormat.MEDIUM).format(aDate));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormat.getDateInstance(int, Locale)'
|
||||
*/
|
||||
public final void testGetDateInstanceIntLocale() {
|
||||
assertEquals(aDateString, DateFormat.getDateInstance(DateFormat.MEDIUM, Locale.US).format(aDate));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormat.getDateInstance(int, ULocale)'
|
||||
*/
|
||||
public final void testGetDateInstanceIntULocale() {
|
||||
assertEquals(aDateString, DateFormat.getDateInstance(DateFormat.MEDIUM, ULocale.US).format(aDate));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormat.getDateTimeInstance()'
|
||||
*/
|
||||
public final void testGetDateTimeInstance() {
|
||||
assertEquals(aDateTimeString, DateFormat.getDateTimeInstance().format(aDate));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormat.getDateTimeInstance(int, int)'
|
||||
*/
|
||||
public final void testGetDateTimeInstanceIntInt() {
|
||||
assertEquals(aDateTimeString,
|
||||
DateFormat.getDateTimeInstance(
|
||||
DateFormat.MEDIUM, DateFormat.MEDIUM).format(aDate));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormat.getDateTimeInstance(int, int, Locale)'
|
||||
*/
|
||||
public final void testGetDateTimeInstanceIntIntLocale() {
|
||||
assertEquals(aDateTimeString,
|
||||
DateFormat.getDateTimeInstance(
|
||||
DateFormat.MEDIUM, DateFormat.MEDIUM, Locale.US).format(aDate));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormat.getDateTimeInstance(int, int, ULocale)'
|
||||
*/
|
||||
public final void testGetDateTimeInstanceIntIntULocale() {
|
||||
assertEquals(aDateTimeString,
|
||||
DateFormat.getDateTimeInstance(
|
||||
DateFormat.MEDIUM, DateFormat.MEDIUM, ULocale.US).format(aDate));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormat.getInstance()'
|
||||
*/
|
||||
public final void testGetInstance() {
|
||||
assertEquals(aShortDateTimeString, DateFormat.getInstance().format(aDate));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormat.getAvailableLocales()'
|
||||
*/
|
||||
public final void testGetAvailableLocales() {
|
||||
Locale[] locales = DateFormat.getAvailableLocales();
|
||||
if (ICUTestCase.testingWrapper) {
|
||||
ICUTestCase.assertArraysEqual(java.text.DateFormat.getAvailableLocales(), locales);
|
||||
} else {
|
||||
assertNotNull(locales);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormat.setCalendar(Calendar)'
|
||||
*/
|
||||
public final void testSetCalendar() {
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.setTimeZone(TimeZone.getTimeZone("EST"));
|
||||
DateFormat df = DateFormat.getTimeInstance(DateFormat.SHORT);
|
||||
df.setCalendar(cal);
|
||||
assertEquals("8:17 AM", df.format(aDate));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormat.getCalendar()'
|
||||
*/
|
||||
public final void testGetCalendar() {
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.setTimeZone(TimeZone.getTimeZone("EST"));
|
||||
DateFormat df = DateFormat.getTimeInstance(DateFormat.SHORT);
|
||||
df.setCalendar(cal);
|
||||
assertEquals(cal, df.getCalendar());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormat.setNumberFormat(NumberFormat)'
|
||||
*/
|
||||
public final void testSetNumberFormat() {
|
||||
// no easy way to test effect of setting the number format
|
||||
NumberFormat nf = NumberFormat.getInstance();
|
||||
DateFormat df = DateFormat.getTimeInstance(DateFormat.SHORT);
|
||||
df.setNumberFormat(nf);
|
||||
// note, can't actually USE the dateformat since it changes the calendar
|
||||
assertEquals(nf, df.getNumberFormat());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormat.getNumberFormat()'
|
||||
*/
|
||||
public final void testGetNumberFormat() {
|
||||
// see testSetNumberFormat
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormat.setTimeZone(TimeZone)'
|
||||
*/
|
||||
public final void testSetTimeZone() {
|
||||
DateFormat df = DateFormat.getTimeInstance(DateFormat.SHORT);
|
||||
TimeZone tz = TimeZone.getTimeZone("EST");
|
||||
df.setTimeZone(tz);
|
||||
assertEquals("8:17 AM", df.format(aDate));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormat.getTimeZone()'
|
||||
*/
|
||||
public final void testGetTimeZone() {
|
||||
DateFormat df = DateFormat.getTimeInstance(DateFormat.SHORT);
|
||||
TimeZone tz = TimeZone.getTimeZone("EST");
|
||||
df.setTimeZone(tz);
|
||||
assertEquals(tz, df.getTimeZone());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormat.setLenient(boolean)'
|
||||
*/
|
||||
public final void testSetLenient() throws Exception {
|
||||
DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT);
|
||||
df.parse("2/31/90"); // succeeds, default is lenient
|
||||
df.setLenient(false);
|
||||
try {
|
||||
df.parse("2/31/90");
|
||||
throw new Exception("strict parse should have failed");
|
||||
}
|
||||
catch (ParseException e) {
|
||||
// ok, this is what we expect
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormat.isLenient()'
|
||||
*/
|
||||
public final void testIsLenient() {
|
||||
DateFormat df = DateFormat.getInstance();
|
||||
assertTrue(df.isLenient());
|
||||
df.setLenient(false);
|
||||
assertFalse(df.isLenient());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormat.getDateInstance(Calendar, int, Locale)'
|
||||
*/
|
||||
public final void testGetDateInstanceCalendarIntLocale() {
|
||||
assertEquals(aDateString, DateFormat.getDateInstance(aCal, DateFormat.MEDIUM, Locale.US).format(aDate));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormat.getDateInstance(Calendar, int, ULocale)'
|
||||
*/
|
||||
public final void testGetDateInstanceCalendarIntULocale() {
|
||||
assertEquals(aDateString, DateFormat.getDateInstance(aCal, DateFormat.MEDIUM, ULocale.US).format(aDate));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormat.getTimeInstance(Calendar, int, Locale)'
|
||||
*/
|
||||
public final void testGetTimeInstanceCalendarIntLocale() {
|
||||
assertEquals(anESTTimeString, DateFormat.getTimeInstance(anESTCal, DateFormat.MEDIUM, Locale.US).format(aDate));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormat.getTimeInstance(Calendar, int, ULocale)'
|
||||
*/
|
||||
public final void testGetTimeInstanceCalendarIntULocale() {
|
||||
assertEquals(anESTTimeString, DateFormat.getTimeInstance(anESTCal, DateFormat.MEDIUM, ULocale.US).format(aDate));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormat.getDateTimeInstance(Calendar, int, int, Locale)'
|
||||
*/
|
||||
public final void testGetDateTimeInstanceCalendarIntIntLocale() {
|
||||
assertEquals(aDefaultESTDateTimeString, DateFormat.getDateTimeInstance(anESTCal, DateFormat.MEDIUM, DateFormat.SHORT, Locale.US).format(aDate));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormat.getDateTimeInstance(Calendar, int, int, ULocale)'
|
||||
*/
|
||||
public final void testGetDateTimeInstanceCalendarIntIntULocale() {
|
||||
assertEquals(aDefaultESTDateTimeString, DateFormat.getDateTimeInstance(anESTCal, DateFormat.MEDIUM, DateFormat.SHORT, ULocale.US).format(aDate));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormat.getInstance(Calendar, Locale)'
|
||||
*/
|
||||
public final void testGetInstanceCalendarLocale() {
|
||||
assertEquals(aDefaultESTDateTimeString, DateFormat.getInstance(anESTCal, Locale.US).format(aDate));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormat.getInstance(Calendar, ULocale)'
|
||||
*/
|
||||
public final void testGetInstanceCalendarULocale() {
|
||||
assertEquals(aDefaultESTDateTimeString, DateFormat.getInstance(anESTCal, ULocale.US).format(aDate));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormat.getInstance(Calendar)'
|
||||
*/
|
||||
public final void testGetInstanceCalendar() {
|
||||
assertEquals(aDefaultESTDateTimeString, DateFormat.getInstance(anESTCal).format(aDate));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormat.getDateInstance(Calendar, int)'
|
||||
*/
|
||||
public final void testGetDateInstanceCalendarInt() {
|
||||
assertEquals(aDateString, DateFormat.getDateInstance(aCal, DateFormat.MEDIUM).format(aDate));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormat.getTimeInstance(Calendar, int)'
|
||||
*/
|
||||
public final void testGetTimeInstanceCalendarInt() {
|
||||
assertEquals(anESTTimeString, DateFormat.getTimeInstance(anESTCal, DateFormat.MEDIUM).format(aDate));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormat.getDateTimeInstance(Calendar, int, int)'
|
||||
*/
|
||||
public final void testGetDateTimeInstanceCalendarIntInt() {
|
||||
assertEquals(aDefaultESTDateTimeString, DateFormat.getDateTimeInstance(anESTCal, DateFormat.MEDIUM, DateFormat.SHORT).format(aDate));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormat.toString()'
|
||||
*/
|
||||
public final void testToString() {
|
||||
assertNotNull(aDF.toString());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormat.clone()'
|
||||
*/
|
||||
public final void testClone() {
|
||||
// see testHashCode
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormat.equals(Object)'
|
||||
*/
|
||||
public final void testEqualsObject() {
|
||||
// see testHashCode
|
||||
}
|
||||
}
|
||||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2006-2011, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
package com.ibm.icu.tests;
|
||||
|
||||
import java.text.FieldPosition;
|
||||
import java.text.ParseException;
|
||||
import java.text.ParsePosition;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
|
||||
import com.ibm.icu.text.DateFormat;
|
||||
import com.ibm.icu.text.NumberFormat;
|
||||
import com.ibm.icu.util.Calendar;
|
||||
import com.ibm.icu.util.TimeZone;
|
||||
import com.ibm.icu.util.ULocale;
|
||||
|
||||
public class DateFormatTest extends ICUTestCase {
|
||||
private Calendar aCal;
|
||||
private Calendar anESTCal;
|
||||
private Date aDate;
|
||||
private String aDateString;
|
||||
private String aTimeString;
|
||||
private String anESTTimeString;
|
||||
private String aDateTimeString;
|
||||
private String aShortDateTimeString;
|
||||
private String aDefaultESTDateTimeString;
|
||||
private DateFormat aDF;
|
||||
private StringBuffer aBuf;
|
||||
private FieldPosition anFP;
|
||||
private FieldPosition anFPField;
|
||||
|
||||
private static int YEAR_POS_START = 8;
|
||||
private static int YEAR_POS_END = 12;
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
|
||||
java.util.GregorianCalendar gcal = new java.util.GregorianCalendar();
|
||||
gcal.clear();
|
||||
gcal.set(java.util.GregorianCalendar.YEAR, 1990);
|
||||
gcal.set(java.util.GregorianCalendar.MONTH, java.util.GregorianCalendar.DECEMBER);
|
||||
gcal.set(java.util.GregorianCalendar.DATE, 17);
|
||||
gcal.set(java.util.GregorianCalendar.HOUR, 5);
|
||||
gcal.set(java.util.GregorianCalendar.MINUTE, 17);
|
||||
aCal = new Calendar(gcal);
|
||||
anESTCal = Calendar.getInstance();
|
||||
anESTCal.setTimeZone(TimeZone.getTimeZone("EST"));
|
||||
aDate = gcal.getTime();
|
||||
aDateString = "Dec 17, 1990"; // medium -- the default
|
||||
aTimeString = "5:17:00 AM"; // medium
|
||||
anESTTimeString = "8:17:00 AM";
|
||||
aDateTimeString = "Dec 17, 1990 5:17:00 AM"; // medium, medium
|
||||
aDefaultESTDateTimeString = "Dec 17, 1990 8:17 AM"; // medium, short -- the default
|
||||
aShortDateTimeString = "12/17/90 5:17 AM"; // short, short
|
||||
aDF = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM, Locale.US);
|
||||
aBuf = new StringBuffer();
|
||||
anFP = new FieldPosition(DateFormat.YEAR_FIELD);
|
||||
anFPField = new FieldPosition(DateFormat.Field.YEAR);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormat.hashCode()'
|
||||
*/
|
||||
public final void testHashCode() {
|
||||
DateFormat df = DateFormat.getInstance();
|
||||
DateFormat eq = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
|
||||
testEHCS(df, eq, aDF);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormat.DateFormat(DateFormat)'
|
||||
*/
|
||||
public final void testDateFormat() {
|
||||
DateFormat df = new DateFormat(java.text.DateFormat.getInstance());
|
||||
assertEquals(DateFormat.getInstance(), df);
|
||||
}
|
||||
|
||||
private void assertEqualDateString(StringBuffer buf) {
|
||||
assertEquals(aDateTimeString, buf.toString());
|
||||
}
|
||||
|
||||
private void assertEqualDateString(String str) {
|
||||
assertEquals(aDateTimeString, str);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormat.format(Object, StringBuffer, FieldPosition)'
|
||||
*/
|
||||
public final void testFormatObjectStringBufferFieldPosition() {
|
||||
assertEqualDateString(aDF.format(aDate, aBuf, anFP));
|
||||
assertEquals(YEAR_POS_START, anFP.getBeginIndex());
|
||||
assertEquals(YEAR_POS_END, anFP.getEndIndex());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormat.format(Calendar, StringBuffer, FieldPosition)'
|
||||
*/
|
||||
public final void testFormatCalendarStringBufferFieldPosition() {
|
||||
assertEqualDateString(aDF.format(aCal, aBuf, anFP));
|
||||
assertEquals(YEAR_POS_START, anFP.getBeginIndex());
|
||||
assertEquals(YEAR_POS_END, anFP.getEndIndex());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormat.format(Date, StringBuffer, FieldPosition)'
|
||||
*/
|
||||
public final void testFormatDateStringBufferFieldPosition() {
|
||||
assertEqualDateString(aDF.format(aDate, aBuf, anFPField));
|
||||
assertEquals(YEAR_POS_START, anFPField.getBeginIndex());
|
||||
assertEquals(YEAR_POS_END, anFPField.getEndIndex());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormat.format(Date)'
|
||||
*/
|
||||
public final void testFormatDate() {
|
||||
assertEqualDateString(aDF.format(aDate));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormat.parse(String)'
|
||||
*/
|
||||
public final void testParseString() throws Exception {
|
||||
assertEquals(aDate, aDF.parse(aDateTimeString));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormat.parse(String, Calendar, ParsePosition)'
|
||||
*/
|
||||
public final void testParseStringCalendarParsePosition() {
|
||||
aDF.parse(aDateTimeString, aCal, new ParsePosition(0));
|
||||
assertEquals(aDate, aCal.getTime());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormat.parse(String, ParsePosition)'
|
||||
*/
|
||||
public final void testParseStringParsePosition() {
|
||||
assertEquals(aDate, aDF.parse(aDateTimeString, new ParsePosition(0)));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormat.parseObject(String, ParsePosition)'
|
||||
*/
|
||||
public final void testParseObjectStringParsePosition() {
|
||||
assertEquals(aDate, aDF.parseObject(aDateTimeString, new ParsePosition(0)));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormat.getTimeInstance()'
|
||||
*/
|
||||
public final void testGetTimeInstance() {
|
||||
assertEquals(aTimeString, DateFormat.getTimeInstance().format(aDate));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormat.getTimeInstance(int)'
|
||||
*/
|
||||
public final void testGetTimeInstanceInt() {
|
||||
assertEquals(aTimeString, DateFormat.getTimeInstance(DateFormat.MEDIUM).format(aDate));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormat.getTimeInstance(int, Locale)'
|
||||
*/
|
||||
public final void testGetTimeInstanceIntLocale() {
|
||||
assertEquals(aTimeString, DateFormat.getTimeInstance(DateFormat.MEDIUM, Locale.US).format(aDate));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormat.getTimeInstance(int, ULocale)'
|
||||
*/
|
||||
public final void testGetTimeInstanceIntULocale() {
|
||||
assertEquals(aTimeString, DateFormat.getTimeInstance(DateFormat.MEDIUM, ULocale.US).format(aDate));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormat.getDateInstance()'
|
||||
*/
|
||||
public final void testGetDateInstance() {
|
||||
assertEquals(aDateString, DateFormat.getDateInstance().format(aDate));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormat.getDateInstance(int)'
|
||||
*/
|
||||
public final void testGetDateInstanceInt() {
|
||||
assertEquals(aDateString, DateFormat.getDateInstance(DateFormat.MEDIUM).format(aDate));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormat.getDateInstance(int, Locale)'
|
||||
*/
|
||||
public final void testGetDateInstanceIntLocale() {
|
||||
assertEquals(aDateString, DateFormat.getDateInstance(DateFormat.MEDIUM, Locale.US).format(aDate));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormat.getDateInstance(int, ULocale)'
|
||||
*/
|
||||
public final void testGetDateInstanceIntULocale() {
|
||||
assertEquals(aDateString, DateFormat.getDateInstance(DateFormat.MEDIUM, ULocale.US).format(aDate));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormat.getDateTimeInstance()'
|
||||
*/
|
||||
public final void testGetDateTimeInstance() {
|
||||
assertEquals(aDateTimeString, DateFormat.getDateTimeInstance().format(aDate));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormat.getDateTimeInstance(int, int)'
|
||||
*/
|
||||
public final void testGetDateTimeInstanceIntInt() {
|
||||
assertEquals(aDateTimeString,
|
||||
DateFormat.getDateTimeInstance(
|
||||
DateFormat.MEDIUM, DateFormat.MEDIUM).format(aDate));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormat.getDateTimeInstance(int, int, Locale)'
|
||||
*/
|
||||
public final void testGetDateTimeInstanceIntIntLocale() {
|
||||
assertEquals(aDateTimeString,
|
||||
DateFormat.getDateTimeInstance(
|
||||
DateFormat.MEDIUM, DateFormat.MEDIUM, Locale.US).format(aDate));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormat.getDateTimeInstance(int, int, ULocale)'
|
||||
*/
|
||||
public final void testGetDateTimeInstanceIntIntULocale() {
|
||||
assertEquals(aDateTimeString,
|
||||
DateFormat.getDateTimeInstance(
|
||||
DateFormat.MEDIUM, DateFormat.MEDIUM, ULocale.US).format(aDate));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormat.getInstance()'
|
||||
*/
|
||||
public final void testGetInstance() {
|
||||
assertEquals(aShortDateTimeString, DateFormat.getInstance().format(aDate));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormat.getAvailableLocales()'
|
||||
*/
|
||||
public final void testGetAvailableLocales() {
|
||||
Locale[] locales = DateFormat.getAvailableLocales();
|
||||
if (ICUTestCase.testingWrapper) {
|
||||
ICUTestCase.assertArraysEqual(java.text.DateFormat.getAvailableLocales(), locales);
|
||||
} else {
|
||||
assertNotNull(locales);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormat.setCalendar(Calendar)'
|
||||
*/
|
||||
public final void testSetCalendar() {
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.setTimeZone(TimeZone.getTimeZone("EST"));
|
||||
DateFormat df = DateFormat.getTimeInstance(DateFormat.SHORT);
|
||||
df.setCalendar(cal);
|
||||
assertEquals("8:17 AM", df.format(aDate));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormat.getCalendar()'
|
||||
*/
|
||||
public final void testGetCalendar() {
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.setTimeZone(TimeZone.getTimeZone("EST"));
|
||||
DateFormat df = DateFormat.getTimeInstance(DateFormat.SHORT);
|
||||
df.setCalendar(cal);
|
||||
assertEquals(cal, df.getCalendar());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormat.setNumberFormat(NumberFormat)'
|
||||
*/
|
||||
public final void testSetNumberFormat() {
|
||||
// no easy way to test effect of setting the number format
|
||||
NumberFormat nf = NumberFormat.getInstance();
|
||||
DateFormat df = DateFormat.getTimeInstance(DateFormat.SHORT);
|
||||
df.setNumberFormat(nf);
|
||||
// note, can't actually USE the dateformat since it changes the calendar
|
||||
assertEquals(nf, df.getNumberFormat());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormat.getNumberFormat()'
|
||||
*/
|
||||
public final void testGetNumberFormat() {
|
||||
// see testSetNumberFormat
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormat.setTimeZone(TimeZone)'
|
||||
*/
|
||||
public final void testSetTimeZone() {
|
||||
DateFormat df = DateFormat.getTimeInstance(DateFormat.SHORT);
|
||||
TimeZone tz = TimeZone.getTimeZone("EST");
|
||||
df.setTimeZone(tz);
|
||||
assertEquals("8:17 AM", df.format(aDate));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormat.getTimeZone()'
|
||||
*/
|
||||
public final void testGetTimeZone() {
|
||||
DateFormat df = DateFormat.getTimeInstance(DateFormat.SHORT);
|
||||
TimeZone tz = TimeZone.getTimeZone("EST");
|
||||
df.setTimeZone(tz);
|
||||
assertEquals(tz, df.getTimeZone());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormat.setLenient(boolean)'
|
||||
*/
|
||||
public final void testSetLenient() throws Exception {
|
||||
DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT);
|
||||
df.parse("2/31/90"); // succeeds, default is lenient
|
||||
df.setLenient(false);
|
||||
try {
|
||||
df.parse("2/31/90");
|
||||
throw new Exception("strict parse should have failed");
|
||||
}
|
||||
catch (ParseException e) {
|
||||
// ok, this is what we expect
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormat.isLenient()'
|
||||
*/
|
||||
public final void testIsLenient() {
|
||||
DateFormat df = DateFormat.getInstance();
|
||||
assertTrue(df.isLenient());
|
||||
df.setLenient(false);
|
||||
assertFalse(df.isLenient());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormat.getDateInstance(Calendar, int, Locale)'
|
||||
*/
|
||||
public final void testGetDateInstanceCalendarIntLocale() {
|
||||
assertEquals(aDateString, DateFormat.getDateInstance(aCal, DateFormat.MEDIUM, Locale.US).format(aDate));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormat.getDateInstance(Calendar, int, ULocale)'
|
||||
*/
|
||||
public final void testGetDateInstanceCalendarIntULocale() {
|
||||
assertEquals(aDateString, DateFormat.getDateInstance(aCal, DateFormat.MEDIUM, ULocale.US).format(aDate));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormat.getTimeInstance(Calendar, int, Locale)'
|
||||
*/
|
||||
public final void testGetTimeInstanceCalendarIntLocale() {
|
||||
assertEquals(anESTTimeString, DateFormat.getTimeInstance(anESTCal, DateFormat.MEDIUM, Locale.US).format(aDate));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormat.getTimeInstance(Calendar, int, ULocale)'
|
||||
*/
|
||||
public final void testGetTimeInstanceCalendarIntULocale() {
|
||||
assertEquals(anESTTimeString, DateFormat.getTimeInstance(anESTCal, DateFormat.MEDIUM, ULocale.US).format(aDate));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormat.getDateTimeInstance(Calendar, int, int, Locale)'
|
||||
*/
|
||||
public final void testGetDateTimeInstanceCalendarIntIntLocale() {
|
||||
assertEquals(aDefaultESTDateTimeString, DateFormat.getDateTimeInstance(anESTCal, DateFormat.MEDIUM, DateFormat.SHORT, Locale.US).format(aDate));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormat.getDateTimeInstance(Calendar, int, int, ULocale)'
|
||||
*/
|
||||
public final void testGetDateTimeInstanceCalendarIntIntULocale() {
|
||||
assertEquals(aDefaultESTDateTimeString, DateFormat.getDateTimeInstance(anESTCal, DateFormat.MEDIUM, DateFormat.SHORT, ULocale.US).format(aDate));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormat.getInstance(Calendar, Locale)'
|
||||
*/
|
||||
public final void testGetInstanceCalendarLocale() {
|
||||
assertEquals(aDefaultESTDateTimeString, DateFormat.getInstance(anESTCal, Locale.US).format(aDate));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormat.getInstance(Calendar, ULocale)'
|
||||
*/
|
||||
public final void testGetInstanceCalendarULocale() {
|
||||
assertEquals(aDefaultESTDateTimeString, DateFormat.getInstance(anESTCal, ULocale.US).format(aDate));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormat.getInstance(Calendar)'
|
||||
*/
|
||||
public final void testGetInstanceCalendar() {
|
||||
assertEquals(aDefaultESTDateTimeString, DateFormat.getInstance(anESTCal).format(aDate));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormat.getDateInstance(Calendar, int)'
|
||||
*/
|
||||
public final void testGetDateInstanceCalendarInt() {
|
||||
assertEquals(aDateString, DateFormat.getDateInstance(aCal, DateFormat.MEDIUM).format(aDate));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormat.getTimeInstance(Calendar, int)'
|
||||
*/
|
||||
public final void testGetTimeInstanceCalendarInt() {
|
||||
assertEquals(anESTTimeString, DateFormat.getTimeInstance(anESTCal, DateFormat.MEDIUM).format(aDate));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormat.getDateTimeInstance(Calendar, int, int)'
|
||||
*/
|
||||
public final void testGetDateTimeInstanceCalendarIntInt() {
|
||||
assertEquals(aDefaultESTDateTimeString, DateFormat.getDateTimeInstance(anESTCal, DateFormat.MEDIUM, DateFormat.SHORT).format(aDate));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormat.toString()'
|
||||
*/
|
||||
public final void testToString() {
|
||||
assertNotNull(aDF.toString());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormat.clone()'
|
||||
*/
|
||||
public final void testClone() {
|
||||
// see testHashCode
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DateFormat.equals(Object)'
|
||||
*/
|
||||
public final void testEqualsObject() {
|
||||
// see testHashCode
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,344 +1,344 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2006-2011, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
package com.ibm.icu.tests;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import com.ibm.icu.text.DecimalFormatSymbols;
|
||||
import com.ibm.icu.util.ULocale;
|
||||
|
||||
public class DecimalFormatSymbolsTest extends ICUTestCase {
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.hashCode()'
|
||||
*/
|
||||
public void testHashCode() {
|
||||
DecimalFormatSymbols dfs = new DecimalFormatSymbols(Locale.US);
|
||||
DecimalFormatSymbols dfs2 = new DecimalFormatSymbols(ULocale.US);
|
||||
DecimalFormatSymbols dfsn = new DecimalFormatSymbols(Locale.FRANCE);
|
||||
testEHCS(dfs, dfs2, dfsn);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.DecimalFormatSymbols(DecimalFormatSymbols)'
|
||||
*/
|
||||
public void testDecimalFormatSymbolsDecimalFormatSymbols() {
|
||||
// implicitly tested everywhere
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.DecimalFormatSymbols()'
|
||||
*/
|
||||
public void testDecimalFormatSymbols() {
|
||||
DecimalFormatSymbols dfs = new DecimalFormatSymbols();
|
||||
assertTrue(-1 != dfs.getDecimalSeparator());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.DecimalFormatSymbols(Locale)'
|
||||
*/
|
||||
public void testDecimalFormatSymbolsLocale() {
|
||||
DecimalFormatSymbols dfs = new DecimalFormatSymbols(Locale.US);
|
||||
assertTrue(-1 != dfs.getDecimalSeparator());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.DecimalFormatSymbols(ULocale)'
|
||||
*/
|
||||
public void testDecimalFormatSymbolsULocale() {
|
||||
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
|
||||
assertTrue(-1 != dfs.getDecimalSeparator());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.getZeroDigit()'
|
||||
*/
|
||||
public void testGetZeroDigit() {
|
||||
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
|
||||
assertEquals('0', dfs.getZeroDigit());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.setZeroDigit(char)'
|
||||
*/
|
||||
public void testSetZeroDigit() {
|
||||
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
|
||||
char value = dfs.getZeroDigit();
|
||||
char value1 = (char)(value + 1);
|
||||
dfs.setZeroDigit(value1);
|
||||
char result = dfs.getZeroDigit();
|
||||
assertNotEqual(value, result);
|
||||
assertEquals(value1, result);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.getGroupingSeparator()'
|
||||
*/
|
||||
public void testGetGroupingSeparator() {
|
||||
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
|
||||
assertEquals(',', dfs.getGroupingSeparator());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.setGroupingSeparator(char)'
|
||||
*/
|
||||
public void testSetGroupingSeparator() {
|
||||
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
|
||||
char value = dfs.getGroupingSeparator();
|
||||
char value1 = (char)(value + 1);
|
||||
dfs.setGroupingSeparator(value1);
|
||||
char result = dfs.getGroupingSeparator();
|
||||
assertNotEqual(value, result);
|
||||
assertEquals(value1, result);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.getDecimalSeparator()'
|
||||
*/
|
||||
public void testGetDecimalSeparator() {
|
||||
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
|
||||
assertEquals('.', dfs.getDecimalSeparator());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.setDecimalSeparator(char)'
|
||||
*/
|
||||
public void testSetDecimalSeparator() {
|
||||
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
|
||||
char value = dfs.getDecimalSeparator();
|
||||
char value1 = (char)(value + 1);
|
||||
dfs.setDecimalSeparator(value1);
|
||||
char result = dfs.getDecimalSeparator();
|
||||
assertNotEqual(value, result);
|
||||
assertEquals(value1, result);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.getPerMill()'
|
||||
*/
|
||||
public void testGetPerMill() {
|
||||
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
|
||||
assertEquals('\u2030', dfs.getPerMill());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.setPerMill(char)'
|
||||
*/
|
||||
public void testSetPerMill() {
|
||||
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
|
||||
char value = dfs.getPerMill();
|
||||
char value1 = (char)(value + 1);
|
||||
dfs.setPerMill(value1);
|
||||
char result = dfs.getPerMill();
|
||||
assertNotEqual(value, result);
|
||||
assertEquals(value1, result);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.getPercent()'
|
||||
*/
|
||||
public void testGetPercent() {
|
||||
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
|
||||
assertEquals('%', dfs.getPercent());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.setPercent(char)'
|
||||
*/
|
||||
public void testSetPercent() {
|
||||
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
|
||||
char value = dfs.getPercent();
|
||||
char value1 = (char)(value + 1);
|
||||
dfs.setPercent(value1);
|
||||
char result = dfs.getPercent();
|
||||
assertNotEqual(value, result);
|
||||
assertEquals(value1, result);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.getDigit()'
|
||||
*/
|
||||
public void testGetDigit() {
|
||||
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
|
||||
assertEquals('#', dfs.getDigit());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.setDigit(char)'
|
||||
*/
|
||||
public void testSetDigit() {
|
||||
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
|
||||
char value = dfs.getDigit();
|
||||
char value1 = (char)(value + 1);
|
||||
dfs.setDigit(value1);
|
||||
char result = dfs.getDigit();
|
||||
assertNotEqual(value, result);
|
||||
assertEquals(value1, result);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.getPatternSeparator()'
|
||||
*/
|
||||
public void testGetPatternSeparator() {
|
||||
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
|
||||
assertEquals(';', dfs.getPatternSeparator());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.setPatternSeparator(char)'
|
||||
*/
|
||||
public void testSetPatternSeparator() {
|
||||
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
|
||||
char value = dfs.getPatternSeparator();
|
||||
char value1 = (char)(value + 1);
|
||||
dfs.setPatternSeparator(value1);
|
||||
char result = dfs.getPatternSeparator();
|
||||
assertNotEqual(value, result);
|
||||
assertEquals(value1, result);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.getInfinity()'
|
||||
*/
|
||||
public void testGetInfinity() {
|
||||
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
|
||||
assertEquals("\u221e", dfs.getInfinity());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.setInfinity(String)'
|
||||
*/
|
||||
public void testSetInfinity() {
|
||||
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
|
||||
String value = dfs.getInfinity();
|
||||
String value1 = value + "!";
|
||||
dfs.setInfinity(value1);
|
||||
String result = dfs.getInfinity();
|
||||
assertNotEqual(value, result);
|
||||
assertEquals(value1, result);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.getNaN()'
|
||||
*/
|
||||
public void testGetNaN() {
|
||||
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
|
||||
assertNotNull(dfs.getNaN()); // java returns missing character???
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.setNaN(String)'
|
||||
*/
|
||||
public void testSetNaN() {
|
||||
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
|
||||
String value = dfs.getNaN();
|
||||
String value1 = value + "!";
|
||||
dfs.setNaN(value1);
|
||||
String result = dfs.getNaN();
|
||||
assertNotEqual(value, result);
|
||||
assertEquals(value1, result);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.getMinusSign()'
|
||||
*/
|
||||
public void testGetMinusSign() {
|
||||
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
|
||||
assertEquals('-', dfs.getMinusSign());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.setMinusSign(char)'
|
||||
*/
|
||||
public void testSetMinusSign() {
|
||||
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
|
||||
char value = dfs.getMinusSign();
|
||||
char value1 = (char)(value + 1);
|
||||
dfs.setMinusSign(value1);
|
||||
char result = dfs.getMinusSign();
|
||||
assertNotEqual(value, result);
|
||||
assertEquals(value1, result);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.getCurrencySymbol()'
|
||||
*/
|
||||
public void testGetCurrencySymbol() {
|
||||
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
|
||||
assertEquals("$", dfs.getCurrencySymbol());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.setCurrencySymbol(String)'
|
||||
*/
|
||||
public void testSetCurrencySymbol() {
|
||||
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
|
||||
String value = dfs.getCurrencySymbol();
|
||||
String value1 = value + "!";
|
||||
dfs.setCurrencySymbol(value1);
|
||||
String result = dfs.getCurrencySymbol();
|
||||
assertNotEqual(value, result);
|
||||
assertEquals(value1, result);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.getInternationalCurrencySymbol()'
|
||||
*/
|
||||
public void testGetInternationalCurrencySymbol() {
|
||||
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
|
||||
assertEquals("USD", dfs.getInternationalCurrencySymbol());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.setInternationalCurrencySymbol(String)'
|
||||
*/
|
||||
public void testSetInternationalCurrencySymbol() {
|
||||
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
|
||||
String value = dfs.getInternationalCurrencySymbol();
|
||||
String value1 = value + "!";
|
||||
dfs.setInternationalCurrencySymbol(value1);
|
||||
String result = dfs.getInternationalCurrencySymbol();
|
||||
assertNotEqual(value, result);
|
||||
assertEquals(value1, result);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.getMonetaryDecimalSeparator()'
|
||||
*/
|
||||
public void testGetMonetaryDecimalSeparator() {
|
||||
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
|
||||
assertEquals('.', dfs.getMonetaryDecimalSeparator());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.setMonetaryDecimalSeparator(char)'
|
||||
*/
|
||||
public void testSetMonetaryDecimalSeparator() {
|
||||
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
|
||||
char value = dfs.getMonetaryDecimalSeparator();
|
||||
char value1 = (char)(value + 1);
|
||||
dfs.setMonetaryDecimalSeparator(value1);
|
||||
char result = dfs.getMonetaryDecimalSeparator();
|
||||
assertNotEqual(value, result);
|
||||
assertEquals(value1, result);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.clone()'
|
||||
*/
|
||||
public void testClone() {
|
||||
// tested in testHashcode
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.equals(Object)'
|
||||
*/
|
||||
public void testEqualsObject() {
|
||||
// tested in testHashcode
|
||||
}
|
||||
}
|
||||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2006-2011, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
package com.ibm.icu.tests;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import com.ibm.icu.text.DecimalFormatSymbols;
|
||||
import com.ibm.icu.util.ULocale;
|
||||
|
||||
public class DecimalFormatSymbolsTest extends ICUTestCase {
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.hashCode()'
|
||||
*/
|
||||
public void testHashCode() {
|
||||
DecimalFormatSymbols dfs = new DecimalFormatSymbols(Locale.US);
|
||||
DecimalFormatSymbols dfs2 = new DecimalFormatSymbols(ULocale.US);
|
||||
DecimalFormatSymbols dfsn = new DecimalFormatSymbols(Locale.FRANCE);
|
||||
testEHCS(dfs, dfs2, dfsn);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.DecimalFormatSymbols(DecimalFormatSymbols)'
|
||||
*/
|
||||
public void testDecimalFormatSymbolsDecimalFormatSymbols() {
|
||||
// implicitly tested everywhere
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.DecimalFormatSymbols()'
|
||||
*/
|
||||
public void testDecimalFormatSymbols() {
|
||||
DecimalFormatSymbols dfs = new DecimalFormatSymbols();
|
||||
assertTrue(-1 != dfs.getDecimalSeparator());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.DecimalFormatSymbols(Locale)'
|
||||
*/
|
||||
public void testDecimalFormatSymbolsLocale() {
|
||||
DecimalFormatSymbols dfs = new DecimalFormatSymbols(Locale.US);
|
||||
assertTrue(-1 != dfs.getDecimalSeparator());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.DecimalFormatSymbols(ULocale)'
|
||||
*/
|
||||
public void testDecimalFormatSymbolsULocale() {
|
||||
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
|
||||
assertTrue(-1 != dfs.getDecimalSeparator());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.getZeroDigit()'
|
||||
*/
|
||||
public void testGetZeroDigit() {
|
||||
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
|
||||
assertEquals('0', dfs.getZeroDigit());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.setZeroDigit(char)'
|
||||
*/
|
||||
public void testSetZeroDigit() {
|
||||
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
|
||||
char value = dfs.getZeroDigit();
|
||||
char value1 = (char)(value + 1);
|
||||
dfs.setZeroDigit(value1);
|
||||
char result = dfs.getZeroDigit();
|
||||
assertNotEqual(value, result);
|
||||
assertEquals(value1, result);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.getGroupingSeparator()'
|
||||
*/
|
||||
public void testGetGroupingSeparator() {
|
||||
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
|
||||
assertEquals(',', dfs.getGroupingSeparator());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.setGroupingSeparator(char)'
|
||||
*/
|
||||
public void testSetGroupingSeparator() {
|
||||
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
|
||||
char value = dfs.getGroupingSeparator();
|
||||
char value1 = (char)(value + 1);
|
||||
dfs.setGroupingSeparator(value1);
|
||||
char result = dfs.getGroupingSeparator();
|
||||
assertNotEqual(value, result);
|
||||
assertEquals(value1, result);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.getDecimalSeparator()'
|
||||
*/
|
||||
public void testGetDecimalSeparator() {
|
||||
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
|
||||
assertEquals('.', dfs.getDecimalSeparator());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.setDecimalSeparator(char)'
|
||||
*/
|
||||
public void testSetDecimalSeparator() {
|
||||
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
|
||||
char value = dfs.getDecimalSeparator();
|
||||
char value1 = (char)(value + 1);
|
||||
dfs.setDecimalSeparator(value1);
|
||||
char result = dfs.getDecimalSeparator();
|
||||
assertNotEqual(value, result);
|
||||
assertEquals(value1, result);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.getPerMill()'
|
||||
*/
|
||||
public void testGetPerMill() {
|
||||
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
|
||||
assertEquals('\u2030', dfs.getPerMill());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.setPerMill(char)'
|
||||
*/
|
||||
public void testSetPerMill() {
|
||||
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
|
||||
char value = dfs.getPerMill();
|
||||
char value1 = (char)(value + 1);
|
||||
dfs.setPerMill(value1);
|
||||
char result = dfs.getPerMill();
|
||||
assertNotEqual(value, result);
|
||||
assertEquals(value1, result);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.getPercent()'
|
||||
*/
|
||||
public void testGetPercent() {
|
||||
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
|
||||
assertEquals('%', dfs.getPercent());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.setPercent(char)'
|
||||
*/
|
||||
public void testSetPercent() {
|
||||
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
|
||||
char value = dfs.getPercent();
|
||||
char value1 = (char)(value + 1);
|
||||
dfs.setPercent(value1);
|
||||
char result = dfs.getPercent();
|
||||
assertNotEqual(value, result);
|
||||
assertEquals(value1, result);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.getDigit()'
|
||||
*/
|
||||
public void testGetDigit() {
|
||||
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
|
||||
assertEquals('#', dfs.getDigit());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.setDigit(char)'
|
||||
*/
|
||||
public void testSetDigit() {
|
||||
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
|
||||
char value = dfs.getDigit();
|
||||
char value1 = (char)(value + 1);
|
||||
dfs.setDigit(value1);
|
||||
char result = dfs.getDigit();
|
||||
assertNotEqual(value, result);
|
||||
assertEquals(value1, result);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.getPatternSeparator()'
|
||||
*/
|
||||
public void testGetPatternSeparator() {
|
||||
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
|
||||
assertEquals(';', dfs.getPatternSeparator());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.setPatternSeparator(char)'
|
||||
*/
|
||||
public void testSetPatternSeparator() {
|
||||
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
|
||||
char value = dfs.getPatternSeparator();
|
||||
char value1 = (char)(value + 1);
|
||||
dfs.setPatternSeparator(value1);
|
||||
char result = dfs.getPatternSeparator();
|
||||
assertNotEqual(value, result);
|
||||
assertEquals(value1, result);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.getInfinity()'
|
||||
*/
|
||||
public void testGetInfinity() {
|
||||
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
|
||||
assertEquals("\u221e", dfs.getInfinity());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.setInfinity(String)'
|
||||
*/
|
||||
public void testSetInfinity() {
|
||||
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
|
||||
String value = dfs.getInfinity();
|
||||
String value1 = value + "!";
|
||||
dfs.setInfinity(value1);
|
||||
String result = dfs.getInfinity();
|
||||
assertNotEqual(value, result);
|
||||
assertEquals(value1, result);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.getNaN()'
|
||||
*/
|
||||
public void testGetNaN() {
|
||||
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
|
||||
assertNotNull(dfs.getNaN()); // java returns missing character???
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.setNaN(String)'
|
||||
*/
|
||||
public void testSetNaN() {
|
||||
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
|
||||
String value = dfs.getNaN();
|
||||
String value1 = value + "!";
|
||||
dfs.setNaN(value1);
|
||||
String result = dfs.getNaN();
|
||||
assertNotEqual(value, result);
|
||||
assertEquals(value1, result);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.getMinusSign()'
|
||||
*/
|
||||
public void testGetMinusSign() {
|
||||
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
|
||||
assertEquals('-', dfs.getMinusSign());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.setMinusSign(char)'
|
||||
*/
|
||||
public void testSetMinusSign() {
|
||||
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
|
||||
char value = dfs.getMinusSign();
|
||||
char value1 = (char)(value + 1);
|
||||
dfs.setMinusSign(value1);
|
||||
char result = dfs.getMinusSign();
|
||||
assertNotEqual(value, result);
|
||||
assertEquals(value1, result);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.getCurrencySymbol()'
|
||||
*/
|
||||
public void testGetCurrencySymbol() {
|
||||
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
|
||||
assertEquals("$", dfs.getCurrencySymbol());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.setCurrencySymbol(String)'
|
||||
*/
|
||||
public void testSetCurrencySymbol() {
|
||||
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
|
||||
String value = dfs.getCurrencySymbol();
|
||||
String value1 = value + "!";
|
||||
dfs.setCurrencySymbol(value1);
|
||||
String result = dfs.getCurrencySymbol();
|
||||
assertNotEqual(value, result);
|
||||
assertEquals(value1, result);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.getInternationalCurrencySymbol()'
|
||||
*/
|
||||
public void testGetInternationalCurrencySymbol() {
|
||||
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
|
||||
assertEquals("USD", dfs.getInternationalCurrencySymbol());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.setInternationalCurrencySymbol(String)'
|
||||
*/
|
||||
public void testSetInternationalCurrencySymbol() {
|
||||
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
|
||||
String value = dfs.getInternationalCurrencySymbol();
|
||||
String value1 = value + "!";
|
||||
dfs.setInternationalCurrencySymbol(value1);
|
||||
String result = dfs.getInternationalCurrencySymbol();
|
||||
assertNotEqual(value, result);
|
||||
assertEquals(value1, result);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.getMonetaryDecimalSeparator()'
|
||||
*/
|
||||
public void testGetMonetaryDecimalSeparator() {
|
||||
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
|
||||
assertEquals('.', dfs.getMonetaryDecimalSeparator());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.setMonetaryDecimalSeparator(char)'
|
||||
*/
|
||||
public void testSetMonetaryDecimalSeparator() {
|
||||
DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
|
||||
char value = dfs.getMonetaryDecimalSeparator();
|
||||
char value1 = (char)(value + 1);
|
||||
dfs.setMonetaryDecimalSeparator(value1);
|
||||
char result = dfs.getMonetaryDecimalSeparator();
|
||||
assertNotEqual(value, result);
|
||||
assertEquals(value1, result);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.clone()'
|
||||
*/
|
||||
public void testClone() {
|
||||
// tested in testHashcode
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormatSymbols.equals(Object)'
|
||||
*/
|
||||
public void testEqualsObject() {
|
||||
// tested in testHashcode
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,242 +1,242 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2006-2011, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
package com.ibm.icu.tests;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import com.ibm.icu.text.DecimalFormat;
|
||||
import com.ibm.icu.text.DecimalFormatSymbols;
|
||||
|
||||
public class DecimalFormatTest extends ICUTestCase {
|
||||
private static final long lmax = Long.MAX_VALUE;
|
||||
private static final double dsmall = 23.33;
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormat.clone()'
|
||||
*/
|
||||
public void testClone() {
|
||||
DecimalFormat df = new DecimalFormat("#,#0.00");
|
||||
DecimalFormat df2 = new DecimalFormat("#,#0.00");
|
||||
DecimalFormat dfn = new DecimalFormat("#,#0.00");
|
||||
dfn.setNegativePrefix(dfn.getNegativePrefix() + '!');
|
||||
testEHCS(df, df2, dfn);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormat.DecimalFormat(DecimalFormat)'
|
||||
*/
|
||||
public void testDecimalFormatDecimalFormat() {
|
||||
// tested implicitly
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormat.DecimalFormat()'
|
||||
*/
|
||||
public void testDecimalFormat() {
|
||||
DecimalFormat df = new DecimalFormat();
|
||||
assertEquals("9,223,372,036,854,775,807", df.format(lmax));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormat.DecimalFormat(String)'
|
||||
*/
|
||||
public void testDecimalFormatString() {
|
||||
DecimalFormat df = new DecimalFormat("#,##0.000");
|
||||
assertEquals("23.330", df.format(dsmall));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormat.DecimalFormat(String, DecimalFormatSymbols)'
|
||||
*/
|
||||
public void testDecimalFormatStringDecimalFormatSymbols() {
|
||||
DecimalFormatSymbols sym = new DecimalFormatSymbols(Locale.FRANCE);
|
||||
DecimalFormat df = new DecimalFormat("#,##0.000", sym);
|
||||
assertEquals("23,330", df.format(dsmall));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormat.getDecimalFormatSymbols()'
|
||||
*/
|
||||
public void testGetDecimalFormatSymbols() {
|
||||
DecimalFormatSymbols sym = new DecimalFormatSymbols(Locale.FRANCE);
|
||||
DecimalFormat df = new DecimalFormat("#,##0.000", sym);
|
||||
assertEquals(sym, df.getDecimalFormatSymbols());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormat.setDecimalFormatSymbols(DecimalFormatSymbols)'
|
||||
*/
|
||||
public void testSetDecimalFormatSymbols() {
|
||||
DecimalFormat df = new DecimalFormat();
|
||||
df.setDecimalFormatSymbols(new DecimalFormatSymbols(Locale.FRANCE));
|
||||
assertEquals("23,33", df.format(dsmall));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormat.getPositivePrefix()'
|
||||
*/
|
||||
public void testGetPositivePrefix() {
|
||||
DecimalFormat df = new DecimalFormat("+#,##0.#;-#,##0.#");
|
||||
assertEquals("+", df.getPositivePrefix());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormat.setPositivePrefix(String)'
|
||||
*/
|
||||
public void testSetPositivePrefix() {
|
||||
DecimalFormat df = new DecimalFormat("+#,##0.#;-#,##0.#");
|
||||
df.setPositivePrefix("?");
|
||||
assertEquals("?23.3", df.format(dsmall));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormat.getNegativePrefix()'
|
||||
*/
|
||||
public void testGetNegativePrefix() {
|
||||
DecimalFormat df = new DecimalFormat("+#,##0.#;-#,##0.#");
|
||||
assertEquals("-", df.getNegativePrefix());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormat.setNegativePrefix(String)'
|
||||
*/
|
||||
public void testSetNegativePrefix() {
|
||||
DecimalFormat df = new DecimalFormat("+#,##0.#;-#,##0.#");
|
||||
df.setNegativePrefix("~");
|
||||
assertEquals("~23.3", df.format(-dsmall));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormat.getPositiveSuffix()'
|
||||
*/
|
||||
public void testGetPositiveSuffix() {
|
||||
DecimalFormat df = new DecimalFormat("+#,##0.#**;-#,##0.#~~");
|
||||
assertEquals("**", df.getPositiveSuffix());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormat.setPositiveSuffix(String)'
|
||||
*/
|
||||
public void testSetPositiveSuffix() {
|
||||
DecimalFormat df = new DecimalFormat("+#,##0.#;-#,##0.#");
|
||||
df.setPositiveSuffix("**");
|
||||
assertEquals("+23.3**", df.format(dsmall));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormat.getNegativeSuffix()'
|
||||
*/
|
||||
public void testGetNegativeSuffix() {
|
||||
DecimalFormat df = new DecimalFormat("+#,##0.#**;-#,##0.#~~");
|
||||
assertEquals("~~", df.getNegativeSuffix());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormat.setNegativeSuffix(String)'
|
||||
*/
|
||||
public void testSetNegativeSuffix() {
|
||||
DecimalFormat df = new DecimalFormat("+#,##0.#;-#,##0.#");
|
||||
df.setNegativeSuffix("~~");
|
||||
assertEquals("-23.3~~", df.format(-dsmall));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormat.getMultiplier()'
|
||||
*/
|
||||
public void testGetMultiplier() {
|
||||
DecimalFormat df = new DecimalFormat("%000");
|
||||
df.setMultiplier(1000);
|
||||
assertEquals(1000, df.getMultiplier());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormat.setMultiplier(int)'
|
||||
*/
|
||||
public void testSetMultiplier() {
|
||||
DecimalFormat df = new DecimalFormat("%000");
|
||||
assertEquals("%012", df.format(.123));
|
||||
df.setMultiplier(1000);
|
||||
assertEquals("%123", df.format(.123));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormat.getGroupingSize()'
|
||||
*/
|
||||
public void testGetGroupingSize() {
|
||||
DecimalFormat df = new DecimalFormat("#,#0.#");
|
||||
assertEquals(2, df.getGroupingSize());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormat.setGroupingSize(int)'
|
||||
*/
|
||||
public void testSetGroupingSize() {
|
||||
DecimalFormat df = new DecimalFormat("#,##0.##");
|
||||
assertEquals("1,234,567.89", df.format(1234567.89));
|
||||
df.setGroupingSize(2);
|
||||
assertEquals("1,23,45,67.89", df.format(1234567.89));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormat.isDecimalSeparatorAlwaysShown()'
|
||||
*/
|
||||
public void testIsDecimalSeparatorAlwaysShown() {
|
||||
DecimalFormat df = new DecimalFormat("#.#");
|
||||
df.setDecimalSeparatorAlwaysShown(false);
|
||||
assertEquals("1", df.format(1));
|
||||
assertEquals("1.2", df.format(1.2));
|
||||
df.setDecimalSeparatorAlwaysShown(true);
|
||||
assertEquals("1.", df.format(1));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormat.setDecimalSeparatorAlwaysShown(boolean)'
|
||||
*/
|
||||
public void testSetDecimalSeparatorAlwaysShown() {
|
||||
DecimalFormat df = new DecimalFormat("#.#");
|
||||
df.setDecimalSeparatorAlwaysShown(false);
|
||||
assertFalse(df.isDecimalSeparatorAlwaysShown());
|
||||
df.setDecimalSeparatorAlwaysShown(true);
|
||||
assertTrue(df.isDecimalSeparatorAlwaysShown());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormat.toPattern()'
|
||||
*/
|
||||
public void testToPattern() {
|
||||
DecimalFormat df = new DecimalFormat("#,##0.##");
|
||||
assertEquals("#,##0.##", df.toPattern());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormat.toLocalizedPattern()'
|
||||
*/
|
||||
public void testToLocalizedPattern() {
|
||||
DecimalFormat df = new DecimalFormat("#,##0.##", new DecimalFormatSymbols(Locale.FRANCE));
|
||||
assertEquals("#,##0.##", df.toPattern());
|
||||
assertEquals("#\u00a0##0,##", df.toLocalizedPattern());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormat.applyPattern(String)'
|
||||
*/
|
||||
public void testApplyPattern() {
|
||||
DecimalFormat df = new DecimalFormat("#,##0.##");
|
||||
df.applyPattern("#,0.#");
|
||||
assertEquals("1,2,3.4", df.format(123.4));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormat.applyLocalizedPattern(String)'
|
||||
*/
|
||||
public void testApplyLocalizedPattern() {
|
||||
DecimalFormat df = new DecimalFormat("#,##0.##", new DecimalFormatSymbols(Locale.FRANCE));
|
||||
df.applyLocalizedPattern("#\u00a00,#");
|
||||
assertEquals("1\u00a02\u00a03,4", df.format(123.4));
|
||||
}
|
||||
}
|
||||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2006-2011, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
package com.ibm.icu.tests;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import com.ibm.icu.text.DecimalFormat;
|
||||
import com.ibm.icu.text.DecimalFormatSymbols;
|
||||
|
||||
public class DecimalFormatTest extends ICUTestCase {
|
||||
private static final long lmax = Long.MAX_VALUE;
|
||||
private static final double dsmall = 23.33;
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormat.clone()'
|
||||
*/
|
||||
public void testClone() {
|
||||
DecimalFormat df = new DecimalFormat("#,#0.00");
|
||||
DecimalFormat df2 = new DecimalFormat("#,#0.00");
|
||||
DecimalFormat dfn = new DecimalFormat("#,#0.00");
|
||||
dfn.setNegativePrefix(dfn.getNegativePrefix() + '!');
|
||||
testEHCS(df, df2, dfn);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormat.DecimalFormat(DecimalFormat)'
|
||||
*/
|
||||
public void testDecimalFormatDecimalFormat() {
|
||||
// tested implicitly
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormat.DecimalFormat()'
|
||||
*/
|
||||
public void testDecimalFormat() {
|
||||
DecimalFormat df = new DecimalFormat();
|
||||
assertEquals("9,223,372,036,854,775,807", df.format(lmax));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormat.DecimalFormat(String)'
|
||||
*/
|
||||
public void testDecimalFormatString() {
|
||||
DecimalFormat df = new DecimalFormat("#,##0.000");
|
||||
assertEquals("23.330", df.format(dsmall));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormat.DecimalFormat(String, DecimalFormatSymbols)'
|
||||
*/
|
||||
public void testDecimalFormatStringDecimalFormatSymbols() {
|
||||
DecimalFormatSymbols sym = new DecimalFormatSymbols(Locale.FRANCE);
|
||||
DecimalFormat df = new DecimalFormat("#,##0.000", sym);
|
||||
assertEquals("23,330", df.format(dsmall));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormat.getDecimalFormatSymbols()'
|
||||
*/
|
||||
public void testGetDecimalFormatSymbols() {
|
||||
DecimalFormatSymbols sym = new DecimalFormatSymbols(Locale.FRANCE);
|
||||
DecimalFormat df = new DecimalFormat("#,##0.000", sym);
|
||||
assertEquals(sym, df.getDecimalFormatSymbols());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormat.setDecimalFormatSymbols(DecimalFormatSymbols)'
|
||||
*/
|
||||
public void testSetDecimalFormatSymbols() {
|
||||
DecimalFormat df = new DecimalFormat();
|
||||
df.setDecimalFormatSymbols(new DecimalFormatSymbols(Locale.FRANCE));
|
||||
assertEquals("23,33", df.format(dsmall));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormat.getPositivePrefix()'
|
||||
*/
|
||||
public void testGetPositivePrefix() {
|
||||
DecimalFormat df = new DecimalFormat("+#,##0.#;-#,##0.#");
|
||||
assertEquals("+", df.getPositivePrefix());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormat.setPositivePrefix(String)'
|
||||
*/
|
||||
public void testSetPositivePrefix() {
|
||||
DecimalFormat df = new DecimalFormat("+#,##0.#;-#,##0.#");
|
||||
df.setPositivePrefix("?");
|
||||
assertEquals("?23.3", df.format(dsmall));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormat.getNegativePrefix()'
|
||||
*/
|
||||
public void testGetNegativePrefix() {
|
||||
DecimalFormat df = new DecimalFormat("+#,##0.#;-#,##0.#");
|
||||
assertEquals("-", df.getNegativePrefix());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormat.setNegativePrefix(String)'
|
||||
*/
|
||||
public void testSetNegativePrefix() {
|
||||
DecimalFormat df = new DecimalFormat("+#,##0.#;-#,##0.#");
|
||||
df.setNegativePrefix("~");
|
||||
assertEquals("~23.3", df.format(-dsmall));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormat.getPositiveSuffix()'
|
||||
*/
|
||||
public void testGetPositiveSuffix() {
|
||||
DecimalFormat df = new DecimalFormat("+#,##0.#**;-#,##0.#~~");
|
||||
assertEquals("**", df.getPositiveSuffix());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormat.setPositiveSuffix(String)'
|
||||
*/
|
||||
public void testSetPositiveSuffix() {
|
||||
DecimalFormat df = new DecimalFormat("+#,##0.#;-#,##0.#");
|
||||
df.setPositiveSuffix("**");
|
||||
assertEquals("+23.3**", df.format(dsmall));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormat.getNegativeSuffix()'
|
||||
*/
|
||||
public void testGetNegativeSuffix() {
|
||||
DecimalFormat df = new DecimalFormat("+#,##0.#**;-#,##0.#~~");
|
||||
assertEquals("~~", df.getNegativeSuffix());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormat.setNegativeSuffix(String)'
|
||||
*/
|
||||
public void testSetNegativeSuffix() {
|
||||
DecimalFormat df = new DecimalFormat("+#,##0.#;-#,##0.#");
|
||||
df.setNegativeSuffix("~~");
|
||||
assertEquals("-23.3~~", df.format(-dsmall));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormat.getMultiplier()'
|
||||
*/
|
||||
public void testGetMultiplier() {
|
||||
DecimalFormat df = new DecimalFormat("%000");
|
||||
df.setMultiplier(1000);
|
||||
assertEquals(1000, df.getMultiplier());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormat.setMultiplier(int)'
|
||||
*/
|
||||
public void testSetMultiplier() {
|
||||
DecimalFormat df = new DecimalFormat("%000");
|
||||
assertEquals("%012", df.format(.123));
|
||||
df.setMultiplier(1000);
|
||||
assertEquals("%123", df.format(.123));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormat.getGroupingSize()'
|
||||
*/
|
||||
public void testGetGroupingSize() {
|
||||
DecimalFormat df = new DecimalFormat("#,#0.#");
|
||||
assertEquals(2, df.getGroupingSize());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormat.setGroupingSize(int)'
|
||||
*/
|
||||
public void testSetGroupingSize() {
|
||||
DecimalFormat df = new DecimalFormat("#,##0.##");
|
||||
assertEquals("1,234,567.89", df.format(1234567.89));
|
||||
df.setGroupingSize(2);
|
||||
assertEquals("1,23,45,67.89", df.format(1234567.89));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormat.isDecimalSeparatorAlwaysShown()'
|
||||
*/
|
||||
public void testIsDecimalSeparatorAlwaysShown() {
|
||||
DecimalFormat df = new DecimalFormat("#.#");
|
||||
df.setDecimalSeparatorAlwaysShown(false);
|
||||
assertEquals("1", df.format(1));
|
||||
assertEquals("1.2", df.format(1.2));
|
||||
df.setDecimalSeparatorAlwaysShown(true);
|
||||
assertEquals("1.", df.format(1));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormat.setDecimalSeparatorAlwaysShown(boolean)'
|
||||
*/
|
||||
public void testSetDecimalSeparatorAlwaysShown() {
|
||||
DecimalFormat df = new DecimalFormat("#.#");
|
||||
df.setDecimalSeparatorAlwaysShown(false);
|
||||
assertFalse(df.isDecimalSeparatorAlwaysShown());
|
||||
df.setDecimalSeparatorAlwaysShown(true);
|
||||
assertTrue(df.isDecimalSeparatorAlwaysShown());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormat.toPattern()'
|
||||
*/
|
||||
public void testToPattern() {
|
||||
DecimalFormat df = new DecimalFormat("#,##0.##");
|
||||
assertEquals("#,##0.##", df.toPattern());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormat.toLocalizedPattern()'
|
||||
*/
|
||||
public void testToLocalizedPattern() {
|
||||
DecimalFormat df = new DecimalFormat("#,##0.##", new DecimalFormatSymbols(Locale.FRANCE));
|
||||
assertEquals("#,##0.##", df.toPattern());
|
||||
assertEquals("#\u00a0##0,##", df.toLocalizedPattern());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormat.applyPattern(String)'
|
||||
*/
|
||||
public void testApplyPattern() {
|
||||
DecimalFormat df = new DecimalFormat("#,##0.##");
|
||||
df.applyPattern("#,0.#");
|
||||
assertEquals("1,2,3.4", df.format(123.4));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.DecimalFormat.applyLocalizedPattern(String)'
|
||||
*/
|
||||
public void testApplyLocalizedPattern() {
|
||||
DecimalFormat df = new DecimalFormat("#,##0.##", new DecimalFormatSymbols(Locale.FRANCE));
|
||||
df.applyLocalizedPattern("#\u00a00,#");
|
||||
assertEquals("1\u00a02\u00a03,4", df.format(123.4));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,286 +1,286 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2006-2011, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
package com.ibm.icu.tests;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.Externalizable;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.io.Serializable;
|
||||
import java.lang.reflect.Array;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Locale;
|
||||
|
||||
import com.ibm.icu.util.TimeZone;
|
||||
import com.ibm.icu.util.ULocale;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
/**
|
||||
* Implement boilerplate tests.
|
||||
* Currently there is only one method, testEHCS, which tests equals, hashCode,
|
||||
* clone, and serialization.
|
||||
*/
|
||||
public abstract class ICUTestCase extends TestCase {
|
||||
private static final Object[] EMPTY_ARGS = {};
|
||||
private static final Class<?>[] EMPTY_CLASSES = {};
|
||||
|
||||
private static final Locale oldLocale = Locale.getDefault();
|
||||
private static final ULocale oldULocale = ULocale.getDefault();
|
||||
private static final java.util.TimeZone oldJTimeZone = java.util.TimeZone.getDefault();
|
||||
private static final TimeZone oldITimeZone = TimeZone.getDefault();
|
||||
|
||||
// TODO: what's the best way to check this?
|
||||
public static final boolean testingWrapper = true;
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
Locale.setDefault(Locale.US);
|
||||
ULocale.setDefault(ULocale.US);
|
||||
java.util.TimeZone.setDefault(java.util.TimeZone.getTimeZone("PST"));
|
||||
TimeZone.setDefault(TimeZone.getTimeZone("PST"));
|
||||
}
|
||||
|
||||
protected void tearDown() throws Exception {
|
||||
ULocale.setDefault(oldULocale);
|
||||
Locale.setDefault(oldLocale);
|
||||
TimeZone.setDefault(oldITimeZone);
|
||||
java.util.TimeZone.setDefault(oldJTimeZone);
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
private static final Object test = new Object();
|
||||
|
||||
/**
|
||||
* Assert that two objects are _not_ equal. Curiously missing from Assert.
|
||||
* @param lhs an object to test, may be null
|
||||
* @param rhs an object to test, may be null
|
||||
*/
|
||||
public static void assertNotEqual(Object lhs, Object rhs) {
|
||||
if (lhs == null) {
|
||||
if (rhs == null) fail("null equals null");
|
||||
} else {
|
||||
if (lhs.equals(rhs)) {
|
||||
fail(lhs.toString() + " equals " + rhs);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void assertNotEqual(long lhs, long rhs) {
|
||||
if (lhs == rhs) {
|
||||
fail("values are equal: " + lhs);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test whether equality, hashCode, clone, and serialization work as expected.
|
||||
* Equals(Object) is assumed to return false (not throw an exception) if passed
|
||||
* null or an object of an incompatible class.
|
||||
* Hashcodes must be equal iff the two objects compare equal. No attempt is made to
|
||||
* evaluate the quality of the hashcode distribution, so (in particular) degenerate
|
||||
* hashcode implementations will pass this test.
|
||||
* Clone will be tested if the method "clone" is public on the class of obj.
|
||||
* It is assumed to return an object that compares equal to obj.
|
||||
* Serialization will be tested if object implements Serializable or Externalizable.
|
||||
* It is assumed the serialized/deserialized object compares equal to obj.
|
||||
* @param obj the object to test
|
||||
* @param eq an object that should compare equal to, but is not the same as, obj.
|
||||
* it should be assignable to the class of obj.
|
||||
* @param neq a non-null object that should not compare equal to obj.
|
||||
* it should be assignable to the class of obj.
|
||||
*/
|
||||
public static void testEHCS(Object obj, Object eq, Object neq) {
|
||||
if (obj == null || eq == null || neq == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
Class<? extends Object> cls = obj.getClass();
|
||||
if (!(cls.isAssignableFrom(eq.getClass()) && cls.isAssignableFrom(neq.getClass()))) {
|
||||
throw new IllegalArgumentException("unassignable classes");
|
||||
}
|
||||
|
||||
// reflexive
|
||||
assertEquals(obj, obj);
|
||||
|
||||
// should return false, not throw exception
|
||||
assertNotEqual(obj, test);
|
||||
assertNotEqual(obj, null);
|
||||
|
||||
// commutative
|
||||
assertEquals(obj, eq);
|
||||
assertEquals(eq, obj);
|
||||
|
||||
assertNotEqual(obj, neq);
|
||||
assertNotEqual(neq, obj);
|
||||
|
||||
// equal objects MUST have equal hashes, unequal objects MAY have equal hashes
|
||||
assertEquals(obj.hashCode(), eq.hashCode());
|
||||
|
||||
Object clone = null;
|
||||
try {
|
||||
// look for public clone method and call it if available
|
||||
Method method_clone = cls.getMethod("clone", EMPTY_CLASSES);
|
||||
clone = method_clone.invoke(obj, EMPTY_ARGS);
|
||||
assertNotNull(clone);
|
||||
}
|
||||
catch(NoSuchMethodException e) {
|
||||
// ok
|
||||
}
|
||||
catch(InvocationTargetException e) {
|
||||
// ok
|
||||
}
|
||||
catch(IllegalAccessException e) {
|
||||
// ok
|
||||
}
|
||||
|
||||
if (clone != null) {
|
||||
assertEquals(obj, clone);
|
||||
assertEquals(clone, obj);
|
||||
}
|
||||
|
||||
if (obj instanceof Serializable || obj instanceof Externalizable) {
|
||||
Object ser = null;
|
||||
try {
|
||||
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
||||
ObjectOutputStream oos = new ObjectOutputStream(bos);
|
||||
oos.writeObject(clone);
|
||||
oos.close();
|
||||
|
||||
ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
|
||||
ObjectInputStream ois = new ObjectInputStream(bis);
|
||||
ser = ois.readObject();
|
||||
ois.close();
|
||||
}
|
||||
catch(IOException e) {
|
||||
System.err.println(e.getMessage());
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
catch(ClassNotFoundException e) {
|
||||
System.err.println(e.getMessage());
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
if (ser != null) {
|
||||
assertEquals(obj, ser);
|
||||
assertEquals(ser, obj);
|
||||
assertEquals(obj.hashCode(), ser.hashCode());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fail if the arrays are not equal. To be equal, the arrays must
|
||||
* be the same length, and each element in the left array must compare
|
||||
* equal to the corresponding element of the right array.
|
||||
* Also fails if one of the objects is not an array.
|
||||
* @param lhs the left array
|
||||
* @param rhs the right array
|
||||
*/
|
||||
public static void assertArraysEqual(Object lhs, Object rhs) {
|
||||
Class<? extends Object> lcls = lhs.getClass();
|
||||
Class<? extends Object> rcls = rhs.getClass();
|
||||
if (!(lcls.isArray() && rcls.isArray())) {
|
||||
fail("objects are not arrays");
|
||||
}
|
||||
String result = arraysAreEqual(lhs, rhs);
|
||||
if (result != null) {
|
||||
fail(result);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fail if the arrays are equal. Also fails if one or the other
|
||||
* argument is not an array.
|
||||
* @param lhs the left array
|
||||
* @param rhs the right array
|
||||
*/
|
||||
public static void assertArraysNotEqual(Object lhs, Object rhs) {
|
||||
Class<? extends Object> lcls = lhs.getClass();
|
||||
Class<? extends Object> rcls = rhs.getClass();
|
||||
if (!(lcls.isArray() && rcls.isArray())) {
|
||||
fail("objects are not arrays");
|
||||
}
|
||||
String result = arraysAreEqual(lhs, rhs);
|
||||
if (result == null) {
|
||||
fail("arrays are equal");
|
||||
}
|
||||
}
|
||||
|
||||
// slow but general
|
||||
private static String arraysAreEqual(Object lhsa, Object rhsa) {
|
||||
int lhsl = Array.getLength(lhsa);
|
||||
int rhsl = Array.getLength(rhsa);
|
||||
if (lhsl != rhsl) {
|
||||
return "length " + lhsl + " != " + rhsl;
|
||||
}
|
||||
boolean lhsaA = lhsa.getClass().getComponentType().isArray();
|
||||
boolean rhsaA = rhsa.getClass().getComponentType().isArray();
|
||||
if (lhsaA != rhsaA) {
|
||||
return (lhsaA ? "" : "non-") + "array != " + (rhsaA ? "" : "non-") + "array";
|
||||
}
|
||||
for (int i = 0; i < lhsl; ++i) {
|
||||
Object lhse = Array.get(lhsa, i);
|
||||
Object rhse = Array.get(rhsa, i);
|
||||
if (lhse == null) {
|
||||
if (rhse != null) {
|
||||
return "null != " + rhse;
|
||||
}
|
||||
} else {
|
||||
if (lhsaA) {
|
||||
String result = arraysAreEqual(lhse, rhse);
|
||||
if (result != null) {
|
||||
if (result.charAt(0) != '[') {
|
||||
result = " " + result;
|
||||
}
|
||||
return "[" + i + "]" + result;
|
||||
}
|
||||
} else {
|
||||
if (!lhse.equals(rhse)) {
|
||||
return lhse.toString() + " != " + rhse;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// much more painful and slow than it should be... partly because of the
|
||||
// oddness of clone, partly because arrays don't provide a Method for
|
||||
// 'clone' despite the fact that they implement it and make it public.
|
||||
public static Object cloneComplex(Object obj) {
|
||||
Object result = null;
|
||||
if (obj != null) {
|
||||
Class<? extends Object> cls = obj.getClass();
|
||||
if (cls.isArray()) {
|
||||
int len = Array.getLength(obj);
|
||||
Class<?> typ = cls.getComponentType();
|
||||
result = Array.newInstance(typ, len);
|
||||
boolean prim = typ.isPrimitive();
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Object elem = Array.get(obj, i);
|
||||
Array.set(result, i, prim ? elem : cloneComplex(elem));
|
||||
}
|
||||
} else {
|
||||
result = obj; // default
|
||||
try {
|
||||
Method cloneM = cls.getMethod("clone", EMPTY_CLASSES);
|
||||
result = cloneM.invoke(obj, EMPTY_ARGS);
|
||||
}
|
||||
catch (NoSuchMethodException e) {
|
||||
}
|
||||
catch (IllegalAccessException e) {
|
||||
}
|
||||
catch (InvocationTargetException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2006-2011, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
package com.ibm.icu.tests;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.Externalizable;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.io.Serializable;
|
||||
import java.lang.reflect.Array;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Locale;
|
||||
|
||||
import com.ibm.icu.util.TimeZone;
|
||||
import com.ibm.icu.util.ULocale;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
/**
|
||||
* Implement boilerplate tests.
|
||||
* Currently there is only one method, testEHCS, which tests equals, hashCode,
|
||||
* clone, and serialization.
|
||||
*/
|
||||
public abstract class ICUTestCase extends TestCase {
|
||||
private static final Object[] EMPTY_ARGS = {};
|
||||
private static final Class<?>[] EMPTY_CLASSES = {};
|
||||
|
||||
private static final Locale oldLocale = Locale.getDefault();
|
||||
private static final ULocale oldULocale = ULocale.getDefault();
|
||||
private static final java.util.TimeZone oldJTimeZone = java.util.TimeZone.getDefault();
|
||||
private static final TimeZone oldITimeZone = TimeZone.getDefault();
|
||||
|
||||
// TODO: what's the best way to check this?
|
||||
public static final boolean testingWrapper = true;
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
Locale.setDefault(Locale.US);
|
||||
ULocale.setDefault(ULocale.US);
|
||||
java.util.TimeZone.setDefault(java.util.TimeZone.getTimeZone("PST"));
|
||||
TimeZone.setDefault(TimeZone.getTimeZone("PST"));
|
||||
}
|
||||
|
||||
protected void tearDown() throws Exception {
|
||||
ULocale.setDefault(oldULocale);
|
||||
Locale.setDefault(oldLocale);
|
||||
TimeZone.setDefault(oldITimeZone);
|
||||
java.util.TimeZone.setDefault(oldJTimeZone);
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
private static final Object test = new Object();
|
||||
|
||||
/**
|
||||
* Assert that two objects are _not_ equal. Curiously missing from Assert.
|
||||
* @param lhs an object to test, may be null
|
||||
* @param rhs an object to test, may be null
|
||||
*/
|
||||
public static void assertNotEqual(Object lhs, Object rhs) {
|
||||
if (lhs == null) {
|
||||
if (rhs == null) fail("null equals null");
|
||||
} else {
|
||||
if (lhs.equals(rhs)) {
|
||||
fail(lhs.toString() + " equals " + rhs);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void assertNotEqual(long lhs, long rhs) {
|
||||
if (lhs == rhs) {
|
||||
fail("values are equal: " + lhs);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test whether equality, hashCode, clone, and serialization work as expected.
|
||||
* Equals(Object) is assumed to return false (not throw an exception) if passed
|
||||
* null or an object of an incompatible class.
|
||||
* Hashcodes must be equal iff the two objects compare equal. No attempt is made to
|
||||
* evaluate the quality of the hashcode distribution, so (in particular) degenerate
|
||||
* hashcode implementations will pass this test.
|
||||
* Clone will be tested if the method "clone" is public on the class of obj.
|
||||
* It is assumed to return an object that compares equal to obj.
|
||||
* Serialization will be tested if object implements Serializable or Externalizable.
|
||||
* It is assumed the serialized/deserialized object compares equal to obj.
|
||||
* @param obj the object to test
|
||||
* @param eq an object that should compare equal to, but is not the same as, obj.
|
||||
* it should be assignable to the class of obj.
|
||||
* @param neq a non-null object that should not compare equal to obj.
|
||||
* it should be assignable to the class of obj.
|
||||
*/
|
||||
public static void testEHCS(Object obj, Object eq, Object neq) {
|
||||
if (obj == null || eq == null || neq == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
Class<? extends Object> cls = obj.getClass();
|
||||
if (!(cls.isAssignableFrom(eq.getClass()) && cls.isAssignableFrom(neq.getClass()))) {
|
||||
throw new IllegalArgumentException("unassignable classes");
|
||||
}
|
||||
|
||||
// reflexive
|
||||
assertEquals(obj, obj);
|
||||
|
||||
// should return false, not throw exception
|
||||
assertNotEqual(obj, test);
|
||||
assertNotEqual(obj, null);
|
||||
|
||||
// commutative
|
||||
assertEquals(obj, eq);
|
||||
assertEquals(eq, obj);
|
||||
|
||||
assertNotEqual(obj, neq);
|
||||
assertNotEqual(neq, obj);
|
||||
|
||||
// equal objects MUST have equal hashes, unequal objects MAY have equal hashes
|
||||
assertEquals(obj.hashCode(), eq.hashCode());
|
||||
|
||||
Object clone = null;
|
||||
try {
|
||||
// look for public clone method and call it if available
|
||||
Method method_clone = cls.getMethod("clone", EMPTY_CLASSES);
|
||||
clone = method_clone.invoke(obj, EMPTY_ARGS);
|
||||
assertNotNull(clone);
|
||||
}
|
||||
catch(NoSuchMethodException e) {
|
||||
// ok
|
||||
}
|
||||
catch(InvocationTargetException e) {
|
||||
// ok
|
||||
}
|
||||
catch(IllegalAccessException e) {
|
||||
// ok
|
||||
}
|
||||
|
||||
if (clone != null) {
|
||||
assertEquals(obj, clone);
|
||||
assertEquals(clone, obj);
|
||||
}
|
||||
|
||||
if (obj instanceof Serializable || obj instanceof Externalizable) {
|
||||
Object ser = null;
|
||||
try {
|
||||
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
||||
ObjectOutputStream oos = new ObjectOutputStream(bos);
|
||||
oos.writeObject(clone);
|
||||
oos.close();
|
||||
|
||||
ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
|
||||
ObjectInputStream ois = new ObjectInputStream(bis);
|
||||
ser = ois.readObject();
|
||||
ois.close();
|
||||
}
|
||||
catch(IOException e) {
|
||||
System.err.println(e.getMessage());
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
catch(ClassNotFoundException e) {
|
||||
System.err.println(e.getMessage());
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
if (ser != null) {
|
||||
assertEquals(obj, ser);
|
||||
assertEquals(ser, obj);
|
||||
assertEquals(obj.hashCode(), ser.hashCode());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fail if the arrays are not equal. To be equal, the arrays must
|
||||
* be the same length, and each element in the left array must compare
|
||||
* equal to the corresponding element of the right array.
|
||||
* Also fails if one of the objects is not an array.
|
||||
* @param lhs the left array
|
||||
* @param rhs the right array
|
||||
*/
|
||||
public static void assertArraysEqual(Object lhs, Object rhs) {
|
||||
Class<? extends Object> lcls = lhs.getClass();
|
||||
Class<? extends Object> rcls = rhs.getClass();
|
||||
if (!(lcls.isArray() && rcls.isArray())) {
|
||||
fail("objects are not arrays");
|
||||
}
|
||||
String result = arraysAreEqual(lhs, rhs);
|
||||
if (result != null) {
|
||||
fail(result);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fail if the arrays are equal. Also fails if one or the other
|
||||
* argument is not an array.
|
||||
* @param lhs the left array
|
||||
* @param rhs the right array
|
||||
*/
|
||||
public static void assertArraysNotEqual(Object lhs, Object rhs) {
|
||||
Class<? extends Object> lcls = lhs.getClass();
|
||||
Class<? extends Object> rcls = rhs.getClass();
|
||||
if (!(lcls.isArray() && rcls.isArray())) {
|
||||
fail("objects are not arrays");
|
||||
}
|
||||
String result = arraysAreEqual(lhs, rhs);
|
||||
if (result == null) {
|
||||
fail("arrays are equal");
|
||||
}
|
||||
}
|
||||
|
||||
// slow but general
|
||||
private static String arraysAreEqual(Object lhsa, Object rhsa) {
|
||||
int lhsl = Array.getLength(lhsa);
|
||||
int rhsl = Array.getLength(rhsa);
|
||||
if (lhsl != rhsl) {
|
||||
return "length " + lhsl + " != " + rhsl;
|
||||
}
|
||||
boolean lhsaA = lhsa.getClass().getComponentType().isArray();
|
||||
boolean rhsaA = rhsa.getClass().getComponentType().isArray();
|
||||
if (lhsaA != rhsaA) {
|
||||
return (lhsaA ? "" : "non-") + "array != " + (rhsaA ? "" : "non-") + "array";
|
||||
}
|
||||
for (int i = 0; i < lhsl; ++i) {
|
||||
Object lhse = Array.get(lhsa, i);
|
||||
Object rhse = Array.get(rhsa, i);
|
||||
if (lhse == null) {
|
||||
if (rhse != null) {
|
||||
return "null != " + rhse;
|
||||
}
|
||||
} else {
|
||||
if (lhsaA) {
|
||||
String result = arraysAreEqual(lhse, rhse);
|
||||
if (result != null) {
|
||||
if (result.charAt(0) != '[') {
|
||||
result = " " + result;
|
||||
}
|
||||
return "[" + i + "]" + result;
|
||||
}
|
||||
} else {
|
||||
if (!lhse.equals(rhse)) {
|
||||
return lhse.toString() + " != " + rhse;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// much more painful and slow than it should be... partly because of the
|
||||
// oddness of clone, partly because arrays don't provide a Method for
|
||||
// 'clone' despite the fact that they implement it and make it public.
|
||||
public static Object cloneComplex(Object obj) {
|
||||
Object result = null;
|
||||
if (obj != null) {
|
||||
Class<? extends Object> cls = obj.getClass();
|
||||
if (cls.isArray()) {
|
||||
int len = Array.getLength(obj);
|
||||
Class<?> typ = cls.getComponentType();
|
||||
result = Array.newInstance(typ, len);
|
||||
boolean prim = typ.isPrimitive();
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Object elem = Array.get(obj, i);
|
||||
Array.set(result, i, prim ? elem : cloneComplex(elem));
|
||||
}
|
||||
} else {
|
||||
result = obj; // default
|
||||
try {
|
||||
Method cloneM = cls.getMethod("clone", EMPTY_CLASSES);
|
||||
result = cloneM.invoke(obj, EMPTY_ARGS);
|
||||
}
|
||||
catch (NoSuchMethodException e) {
|
||||
}
|
||||
catch (IllegalAccessException e) {
|
||||
}
|
||||
catch (InvocationTargetException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,307 +1,307 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2006-2011, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
package com.ibm.icu.tests;
|
||||
|
||||
import java.text.FieldPosition;
|
||||
import java.text.Format;
|
||||
import java.text.ParseException;
|
||||
import java.text.ParsePosition;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
|
||||
import com.ibm.icu.text.DateFormat;
|
||||
import com.ibm.icu.text.MessageFormat;
|
||||
import com.ibm.icu.text.NumberFormat;
|
||||
import com.ibm.icu.util.ULocale;
|
||||
|
||||
public class MessageFormatTest extends ICUTestCase {
|
||||
private final String pattern = "Deleted {0,number} files at {1,time,short} on {1,date}.";
|
||||
private final String altPattern = "Deleted {0, number } files at {1, time, short} on {1, date}.";
|
||||
private final Date date = new Date(716698890835L);
|
||||
private final Number num = new Long(3456);
|
||||
private final Object[] args = { num, date };
|
||||
private final Date dateOnly = new Date(716626800000L);
|
||||
private final String englishTarget = "Deleted 3,456 files at 8:01 PM on Sep 16, 1992.";
|
||||
private final String germanTarget = "Deleted 3.456 files at 20:01 on 16.09.1992.";
|
||||
private final String modifiedTarget = "Deleted 3,456 files at 8:01:30 PM PDT on Sep 16, 1992.";
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.MessageFormat.hashCode()'
|
||||
*/
|
||||
public void testHashCode() {
|
||||
MessageFormat mf = new MessageFormat(pattern);
|
||||
MessageFormat eq = new MessageFormat(altPattern);
|
||||
MessageFormat ne = new MessageFormat("Deleted (0, number, currency} files at {1, time} on {1, date}.");
|
||||
testEHCS(mf, eq, ne);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.MessageFormat.MessageFormat(MessageFormat)'
|
||||
*/
|
||||
public void testMessageFormatMessageFormat() {
|
||||
// implicitly tested everywhere
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.MessageFormat.MessageFormat(String)'
|
||||
*/
|
||||
public void testMessageFormatString() {
|
||||
MessageFormat mf = new MessageFormat(pattern);
|
||||
assertEquals(englishTarget, mf.format(args));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.MessageFormat.MessageFormat(String, Locale)'
|
||||
*/
|
||||
public void testMessageFormatStringLocale() {
|
||||
MessageFormat mf = new MessageFormat(pattern, Locale.US);
|
||||
assertEquals(englishTarget, mf.format(args));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.MessageFormat.MessageFormat(String, ULocale)'
|
||||
*/
|
||||
public void testMessageFormatStringULocale() {
|
||||
MessageFormat mf = new MessageFormat(pattern, ULocale.US);
|
||||
assertEquals(englishTarget, mf.format(args));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.MessageFormat.setLocale(Locale)'
|
||||
*/
|
||||
public void testSetLocaleLocale() {
|
||||
MessageFormat mf = new MessageFormat(pattern, Locale.US);
|
||||
mf.setLocale(Locale.GERMANY);
|
||||
mf.applyPattern(pattern);
|
||||
assertEquals(germanTarget, mf.format(args));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.MessageFormat.setLocale(ULocale)'
|
||||
*/
|
||||
public void testSetLocaleULocale() {
|
||||
MessageFormat mf = new MessageFormat(pattern, Locale.US);
|
||||
mf.setLocale(ULocale.GERMANY);
|
||||
mf.applyPattern(pattern);
|
||||
assertEquals(germanTarget, mf.format(args));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.MessageFormat.getLocale()'
|
||||
*/
|
||||
public void testGetLocale() {
|
||||
MessageFormat mf = new MessageFormat(pattern, Locale.US);
|
||||
mf.setLocale(Locale.GERMANY);
|
||||
assertEquals(Locale.GERMANY, mf.getLocale());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.MessageFormat.getULocale()'
|
||||
*/
|
||||
public void testGetULocale() {
|
||||
MessageFormat mf = new MessageFormat(pattern, Locale.US);
|
||||
mf.setLocale(ULocale.GERMANY);
|
||||
assertEquals(ULocale.GERMANY, mf.getULocale());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.MessageFormat.applyPattern(String)'
|
||||
*/
|
||||
public void testApplyPattern() {
|
||||
MessageFormat mf = new MessageFormat("foo");
|
||||
mf.applyPattern(pattern);
|
||||
assertEquals(englishTarget, mf.format(args));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.MessageFormat.toPattern()'
|
||||
*/
|
||||
public void testToPattern() {
|
||||
MessageFormat mf = new MessageFormat(altPattern);
|
||||
assertEquals(pattern, mf.toPattern());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.MessageFormat.setFormatsByArgumentIndex(Format[])'
|
||||
public void testSetFormatsByArgumentIndex() {
|
||||
// this api is broken. if the same argument is used twice with two different
|
||||
// formats, this can't be used, since it sets only one format per argument.
|
||||
MessageFormat mf = new MessageFormat(pattern, Locale.US);
|
||||
Format[] formats = {
|
||||
NumberFormat.getIntegerInstance(),
|
||||
DateFormat.getTimeInstance(DateFormat.SHORT),
|
||||
DateFormat.getDateInstance(),
|
||||
};
|
||||
mf.setFormatsByArgumentIndex(formats);
|
||||
assertEquals(brokenButConformantTarget, mf.format(args));
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.MessageFormat.setFormats(Format[])'
|
||||
*/
|
||||
public void testSetFormats() {
|
||||
// this api, while it has the problem that the order of formats depends
|
||||
// on the order in the string, at least lets you set all the formats.
|
||||
|
||||
MessageFormat mf = new MessageFormat(pattern, Locale.US);
|
||||
Format[] formats = {
|
||||
NumberFormat.getIntegerInstance(),
|
||||
DateFormat.getTimeInstance(DateFormat.SHORT),
|
||||
DateFormat.getDateInstance(),
|
||||
};
|
||||
mf.setFormats(formats);
|
||||
assertEquals(englishTarget, mf.format(args));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.MessageFormat.setFormatByArgumentIndex(int, Format)'
|
||||
public void testSetFormatByArgumentIndex() {
|
||||
// same problem, once you set a format for an argument, you've set all of them
|
||||
|
||||
MessageFormat mf = new MessageFormat(pattern, Locale.US);
|
||||
mf.setFormatByArgumentIndex(1, DateFormat.getTimeInstance(DateFormat.SHORT));
|
||||
assertEquals(brokenButConformantTarget, mf.format(args));
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.MessageFormat.setFormat(int, Format)'
|
||||
*/
|
||||
public void testSetFormat() {
|
||||
// and ok again
|
||||
MessageFormat mf = new MessageFormat(pattern, Locale.US);
|
||||
mf.setFormat(1, DateFormat.getTimeInstance(DateFormat.LONG));
|
||||
assertEquals(modifiedTarget, mf.format(args));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.MessageFormat.getFormatsByArgumentIndex()'
|
||||
public void testGetFormatsByArgumentIndex() {
|
||||
MessageFormat mf = new MessageFormat(pattern, Locale.US);
|
||||
Format[] formats = mf.getFormatsByArgumentIndex();
|
||||
NumberFormat nf = NumberFormat.getNumberInstance(Locale.US);
|
||||
assertEquals(formats[0], nf);
|
||||
DateFormat df = DateFormat.getDateInstance(DateFormat.DEFAULT, Locale.US);
|
||||
assertEquals(formats[1], df);
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.MessageFormat.getFormats()'
|
||||
*/
|
||||
public void testGetFormats() {
|
||||
MessageFormat mf = new MessageFormat(pattern, Locale.US);
|
||||
Format[] formats = mf.getFormats();
|
||||
NumberFormat nf = NumberFormat.getNumberInstance(Locale.US);
|
||||
assertEquals(formats[0], nf);
|
||||
DateFormat tf = DateFormat.getTimeInstance(DateFormat.SHORT, Locale.US);
|
||||
assertEquals(formats[1], tf);
|
||||
DateFormat df = DateFormat.getDateInstance(DateFormat.DEFAULT, Locale.US);
|
||||
assertEquals(formats[2], df);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.MessageFormat.format(Object[], StringBuffer, FieldPosition)'
|
||||
*/
|
||||
public void testFormatObjectArrayStringBufferFieldPosition() {
|
||||
MessageFormat mf = new MessageFormat(pattern, Locale.US);
|
||||
StringBuffer buf = new StringBuffer();
|
||||
FieldPosition fp = new FieldPosition(0);
|
||||
mf.format(args, buf, fp);
|
||||
assertEquals(englishTarget, buf.toString());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.MessageFormat.format(String, Object[])'
|
||||
*/
|
||||
public void testFormatStringObjectArray() {
|
||||
assertEquals(englishTarget, MessageFormat.format(pattern, args));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.MessageFormat.format(Object, StringBuffer, FieldPosition)'
|
||||
*/
|
||||
public void testFormatObjectStringBufferFieldPosition() {
|
||||
MessageFormat mf = new MessageFormat(pattern, Locale.US);
|
||||
StringBuffer buf = new StringBuffer();
|
||||
FieldPosition fp = new FieldPosition(0);
|
||||
mf.format((Object)args, buf, fp);
|
||||
assertEquals(englishTarget, buf.toString());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.MessageFormat.parse(String, ParsePosition)'
|
||||
*/
|
||||
public void testParseStringParsePosition() {
|
||||
MessageFormat mf = new MessageFormat(pattern, Locale.US);
|
||||
ParsePosition pp = new ParsePosition(1);
|
||||
Object[] result = mf.parse("!" + englishTarget, pp);
|
||||
assertEquals(num, result[0]);
|
||||
assertEquals(dateOnly, result[1]);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.MessageFormat.parse(String)'
|
||||
*/
|
||||
public void testParseString() {
|
||||
MessageFormat mf = new MessageFormat(pattern, Locale.US);
|
||||
try {
|
||||
Object[] result = mf.parse(englishTarget);
|
||||
assertEquals(num, result[0]);
|
||||
assertEquals(dateOnly, result[1]);
|
||||
}
|
||||
catch (ParseException e) {
|
||||
fail(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.MessageFormat.parseObject(String, ParsePosition)'
|
||||
*/
|
||||
public void testParseObjectStringParsePosition() {
|
||||
MessageFormat mf = new MessageFormat(pattern, Locale.US);
|
||||
ParsePosition pp = new ParsePosition(0);
|
||||
Object result = mf.parseObject(englishTarget, pp);
|
||||
assertEquals(num, ((Object[])result)[0]);
|
||||
assertEquals(dateOnly, ((Object[])result)[1]);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.MessageFormat.autoQuoteApostrophe(String)'
|
||||
*/
|
||||
public void testAutoQuoteApostrophe() {
|
||||
String str = "Let's meet at {1,time,h 'o'' clock'} at l'Orange Bleue";
|
||||
String pat = MessageFormat.autoQuoteApostrophe(str);
|
||||
MessageFormat mf = new MessageFormat(pat, Locale.US);
|
||||
String result = mf.format(args);
|
||||
assertEquals("Let's meet at 8 o' clock at l'Orange Bleue", result);
|
||||
assertEquals("Let''s meet at {1,time,h 'o'' clock'} at l''Orange Bleue", pat);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.MessageFormat.clone()'
|
||||
*/
|
||||
public void testClone() {
|
||||
// tested already in testHashcode
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.MessageFormat.equals(Object)'
|
||||
*/
|
||||
public void testEqualsObject() {
|
||||
// tested already in testHashcode
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.MessageFormat.toString()'
|
||||
*/
|
||||
public void testToString() {
|
||||
// no need to test
|
||||
}
|
||||
}
|
||||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2006-2011, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
package com.ibm.icu.tests;
|
||||
|
||||
import java.text.FieldPosition;
|
||||
import java.text.Format;
|
||||
import java.text.ParseException;
|
||||
import java.text.ParsePosition;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
|
||||
import com.ibm.icu.text.DateFormat;
|
||||
import com.ibm.icu.text.MessageFormat;
|
||||
import com.ibm.icu.text.NumberFormat;
|
||||
import com.ibm.icu.util.ULocale;
|
||||
|
||||
public class MessageFormatTest extends ICUTestCase {
|
||||
private final String pattern = "Deleted {0,number} files at {1,time,short} on {1,date}.";
|
||||
private final String altPattern = "Deleted {0, number } files at {1, time, short} on {1, date}.";
|
||||
private final Date date = new Date(716698890835L);
|
||||
private final Number num = new Long(3456);
|
||||
private final Object[] args = { num, date };
|
||||
private final Date dateOnly = new Date(716626800000L);
|
||||
private final String englishTarget = "Deleted 3,456 files at 8:01 PM on Sep 16, 1992.";
|
||||
private final String germanTarget = "Deleted 3.456 files at 20:01 on 16.09.1992.";
|
||||
private final String modifiedTarget = "Deleted 3,456 files at 8:01:30 PM PDT on Sep 16, 1992.";
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.MessageFormat.hashCode()'
|
||||
*/
|
||||
public void testHashCode() {
|
||||
MessageFormat mf = new MessageFormat(pattern);
|
||||
MessageFormat eq = new MessageFormat(altPattern);
|
||||
MessageFormat ne = new MessageFormat("Deleted (0, number, currency} files at {1, time} on {1, date}.");
|
||||
testEHCS(mf, eq, ne);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.MessageFormat.MessageFormat(MessageFormat)'
|
||||
*/
|
||||
public void testMessageFormatMessageFormat() {
|
||||
// implicitly tested everywhere
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.MessageFormat.MessageFormat(String)'
|
||||
*/
|
||||
public void testMessageFormatString() {
|
||||
MessageFormat mf = new MessageFormat(pattern);
|
||||
assertEquals(englishTarget, mf.format(args));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.MessageFormat.MessageFormat(String, Locale)'
|
||||
*/
|
||||
public void testMessageFormatStringLocale() {
|
||||
MessageFormat mf = new MessageFormat(pattern, Locale.US);
|
||||
assertEquals(englishTarget, mf.format(args));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.MessageFormat.MessageFormat(String, ULocale)'
|
||||
*/
|
||||
public void testMessageFormatStringULocale() {
|
||||
MessageFormat mf = new MessageFormat(pattern, ULocale.US);
|
||||
assertEquals(englishTarget, mf.format(args));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.MessageFormat.setLocale(Locale)'
|
||||
*/
|
||||
public void testSetLocaleLocale() {
|
||||
MessageFormat mf = new MessageFormat(pattern, Locale.US);
|
||||
mf.setLocale(Locale.GERMANY);
|
||||
mf.applyPattern(pattern);
|
||||
assertEquals(germanTarget, mf.format(args));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.MessageFormat.setLocale(ULocale)'
|
||||
*/
|
||||
public void testSetLocaleULocale() {
|
||||
MessageFormat mf = new MessageFormat(pattern, Locale.US);
|
||||
mf.setLocale(ULocale.GERMANY);
|
||||
mf.applyPattern(pattern);
|
||||
assertEquals(germanTarget, mf.format(args));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.MessageFormat.getLocale()'
|
||||
*/
|
||||
public void testGetLocale() {
|
||||
MessageFormat mf = new MessageFormat(pattern, Locale.US);
|
||||
mf.setLocale(Locale.GERMANY);
|
||||
assertEquals(Locale.GERMANY, mf.getLocale());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.MessageFormat.getULocale()'
|
||||
*/
|
||||
public void testGetULocale() {
|
||||
MessageFormat mf = new MessageFormat(pattern, Locale.US);
|
||||
mf.setLocale(ULocale.GERMANY);
|
||||
assertEquals(ULocale.GERMANY, mf.getULocale());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.MessageFormat.applyPattern(String)'
|
||||
*/
|
||||
public void testApplyPattern() {
|
||||
MessageFormat mf = new MessageFormat("foo");
|
||||
mf.applyPattern(pattern);
|
||||
assertEquals(englishTarget, mf.format(args));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.MessageFormat.toPattern()'
|
||||
*/
|
||||
public void testToPattern() {
|
||||
MessageFormat mf = new MessageFormat(altPattern);
|
||||
assertEquals(pattern, mf.toPattern());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.MessageFormat.setFormatsByArgumentIndex(Format[])'
|
||||
public void testSetFormatsByArgumentIndex() {
|
||||
// this api is broken. if the same argument is used twice with two different
|
||||
// formats, this can't be used, since it sets only one format per argument.
|
||||
MessageFormat mf = new MessageFormat(pattern, Locale.US);
|
||||
Format[] formats = {
|
||||
NumberFormat.getIntegerInstance(),
|
||||
DateFormat.getTimeInstance(DateFormat.SHORT),
|
||||
DateFormat.getDateInstance(),
|
||||
};
|
||||
mf.setFormatsByArgumentIndex(formats);
|
||||
assertEquals(brokenButConformantTarget, mf.format(args));
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.MessageFormat.setFormats(Format[])'
|
||||
*/
|
||||
public void testSetFormats() {
|
||||
// this api, while it has the problem that the order of formats depends
|
||||
// on the order in the string, at least lets you set all the formats.
|
||||
|
||||
MessageFormat mf = new MessageFormat(pattern, Locale.US);
|
||||
Format[] formats = {
|
||||
NumberFormat.getIntegerInstance(),
|
||||
DateFormat.getTimeInstance(DateFormat.SHORT),
|
||||
DateFormat.getDateInstance(),
|
||||
};
|
||||
mf.setFormats(formats);
|
||||
assertEquals(englishTarget, mf.format(args));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.MessageFormat.setFormatByArgumentIndex(int, Format)'
|
||||
public void testSetFormatByArgumentIndex() {
|
||||
// same problem, once you set a format for an argument, you've set all of them
|
||||
|
||||
MessageFormat mf = new MessageFormat(pattern, Locale.US);
|
||||
mf.setFormatByArgumentIndex(1, DateFormat.getTimeInstance(DateFormat.SHORT));
|
||||
assertEquals(brokenButConformantTarget, mf.format(args));
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.MessageFormat.setFormat(int, Format)'
|
||||
*/
|
||||
public void testSetFormat() {
|
||||
// and ok again
|
||||
MessageFormat mf = new MessageFormat(pattern, Locale.US);
|
||||
mf.setFormat(1, DateFormat.getTimeInstance(DateFormat.LONG));
|
||||
assertEquals(modifiedTarget, mf.format(args));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.MessageFormat.getFormatsByArgumentIndex()'
|
||||
public void testGetFormatsByArgumentIndex() {
|
||||
MessageFormat mf = new MessageFormat(pattern, Locale.US);
|
||||
Format[] formats = mf.getFormatsByArgumentIndex();
|
||||
NumberFormat nf = NumberFormat.getNumberInstance(Locale.US);
|
||||
assertEquals(formats[0], nf);
|
||||
DateFormat df = DateFormat.getDateInstance(DateFormat.DEFAULT, Locale.US);
|
||||
assertEquals(formats[1], df);
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.MessageFormat.getFormats()'
|
||||
*/
|
||||
public void testGetFormats() {
|
||||
MessageFormat mf = new MessageFormat(pattern, Locale.US);
|
||||
Format[] formats = mf.getFormats();
|
||||
NumberFormat nf = NumberFormat.getNumberInstance(Locale.US);
|
||||
assertEquals(formats[0], nf);
|
||||
DateFormat tf = DateFormat.getTimeInstance(DateFormat.SHORT, Locale.US);
|
||||
assertEquals(formats[1], tf);
|
||||
DateFormat df = DateFormat.getDateInstance(DateFormat.DEFAULT, Locale.US);
|
||||
assertEquals(formats[2], df);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.MessageFormat.format(Object[], StringBuffer, FieldPosition)'
|
||||
*/
|
||||
public void testFormatObjectArrayStringBufferFieldPosition() {
|
||||
MessageFormat mf = new MessageFormat(pattern, Locale.US);
|
||||
StringBuffer buf = new StringBuffer();
|
||||
FieldPosition fp = new FieldPosition(0);
|
||||
mf.format(args, buf, fp);
|
||||
assertEquals(englishTarget, buf.toString());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.MessageFormat.format(String, Object[])'
|
||||
*/
|
||||
public void testFormatStringObjectArray() {
|
||||
assertEquals(englishTarget, MessageFormat.format(pattern, args));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.MessageFormat.format(Object, StringBuffer, FieldPosition)'
|
||||
*/
|
||||
public void testFormatObjectStringBufferFieldPosition() {
|
||||
MessageFormat mf = new MessageFormat(pattern, Locale.US);
|
||||
StringBuffer buf = new StringBuffer();
|
||||
FieldPosition fp = new FieldPosition(0);
|
||||
mf.format((Object)args, buf, fp);
|
||||
assertEquals(englishTarget, buf.toString());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.MessageFormat.parse(String, ParsePosition)'
|
||||
*/
|
||||
public void testParseStringParsePosition() {
|
||||
MessageFormat mf = new MessageFormat(pattern, Locale.US);
|
||||
ParsePosition pp = new ParsePosition(1);
|
||||
Object[] result = mf.parse("!" + englishTarget, pp);
|
||||
assertEquals(num, result[0]);
|
||||
assertEquals(dateOnly, result[1]);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.MessageFormat.parse(String)'
|
||||
*/
|
||||
public void testParseString() {
|
||||
MessageFormat mf = new MessageFormat(pattern, Locale.US);
|
||||
try {
|
||||
Object[] result = mf.parse(englishTarget);
|
||||
assertEquals(num, result[0]);
|
||||
assertEquals(dateOnly, result[1]);
|
||||
}
|
||||
catch (ParseException e) {
|
||||
fail(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.MessageFormat.parseObject(String, ParsePosition)'
|
||||
*/
|
||||
public void testParseObjectStringParsePosition() {
|
||||
MessageFormat mf = new MessageFormat(pattern, Locale.US);
|
||||
ParsePosition pp = new ParsePosition(0);
|
||||
Object result = mf.parseObject(englishTarget, pp);
|
||||
assertEquals(num, ((Object[])result)[0]);
|
||||
assertEquals(dateOnly, ((Object[])result)[1]);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.MessageFormat.autoQuoteApostrophe(String)'
|
||||
*/
|
||||
public void testAutoQuoteApostrophe() {
|
||||
String str = "Let's meet at {1,time,h 'o'' clock'} at l'Orange Bleue";
|
||||
String pat = MessageFormat.autoQuoteApostrophe(str);
|
||||
MessageFormat mf = new MessageFormat(pat, Locale.US);
|
||||
String result = mf.format(args);
|
||||
assertEquals("Let's meet at 8 o' clock at l'Orange Bleue", result);
|
||||
assertEquals("Let''s meet at {1,time,h 'o'' clock'} at l''Orange Bleue", pat);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.MessageFormat.clone()'
|
||||
*/
|
||||
public void testClone() {
|
||||
// tested already in testHashcode
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.MessageFormat.equals(Object)'
|
||||
*/
|
||||
public void testEqualsObject() {
|
||||
// tested already in testHashcode
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.MessageFormat.toString()'
|
||||
*/
|
||||
public void testToString() {
|
||||
// no need to test
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,447 +1,447 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2007-2011, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
package com.ibm.icu.tests;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.text.FieldPosition;
|
||||
import java.text.ParseException;
|
||||
import java.text.ParsePosition;
|
||||
import java.util.Locale;
|
||||
|
||||
import com.ibm.icu.text.NumberFormat;
|
||||
import com.ibm.icu.util.ULocale;
|
||||
|
||||
public class NumberFormatTest extends ICUTestCase {
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.x.text.NumberFormat.NumberFormat(NumberFormat)'
|
||||
*/
|
||||
public void testNumberFormat() {
|
||||
NumberFormat nf = new NumberFormat(java.text.NumberFormat.getInstance());
|
||||
assertEquals(nf, NumberFormat.getInstance());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.x.text.NumberFormat.format(Object, StringBuffer, FieldPosition)'
|
||||
*/
|
||||
public void testFormatObjectStringBufferFieldPosition() {
|
||||
Number num = new Long(1234L);
|
||||
StringBuffer buf = new StringBuffer();
|
||||
FieldPosition fp = new FieldPosition(NumberFormat.INTEGER_FIELD);
|
||||
NumberFormat.getInstance().format(num, buf, fp);
|
||||
assertEquals("1,234", buf.toString());
|
||||
assertEquals(0, fp.getBeginIndex());
|
||||
assertEquals(5, fp.getEndIndex());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.x.text.NumberFormat.parseObject(String, ParsePosition)'
|
||||
*/
|
||||
public void testParseObjectStringParsePosition() {
|
||||
ParsePosition pp = new ParsePosition(0);
|
||||
Object result = NumberFormat.getInstance().parse("1,234", pp);
|
||||
assertEquals(result, new Long(1234));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.x.text.NumberFormat.format(double)'
|
||||
*/
|
||||
public void testFormatDouble() {
|
||||
assertEquals("1,234.567", NumberFormat.getInstance().format(1234.567));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.x.text.NumberFormat.format(long)'
|
||||
*/
|
||||
public void testFormatLong() {
|
||||
assertEquals("1,234", NumberFormat.getInstance().format(1234L));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.x.text.NumberFormat.format(BigInteger)'
|
||||
*/
|
||||
public void testFormatBigInteger() {
|
||||
// note, java doesn't handle biginteger with full precision.
|
||||
BigInteger bi = new BigInteger("123456");
|
||||
assertEquals("123,456", java.text.NumberFormat.getInstance().format(bi));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.x.text.NumberFormat.format(double, StringBuffer, FieldPosition)'
|
||||
*/
|
||||
public void testFormatDoubleStringBufferFieldPosition() {
|
||||
StringBuffer buf = new StringBuffer();
|
||||
FieldPosition fp = new FieldPosition(NumberFormat.FRACTION_FIELD);
|
||||
assertEquals("123,456.789", NumberFormat.getInstance().format(123456.789, buf, fp).toString());
|
||||
assertEquals(8, fp.getBeginIndex());
|
||||
assertEquals(11, fp.getEndIndex());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.x.text.NumberFormat.format(long, StringBuffer, FieldPosition)'
|
||||
*/
|
||||
public void testFormatLongStringBufferFieldPosition() {
|
||||
StringBuffer buf = new StringBuffer();
|
||||
FieldPosition fp = new FieldPosition(NumberFormat.Field.GROUPING_SEPARATOR);
|
||||
assertEquals("123,456", NumberFormat.getInstance().format(123456L, buf, fp).toString());
|
||||
assertEquals(3, fp.getBeginIndex());
|
||||
assertEquals(4, fp.getEndIndex());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.x.text.NumberFormat.format(BigInteger, StringBuffer, FieldPosition)'
|
||||
*/
|
||||
public void testFormatBigIntegerStringBufferFieldPosition() {
|
||||
// note, java doesn't handle biginteger with full precision.
|
||||
StringBuffer buf = new StringBuffer();
|
||||
FieldPosition fp = new FieldPosition(0);
|
||||
BigInteger bi = new BigInteger("123456");
|
||||
assertEquals("123,456", java.text.NumberFormat.getInstance().format(bi, buf, fp).toString());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.x.text.NumberFormat.parse(String, ParsePosition)'
|
||||
*/
|
||||
public void testParseStringParsePosition() {
|
||||
ParsePosition pp = new ParsePosition(3);
|
||||
assertEquals(new Long(123456), NumberFormat.getInstance().parse("xxx123,456yyy", pp));
|
||||
assertEquals(10, pp.getIndex());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.x.text.NumberFormat.parse(String)'
|
||||
*/
|
||||
public void testParseString() throws ParseException {
|
||||
Number result = NumberFormat.getInstance().parse("123,456,yyy");
|
||||
assertEquals(new Long(123456), result);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.x.text.NumberFormat.isParseIntegerOnly()'
|
||||
*/
|
||||
public void testIsParseIntegerOnly() {
|
||||
NumberFormat nf = NumberFormat.getInstance();
|
||||
nf.setParseIntegerOnly(true);
|
||||
assertTrue(nf.isParseIntegerOnly());
|
||||
nf.setParseIntegerOnly(false);
|
||||
assertFalse(nf.isParseIntegerOnly());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.x.text.NumberFormat.setParseIntegerOnly(boolean)'
|
||||
*/
|
||||
public void testSetParseIntegerOnly() throws ParseException {
|
||||
String str = "123.456,yyy";
|
||||
NumberFormat nf = NumberFormat.getInstance();
|
||||
assertEquals(new Double(123.456), nf.parse(str));
|
||||
nf.setParseIntegerOnly(true);
|
||||
assertEquals(new Long(123), nf.parse(str));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.x.text.NumberFormat.getInstance()'
|
||||
*/
|
||||
public void testGetInstance() {
|
||||
// used everywhere, no need to test
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.x.text.NumberFormat.getInstance(Locale)'
|
||||
*/
|
||||
public void testGetInstanceLocale() {
|
||||
NumberFormat nf = NumberFormat.getInstance(Locale.GERMANY);
|
||||
assertEquals("123,456", nf.format(123.456));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.x.text.NumberFormat.getInstance(ULocale)'
|
||||
*/
|
||||
public void testGetInstanceULocale() {
|
||||
NumberFormat nf = NumberFormat.getInstance(ULocale.GERMANY);
|
||||
assertEquals("123,456", nf.format(123.456));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.x.text.NumberFormat.getNumberInstance()'
|
||||
*/
|
||||
public void testGetNumberInstance() {
|
||||
NumberFormat nf = NumberFormat.getNumberInstance();
|
||||
assertEquals("123,456.789", nf.format(123456.789));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.x.text.NumberFormat.getNumberInstance(Locale)'
|
||||
*/
|
||||
public void testGetNumberInstanceLocale() {
|
||||
NumberFormat nf = NumberFormat.getNumberInstance(Locale.GERMANY);
|
||||
assertEquals("123.456,789", nf.format(123456.789));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.x.text.NumberFormat.getNumberInstance(ULocale)'
|
||||
*/
|
||||
public void testGetNumberInstanceULocale() {
|
||||
NumberFormat nf = NumberFormat.getNumberInstance(ULocale.GERMANY);
|
||||
assertEquals("123.456,789", nf.format(123456.789));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.x.text.NumberFormat.getIntegerInstance()'
|
||||
*/
|
||||
public void testGetIntegerInstance() {
|
||||
NumberFormat nf = NumberFormat.getIntegerInstance();
|
||||
assertEquals("123,457", nf.format(123456.789)); // rounds
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.x.text.NumberFormat.getIntegerInstance(Locale)'
|
||||
*/
|
||||
public void testGetIntegerInstanceLocale() {
|
||||
NumberFormat nf = NumberFormat.getIntegerInstance(Locale.GERMANY);
|
||||
assertEquals("123.457", nf.format(123456.789)); // rounds
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.x.text.NumberFormat.getIntegerInstance(ULocale)'
|
||||
*/
|
||||
public void testGetIntegerInstanceULocale() {
|
||||
NumberFormat nf = NumberFormat.getIntegerInstance(ULocale.GERMANY);
|
||||
assertEquals("123.457", nf.format(123456.789)); // rounds
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.x.text.NumberFormat.getCurrencyInstance()'
|
||||
*/
|
||||
public void testGetCurrencyInstance() {
|
||||
NumberFormat nf = NumberFormat.getCurrencyInstance();
|
||||
assertEquals("$123,456.99", nf.format(123456.99));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.x.text.NumberFormat.getCurrencyInstance(Locale)'
|
||||
*/
|
||||
public void testGetCurrencyInstanceLocale() {
|
||||
NumberFormat nf = NumberFormat.getCurrencyInstance(Locale.GERMANY);
|
||||
assertEquals("123.456,99 \u20AC", nf.format(123456.99));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.x.text.NumberFormat.getCurrencyInstance(ULocale)'
|
||||
*/
|
||||
public void testGetCurrencyInstanceULocale() {
|
||||
NumberFormat nf = NumberFormat.getCurrencyInstance(ULocale.GERMANY);
|
||||
assertEquals("123.456,99 \u20AC", nf.format(123456.99));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.x.text.NumberFormat.getPercentInstance()'
|
||||
*/
|
||||
public void testGetPercentInstance() {
|
||||
NumberFormat nf = NumberFormat.getPercentInstance();
|
||||
assertEquals("123,456%", nf.format(1234.56));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.x.text.NumberFormat.getPercentInstance(Locale)'
|
||||
*/
|
||||
public void testGetPercentInstanceLocale() {
|
||||
NumberFormat nf = NumberFormat.getPercentInstance(Locale.GERMANY);
|
||||
assertEquals("123.456%", nf.format(1234.56));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.x.text.NumberFormat.getPercentInstance(ULocale)'
|
||||
*/
|
||||
public void testGetPercentInstanceULocale() {
|
||||
NumberFormat nf = NumberFormat.getPercentInstance(ULocale.GERMANY);
|
||||
assertEquals("123.456%", nf.format(1234.56));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.x.text.NumberFormat.getScientificInstance()'
|
||||
*/
|
||||
public void testGetScientificInstance() {
|
||||
NumberFormat nf = NumberFormat.getScientificInstance();
|
||||
assertEquals(".123456E4", nf.format(1234.56));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.x.text.NumberFormat.getScientificInstance(Locale)'
|
||||
*/
|
||||
public void testGetScientificInstanceLocale() {
|
||||
NumberFormat nf = NumberFormat.getScientificInstance(Locale.GERMANY);
|
||||
assertEquals(",123456E4", nf.format(1234.56));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.x.text.NumberFormat.getScientificInstance(ULocale)'
|
||||
*/
|
||||
public void testGetScientificInstanceULocale() {
|
||||
NumberFormat nf = NumberFormat.getScientificInstance(ULocale.GERMANY);
|
||||
assertEquals(",123456E4", nf.format(1234.56));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.x.text.NumberFormat.getAvailableLocales()'
|
||||
*/
|
||||
public void testGetAvailableLocales() {
|
||||
Locale[] ilocales = NumberFormat.getAvailableLocales();
|
||||
if (ICUTestCase.testingWrapper) {
|
||||
Locale[] jlocales = java.text.NumberFormat.getAvailableLocales();
|
||||
for (int i = 0; i < ilocales.length; ++i) {
|
||||
assertEquals(jlocales[i], ilocales[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.x.text.NumberFormat.getAvailableULocales()'
|
||||
*/
|
||||
public void testGetAvailableULocales() {
|
||||
ULocale[] ulocales = NumberFormat.getAvailableULocales();
|
||||
if (ICUTestCase.testingWrapper) {
|
||||
Locale[] jlocales = java.text.NumberFormat.getAvailableLocales();
|
||||
for (int i = 0; i < ulocales.length; ++i) {
|
||||
assertEquals(jlocales[i], ulocales[i].toLocale());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.x.text.NumberFormat.isGroupingUsed()'
|
||||
*/
|
||||
public void testIsGroupingUsed() {
|
||||
NumberFormat nf = NumberFormat.getInstance();
|
||||
nf.setGroupingUsed(true);
|
||||
assertTrue(nf.isGroupingUsed());
|
||||
nf.setGroupingUsed(false);
|
||||
assertFalse(nf.isGroupingUsed());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.x.text.NumberFormat.setGroupingUsed(boolean)'
|
||||
*/
|
||||
public void testSetGroupingUsed() {
|
||||
NumberFormat nf = NumberFormat.getInstance();
|
||||
assertEquals("123,456,789", nf.format(123456789));
|
||||
nf.setGroupingUsed(false);
|
||||
assertEquals("123456789", nf.format(123456789));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.x.text.NumberFormat.getMaximumIntegerDigits()'
|
||||
*/
|
||||
public void testGetMaximumIntegerDigits() {
|
||||
NumberFormat nf = NumberFormat.getInstance();
|
||||
nf.setMaximumIntegerDigits(4);
|
||||
assertEquals(4, nf.getMaximumIntegerDigits());
|
||||
nf.setMaximumIntegerDigits(6);
|
||||
assertEquals(6, nf.getMaximumIntegerDigits());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.x.text.NumberFormat.setMaximumIntegerDigits(int)'
|
||||
*/
|
||||
public void testSetMaximumIntegerDigits() {
|
||||
NumberFormat nf = NumberFormat.getInstance();
|
||||
nf.setMaximumIntegerDigits(4);
|
||||
assertEquals("3,456", nf.format(123456)); // high digits truncated
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.x.text.NumberFormat.getMinimumIntegerDigits()'
|
||||
*/
|
||||
public void testGetMinimumIntegerDigits() {
|
||||
NumberFormat nf = NumberFormat.getInstance();
|
||||
nf.setMinimumIntegerDigits(4);
|
||||
assertEquals(4, nf.getMinimumIntegerDigits());
|
||||
nf.setMinimumIntegerDigits(6);
|
||||
assertEquals(6, nf.getMinimumIntegerDigits());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.x.text.NumberFormat.setMinimumIntegerDigits(int)'
|
||||
*/
|
||||
public void testSetMinimumIntegerDigits() {
|
||||
NumberFormat nf = NumberFormat.getInstance();
|
||||
nf.setMinimumIntegerDigits(4);
|
||||
assertEquals("0,012", nf.format(12)); // pad out with zero, grouping still used
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.x.text.NumberFormat.getMaximumFractionDigits()'
|
||||
*/
|
||||
public void testGetMaximumFractionDigits() {
|
||||
NumberFormat nf = NumberFormat.getInstance();
|
||||
nf.setMaximumFractionDigits(4);
|
||||
assertEquals(4, nf.getMaximumFractionDigits());
|
||||
nf.setMaximumFractionDigits(6);
|
||||
assertEquals(6, nf.getMaximumFractionDigits());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.x.text.NumberFormat.setMaximumFractionDigits(int)'
|
||||
*/
|
||||
public void testSetMaximumFractionDigits() {
|
||||
NumberFormat nf = NumberFormat.getInstance();
|
||||
nf.setMaximumFractionDigits(4);
|
||||
assertEquals("1.2346", nf.format(1.2345678)); // low digits rounded
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.x.text.NumberFormat.getMinimumFractionDigits()'
|
||||
*/
|
||||
public void testGetMinimumFractionDigits() {
|
||||
NumberFormat nf = NumberFormat.getInstance();
|
||||
nf.setMinimumFractionDigits(4);
|
||||
assertEquals(4, nf.getMinimumFractionDigits());
|
||||
nf.setMinimumFractionDigits(6);
|
||||
assertEquals(6, nf.getMinimumFractionDigits());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.x.text.NumberFormat.setMinimumFractionDigits(int)'
|
||||
*/
|
||||
public void testSetMinimumFractionDigits() {
|
||||
NumberFormat nf = NumberFormat.getInstance();
|
||||
nf.setMinimumFractionDigits(4);
|
||||
assertEquals("1.2000", nf.format(1.2));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.x.text.NumberFormat.toString()'
|
||||
*/
|
||||
public void testToString() {
|
||||
assertNotNull(NumberFormat.getInstance().toString());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.x.text.NumberFormat.hashCode()'
|
||||
*/
|
||||
public void testHashCode() {
|
||||
NumberFormat nf = NumberFormat.getInstance();
|
||||
NumberFormat eq = NumberFormat.getInstance(Locale.US);
|
||||
NumberFormat neq = NumberFormat.getInstance(Locale.GERMANY);
|
||||
|
||||
ICUTestCase.testEHCS(nf, eq, neq);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.x.text.NumberFormat.clone()'
|
||||
*/
|
||||
public void testClone() {
|
||||
// see testHashCode
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.x.text.NumberFormat.equals(Object)'
|
||||
*/
|
||||
public void testEqualsObject() {
|
||||
// see testHashCode
|
||||
}
|
||||
}
|
||||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2007-2011, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
package com.ibm.icu.tests;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.text.FieldPosition;
|
||||
import java.text.ParseException;
|
||||
import java.text.ParsePosition;
|
||||
import java.util.Locale;
|
||||
|
||||
import com.ibm.icu.text.NumberFormat;
|
||||
import com.ibm.icu.util.ULocale;
|
||||
|
||||
public class NumberFormatTest extends ICUTestCase {
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.x.text.NumberFormat.NumberFormat(NumberFormat)'
|
||||
*/
|
||||
public void testNumberFormat() {
|
||||
NumberFormat nf = new NumberFormat(java.text.NumberFormat.getInstance());
|
||||
assertEquals(nf, NumberFormat.getInstance());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.x.text.NumberFormat.format(Object, StringBuffer, FieldPosition)'
|
||||
*/
|
||||
public void testFormatObjectStringBufferFieldPosition() {
|
||||
Number num = new Long(1234L);
|
||||
StringBuffer buf = new StringBuffer();
|
||||
FieldPosition fp = new FieldPosition(NumberFormat.INTEGER_FIELD);
|
||||
NumberFormat.getInstance().format(num, buf, fp);
|
||||
assertEquals("1,234", buf.toString());
|
||||
assertEquals(0, fp.getBeginIndex());
|
||||
assertEquals(5, fp.getEndIndex());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.x.text.NumberFormat.parseObject(String, ParsePosition)'
|
||||
*/
|
||||
public void testParseObjectStringParsePosition() {
|
||||
ParsePosition pp = new ParsePosition(0);
|
||||
Object result = NumberFormat.getInstance().parse("1,234", pp);
|
||||
assertEquals(result, new Long(1234));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.x.text.NumberFormat.format(double)'
|
||||
*/
|
||||
public void testFormatDouble() {
|
||||
assertEquals("1,234.567", NumberFormat.getInstance().format(1234.567));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.x.text.NumberFormat.format(long)'
|
||||
*/
|
||||
public void testFormatLong() {
|
||||
assertEquals("1,234", NumberFormat.getInstance().format(1234L));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.x.text.NumberFormat.format(BigInteger)'
|
||||
*/
|
||||
public void testFormatBigInteger() {
|
||||
// note, java doesn't handle biginteger with full precision.
|
||||
BigInteger bi = new BigInteger("123456");
|
||||
assertEquals("123,456", java.text.NumberFormat.getInstance().format(bi));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.x.text.NumberFormat.format(double, StringBuffer, FieldPosition)'
|
||||
*/
|
||||
public void testFormatDoubleStringBufferFieldPosition() {
|
||||
StringBuffer buf = new StringBuffer();
|
||||
FieldPosition fp = new FieldPosition(NumberFormat.FRACTION_FIELD);
|
||||
assertEquals("123,456.789", NumberFormat.getInstance().format(123456.789, buf, fp).toString());
|
||||
assertEquals(8, fp.getBeginIndex());
|
||||
assertEquals(11, fp.getEndIndex());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.x.text.NumberFormat.format(long, StringBuffer, FieldPosition)'
|
||||
*/
|
||||
public void testFormatLongStringBufferFieldPosition() {
|
||||
StringBuffer buf = new StringBuffer();
|
||||
FieldPosition fp = new FieldPosition(NumberFormat.Field.GROUPING_SEPARATOR);
|
||||
assertEquals("123,456", NumberFormat.getInstance().format(123456L, buf, fp).toString());
|
||||
assertEquals(3, fp.getBeginIndex());
|
||||
assertEquals(4, fp.getEndIndex());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.x.text.NumberFormat.format(BigInteger, StringBuffer, FieldPosition)'
|
||||
*/
|
||||
public void testFormatBigIntegerStringBufferFieldPosition() {
|
||||
// note, java doesn't handle biginteger with full precision.
|
||||
StringBuffer buf = new StringBuffer();
|
||||
FieldPosition fp = new FieldPosition(0);
|
||||
BigInteger bi = new BigInteger("123456");
|
||||
assertEquals("123,456", java.text.NumberFormat.getInstance().format(bi, buf, fp).toString());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.x.text.NumberFormat.parse(String, ParsePosition)'
|
||||
*/
|
||||
public void testParseStringParsePosition() {
|
||||
ParsePosition pp = new ParsePosition(3);
|
||||
assertEquals(new Long(123456), NumberFormat.getInstance().parse("xxx123,456yyy", pp));
|
||||
assertEquals(10, pp.getIndex());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.x.text.NumberFormat.parse(String)'
|
||||
*/
|
||||
public void testParseString() throws ParseException {
|
||||
Number result = NumberFormat.getInstance().parse("123,456,yyy");
|
||||
assertEquals(new Long(123456), result);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.x.text.NumberFormat.isParseIntegerOnly()'
|
||||
*/
|
||||
public void testIsParseIntegerOnly() {
|
||||
NumberFormat nf = NumberFormat.getInstance();
|
||||
nf.setParseIntegerOnly(true);
|
||||
assertTrue(nf.isParseIntegerOnly());
|
||||
nf.setParseIntegerOnly(false);
|
||||
assertFalse(nf.isParseIntegerOnly());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.x.text.NumberFormat.setParseIntegerOnly(boolean)'
|
||||
*/
|
||||
public void testSetParseIntegerOnly() throws ParseException {
|
||||
String str = "123.456,yyy";
|
||||
NumberFormat nf = NumberFormat.getInstance();
|
||||
assertEquals(new Double(123.456), nf.parse(str));
|
||||
nf.setParseIntegerOnly(true);
|
||||
assertEquals(new Long(123), nf.parse(str));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.x.text.NumberFormat.getInstance()'
|
||||
*/
|
||||
public void testGetInstance() {
|
||||
// used everywhere, no need to test
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.x.text.NumberFormat.getInstance(Locale)'
|
||||
*/
|
||||
public void testGetInstanceLocale() {
|
||||
NumberFormat nf = NumberFormat.getInstance(Locale.GERMANY);
|
||||
assertEquals("123,456", nf.format(123.456));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.x.text.NumberFormat.getInstance(ULocale)'
|
||||
*/
|
||||
public void testGetInstanceULocale() {
|
||||
NumberFormat nf = NumberFormat.getInstance(ULocale.GERMANY);
|
||||
assertEquals("123,456", nf.format(123.456));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.x.text.NumberFormat.getNumberInstance()'
|
||||
*/
|
||||
public void testGetNumberInstance() {
|
||||
NumberFormat nf = NumberFormat.getNumberInstance();
|
||||
assertEquals("123,456.789", nf.format(123456.789));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.x.text.NumberFormat.getNumberInstance(Locale)'
|
||||
*/
|
||||
public void testGetNumberInstanceLocale() {
|
||||
NumberFormat nf = NumberFormat.getNumberInstance(Locale.GERMANY);
|
||||
assertEquals("123.456,789", nf.format(123456.789));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.x.text.NumberFormat.getNumberInstance(ULocale)'
|
||||
*/
|
||||
public void testGetNumberInstanceULocale() {
|
||||
NumberFormat nf = NumberFormat.getNumberInstance(ULocale.GERMANY);
|
||||
assertEquals("123.456,789", nf.format(123456.789));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.x.text.NumberFormat.getIntegerInstance()'
|
||||
*/
|
||||
public void testGetIntegerInstance() {
|
||||
NumberFormat nf = NumberFormat.getIntegerInstance();
|
||||
assertEquals("123,457", nf.format(123456.789)); // rounds
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.x.text.NumberFormat.getIntegerInstance(Locale)'
|
||||
*/
|
||||
public void testGetIntegerInstanceLocale() {
|
||||
NumberFormat nf = NumberFormat.getIntegerInstance(Locale.GERMANY);
|
||||
assertEquals("123.457", nf.format(123456.789)); // rounds
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.x.text.NumberFormat.getIntegerInstance(ULocale)'
|
||||
*/
|
||||
public void testGetIntegerInstanceULocale() {
|
||||
NumberFormat nf = NumberFormat.getIntegerInstance(ULocale.GERMANY);
|
||||
assertEquals("123.457", nf.format(123456.789)); // rounds
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.x.text.NumberFormat.getCurrencyInstance()'
|
||||
*/
|
||||
public void testGetCurrencyInstance() {
|
||||
NumberFormat nf = NumberFormat.getCurrencyInstance();
|
||||
assertEquals("$123,456.99", nf.format(123456.99));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.x.text.NumberFormat.getCurrencyInstance(Locale)'
|
||||
*/
|
||||
public void testGetCurrencyInstanceLocale() {
|
||||
NumberFormat nf = NumberFormat.getCurrencyInstance(Locale.GERMANY);
|
||||
assertEquals("123.456,99 \u20AC", nf.format(123456.99));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.x.text.NumberFormat.getCurrencyInstance(ULocale)'
|
||||
*/
|
||||
public void testGetCurrencyInstanceULocale() {
|
||||
NumberFormat nf = NumberFormat.getCurrencyInstance(ULocale.GERMANY);
|
||||
assertEquals("123.456,99 \u20AC", nf.format(123456.99));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.x.text.NumberFormat.getPercentInstance()'
|
||||
*/
|
||||
public void testGetPercentInstance() {
|
||||
NumberFormat nf = NumberFormat.getPercentInstance();
|
||||
assertEquals("123,456%", nf.format(1234.56));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.x.text.NumberFormat.getPercentInstance(Locale)'
|
||||
*/
|
||||
public void testGetPercentInstanceLocale() {
|
||||
NumberFormat nf = NumberFormat.getPercentInstance(Locale.GERMANY);
|
||||
assertEquals("123.456%", nf.format(1234.56));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.x.text.NumberFormat.getPercentInstance(ULocale)'
|
||||
*/
|
||||
public void testGetPercentInstanceULocale() {
|
||||
NumberFormat nf = NumberFormat.getPercentInstance(ULocale.GERMANY);
|
||||
assertEquals("123.456%", nf.format(1234.56));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.x.text.NumberFormat.getScientificInstance()'
|
||||
*/
|
||||
public void testGetScientificInstance() {
|
||||
NumberFormat nf = NumberFormat.getScientificInstance();
|
||||
assertEquals(".123456E4", nf.format(1234.56));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.x.text.NumberFormat.getScientificInstance(Locale)'
|
||||
*/
|
||||
public void testGetScientificInstanceLocale() {
|
||||
NumberFormat nf = NumberFormat.getScientificInstance(Locale.GERMANY);
|
||||
assertEquals(",123456E4", nf.format(1234.56));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.x.text.NumberFormat.getScientificInstance(ULocale)'
|
||||
*/
|
||||
public void testGetScientificInstanceULocale() {
|
||||
NumberFormat nf = NumberFormat.getScientificInstance(ULocale.GERMANY);
|
||||
assertEquals(",123456E4", nf.format(1234.56));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.x.text.NumberFormat.getAvailableLocales()'
|
||||
*/
|
||||
public void testGetAvailableLocales() {
|
||||
Locale[] ilocales = NumberFormat.getAvailableLocales();
|
||||
if (ICUTestCase.testingWrapper) {
|
||||
Locale[] jlocales = java.text.NumberFormat.getAvailableLocales();
|
||||
for (int i = 0; i < ilocales.length; ++i) {
|
||||
assertEquals(jlocales[i], ilocales[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.x.text.NumberFormat.getAvailableULocales()'
|
||||
*/
|
||||
public void testGetAvailableULocales() {
|
||||
ULocale[] ulocales = NumberFormat.getAvailableULocales();
|
||||
if (ICUTestCase.testingWrapper) {
|
||||
Locale[] jlocales = java.text.NumberFormat.getAvailableLocales();
|
||||
for (int i = 0; i < ulocales.length; ++i) {
|
||||
assertEquals(jlocales[i], ulocales[i].toLocale());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.x.text.NumberFormat.isGroupingUsed()'
|
||||
*/
|
||||
public void testIsGroupingUsed() {
|
||||
NumberFormat nf = NumberFormat.getInstance();
|
||||
nf.setGroupingUsed(true);
|
||||
assertTrue(nf.isGroupingUsed());
|
||||
nf.setGroupingUsed(false);
|
||||
assertFalse(nf.isGroupingUsed());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.x.text.NumberFormat.setGroupingUsed(boolean)'
|
||||
*/
|
||||
public void testSetGroupingUsed() {
|
||||
NumberFormat nf = NumberFormat.getInstance();
|
||||
assertEquals("123,456,789", nf.format(123456789));
|
||||
nf.setGroupingUsed(false);
|
||||
assertEquals("123456789", nf.format(123456789));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.x.text.NumberFormat.getMaximumIntegerDigits()'
|
||||
*/
|
||||
public void testGetMaximumIntegerDigits() {
|
||||
NumberFormat nf = NumberFormat.getInstance();
|
||||
nf.setMaximumIntegerDigits(4);
|
||||
assertEquals(4, nf.getMaximumIntegerDigits());
|
||||
nf.setMaximumIntegerDigits(6);
|
||||
assertEquals(6, nf.getMaximumIntegerDigits());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.x.text.NumberFormat.setMaximumIntegerDigits(int)'
|
||||
*/
|
||||
public void testSetMaximumIntegerDigits() {
|
||||
NumberFormat nf = NumberFormat.getInstance();
|
||||
nf.setMaximumIntegerDigits(4);
|
||||
assertEquals("3,456", nf.format(123456)); // high digits truncated
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.x.text.NumberFormat.getMinimumIntegerDigits()'
|
||||
*/
|
||||
public void testGetMinimumIntegerDigits() {
|
||||
NumberFormat nf = NumberFormat.getInstance();
|
||||
nf.setMinimumIntegerDigits(4);
|
||||
assertEquals(4, nf.getMinimumIntegerDigits());
|
||||
nf.setMinimumIntegerDigits(6);
|
||||
assertEquals(6, nf.getMinimumIntegerDigits());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.x.text.NumberFormat.setMinimumIntegerDigits(int)'
|
||||
*/
|
||||
public void testSetMinimumIntegerDigits() {
|
||||
NumberFormat nf = NumberFormat.getInstance();
|
||||
nf.setMinimumIntegerDigits(4);
|
||||
assertEquals("0,012", nf.format(12)); // pad out with zero, grouping still used
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.x.text.NumberFormat.getMaximumFractionDigits()'
|
||||
*/
|
||||
public void testGetMaximumFractionDigits() {
|
||||
NumberFormat nf = NumberFormat.getInstance();
|
||||
nf.setMaximumFractionDigits(4);
|
||||
assertEquals(4, nf.getMaximumFractionDigits());
|
||||
nf.setMaximumFractionDigits(6);
|
||||
assertEquals(6, nf.getMaximumFractionDigits());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.x.text.NumberFormat.setMaximumFractionDigits(int)'
|
||||
*/
|
||||
public void testSetMaximumFractionDigits() {
|
||||
NumberFormat nf = NumberFormat.getInstance();
|
||||
nf.setMaximumFractionDigits(4);
|
||||
assertEquals("1.2346", nf.format(1.2345678)); // low digits rounded
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.x.text.NumberFormat.getMinimumFractionDigits()'
|
||||
*/
|
||||
public void testGetMinimumFractionDigits() {
|
||||
NumberFormat nf = NumberFormat.getInstance();
|
||||
nf.setMinimumFractionDigits(4);
|
||||
assertEquals(4, nf.getMinimumFractionDigits());
|
||||
nf.setMinimumFractionDigits(6);
|
||||
assertEquals(6, nf.getMinimumFractionDigits());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.x.text.NumberFormat.setMinimumFractionDigits(int)'
|
||||
*/
|
||||
public void testSetMinimumFractionDigits() {
|
||||
NumberFormat nf = NumberFormat.getInstance();
|
||||
nf.setMinimumFractionDigits(4);
|
||||
assertEquals("1.2000", nf.format(1.2));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.x.text.NumberFormat.toString()'
|
||||
*/
|
||||
public void testToString() {
|
||||
assertNotNull(NumberFormat.getInstance().toString());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.x.text.NumberFormat.hashCode()'
|
||||
*/
|
||||
public void testHashCode() {
|
||||
NumberFormat nf = NumberFormat.getInstance();
|
||||
NumberFormat eq = NumberFormat.getInstance(Locale.US);
|
||||
NumberFormat neq = NumberFormat.getInstance(Locale.GERMANY);
|
||||
|
||||
ICUTestCase.testEHCS(nf, eq, neq);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.x.text.NumberFormat.clone()'
|
||||
*/
|
||||
public void testClone() {
|
||||
// see testHashCode
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.x.text.NumberFormat.equals(Object)'
|
||||
*/
|
||||
public void testEqualsObject() {
|
||||
// see testHashCode
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,202 +1,202 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2006-2011, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
package com.ibm.icu.tests;
|
||||
|
||||
import java.text.FieldPosition;
|
||||
import java.text.ParseException;
|
||||
import java.text.ParsePosition;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
|
||||
import com.ibm.icu.text.DateFormatSymbols;
|
||||
import com.ibm.icu.text.SimpleDateFormat;
|
||||
import com.ibm.icu.util.Calendar;
|
||||
import com.ibm.icu.util.TimeZone;
|
||||
import com.ibm.icu.util.ULocale;
|
||||
|
||||
public class SimpleDateFormatTest extends ICUTestCase {
|
||||
private static final String mdy = "MMM dd yyyy";
|
||||
private static final String md2 = "MMM dd yy";
|
||||
private static final String hmz = "'The time is' HH:mm:ss zzz";
|
||||
private static final String hmzmdy = hmz + " 'on' " + mdy;
|
||||
private static final String hmzmdyStr = "The time is 15:05:20 CST on Jan 10 2006";
|
||||
|
||||
private static final TimeZone tzc = TimeZone.getTimeZone("CST");
|
||||
private static final TimeZone tzp = TimeZone.getTimeZone("PST");
|
||||
private static final Calendar cal = Calendar.getInstance(tzc);
|
||||
private static final Date date;
|
||||
static {
|
||||
cal.clear();
|
||||
cal.set(2006, 0, 10, 15, 5, 20); // arrgh, doesn't clear millis
|
||||
date = cal.getTime();
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.SimpleDateFormat.format(Calendar, StringBuffer, FieldPosition)'
|
||||
*/
|
||||
public void testFormatCalendarStringBufferFieldPosition() {
|
||||
StringBuffer buf = new StringBuffer();
|
||||
FieldPosition fp = new FieldPosition(0);
|
||||
SimpleDateFormat sdf = new SimpleDateFormat(hmzmdy);
|
||||
sdf.format(cal, buf, fp);
|
||||
assertEquals(hmzmdyStr, buf.toString());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.SimpleDateFormat.parse(String, Calendar, ParsePosition)'
|
||||
*/
|
||||
public void testParseStringCalendarParsePosition() {
|
||||
Calendar cal = Calendar.getInstance(tzp);
|
||||
cal.clear();
|
||||
ParsePosition pp = new ParsePosition(0);
|
||||
SimpleDateFormat sdf = new SimpleDateFormat(hmzmdy);
|
||||
sdf.parse(hmzmdyStr, cal, pp);
|
||||
assertEquals(date, cal.getTime());
|
||||
// note: java doesn't return the parsed time zone
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.SimpleDateFormat.clone()'
|
||||
*/
|
||||
public void testClone() {
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.SimpleDateFormat.SimpleDateFormat()'
|
||||
*/
|
||||
public void testSimpleDateFormat() {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat();
|
||||
java.text.SimpleDateFormat jsdf = new java.text.SimpleDateFormat();
|
||||
assertEquals(jsdf.format(date), sdf.format(date));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.SimpleDateFormat.SimpleDateFormat(String)'
|
||||
*/
|
||||
public void testSimpleDateFormatString() {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat(mdy);
|
||||
java.text.SimpleDateFormat jsdf = new java.text.SimpleDateFormat(mdy);
|
||||
assertEquals(jsdf.format(date), sdf.format(date));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.SimpleDateFormat.SimpleDateFormat(String, Locale)'
|
||||
*/
|
||||
public void testSimpleDateFormatStringLocale() {
|
||||
Locale l = Locale.JAPAN;
|
||||
SimpleDateFormat sdf = new SimpleDateFormat(mdy, l);
|
||||
java.text.SimpleDateFormat jsdf = new java.text.SimpleDateFormat(mdy, l);
|
||||
assertEquals(jsdf.format(date), sdf.format(date));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.SimpleDateFormat.SimpleDateFormat(String, ULocale)'
|
||||
*/
|
||||
public void testSimpleDateFormatStringULocale() {
|
||||
ULocale l = ULocale.JAPAN;
|
||||
SimpleDateFormat sdf = new SimpleDateFormat(mdy, l);
|
||||
java.text.SimpleDateFormat jsdf = new java.text.SimpleDateFormat(mdy, l.toLocale());
|
||||
assertEquals(jsdf.format(date), sdf.format(date));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.SimpleDateFormat.SimpleDateFormat(String, DateFormatSymbols)'
|
||||
*/
|
||||
public void testSimpleDateFormatStringDateFormatSymbols() {
|
||||
Locale l = Locale.US;
|
||||
DateFormatSymbols dfs = new DateFormatSymbols(l);
|
||||
java.text.DateFormatSymbols jdfs = new java.text.DateFormatSymbols(l);
|
||||
SimpleDateFormat sdf = new SimpleDateFormat(mdy, dfs);
|
||||
java.text.SimpleDateFormat jsdf = new java.text.SimpleDateFormat(mdy, jdfs);
|
||||
assertEquals(jsdf.format(date), sdf.format(date));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.SimpleDateFormat.set2DigitYearStart(Date)'
|
||||
*/
|
||||
public void testSet2DigitYearStart() {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat(md2);
|
||||
sdf.set2DigitYearStart(date);
|
||||
try {
|
||||
Date d = sdf.parse("Jan 15 04");
|
||||
assertNotEqual(-1, d.toString().indexOf("2104"));
|
||||
}
|
||||
catch (ParseException pe) {
|
||||
fail(pe.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.SimpleDateFormat.get2DigitYearStart()'
|
||||
*/
|
||||
public void testGet2DigitYearStart() {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat(md2);
|
||||
sdf.set2DigitYearStart(date);
|
||||
assertEquals(date, sdf.get2DigitYearStart());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.SimpleDateFormat.toPattern()'
|
||||
*/
|
||||
public void testToPattern() {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat(mdy);
|
||||
assertEquals(mdy, sdf.toPattern());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.SimpleDateFormat.toLocalizedPattern()'
|
||||
*/
|
||||
public void testToLocalizedPattern() {
|
||||
Locale l = Locale.getDefault();
|
||||
Locale.setDefault(Locale.US);
|
||||
SimpleDateFormat sdf = new SimpleDateFormat(mdy);
|
||||
assertEquals(mdy, sdf.toLocalizedPattern());
|
||||
Locale.setDefault(l);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.SimpleDateFormat.applyPattern(String)'
|
||||
*/
|
||||
public void testApplyPattern() {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat();
|
||||
sdf.setTimeZone(tzc);
|
||||
sdf.applyPattern(hmzmdy);
|
||||
assertEquals(hmzmdyStr, sdf.format(date));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.SimpleDateFormat.applyLocalizedPattern(String)'
|
||||
*/
|
||||
public void testApplyLocalizedPattern() {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat();
|
||||
sdf.setTimeZone(tzc);
|
||||
sdf.applyLocalizedPattern(hmzmdy);
|
||||
assertEquals(hmzmdyStr, sdf.format(date));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.SimpleDateFormat.getDateFormatSymbols()'
|
||||
*/
|
||||
public void testGetDateFormatSymbols() {
|
||||
DateFormatSymbols dfs = new DateFormatSymbols(Locale.US);
|
||||
SimpleDateFormat sdf = new SimpleDateFormat(mdy, dfs);
|
||||
assertEquals(dfs, sdf.getDateFormatSymbols());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.SimpleDateFormat.setDateFormatSymbols(DateFormatSymbols)'
|
||||
*/
|
||||
public void testSetDateFormatSymbols() {
|
||||
DateFormatSymbols dfs = new DateFormatSymbols(Locale.JAPAN);
|
||||
SimpleDateFormat sdf = new SimpleDateFormat(hmzmdy);
|
||||
sdf.setDateFormatSymbols(dfs);
|
||||
// assumes Japanese symbols do not have gregorian month names
|
||||
assertEquals(-1, sdf.format(date).indexOf("Jan"));
|
||||
}
|
||||
}
|
||||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2006-2011, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
package com.ibm.icu.tests;
|
||||
|
||||
import java.text.FieldPosition;
|
||||
import java.text.ParseException;
|
||||
import java.text.ParsePosition;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
|
||||
import com.ibm.icu.text.DateFormatSymbols;
|
||||
import com.ibm.icu.text.SimpleDateFormat;
|
||||
import com.ibm.icu.util.Calendar;
|
||||
import com.ibm.icu.util.TimeZone;
|
||||
import com.ibm.icu.util.ULocale;
|
||||
|
||||
public class SimpleDateFormatTest extends ICUTestCase {
|
||||
private static final String mdy = "MMM dd yyyy";
|
||||
private static final String md2 = "MMM dd yy";
|
||||
private static final String hmz = "'The time is' HH:mm:ss zzz";
|
||||
private static final String hmzmdy = hmz + " 'on' " + mdy;
|
||||
private static final String hmzmdyStr = "The time is 15:05:20 CST on Jan 10 2006";
|
||||
|
||||
private static final TimeZone tzc = TimeZone.getTimeZone("CST");
|
||||
private static final TimeZone tzp = TimeZone.getTimeZone("PST");
|
||||
private static final Calendar cal = Calendar.getInstance(tzc);
|
||||
private static final Date date;
|
||||
static {
|
||||
cal.clear();
|
||||
cal.set(2006, 0, 10, 15, 5, 20); // arrgh, doesn't clear millis
|
||||
date = cal.getTime();
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.SimpleDateFormat.format(Calendar, StringBuffer, FieldPosition)'
|
||||
*/
|
||||
public void testFormatCalendarStringBufferFieldPosition() {
|
||||
StringBuffer buf = new StringBuffer();
|
||||
FieldPosition fp = new FieldPosition(0);
|
||||
SimpleDateFormat sdf = new SimpleDateFormat(hmzmdy);
|
||||
sdf.format(cal, buf, fp);
|
||||
assertEquals(hmzmdyStr, buf.toString());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.SimpleDateFormat.parse(String, Calendar, ParsePosition)'
|
||||
*/
|
||||
public void testParseStringCalendarParsePosition() {
|
||||
Calendar cal = Calendar.getInstance(tzp);
|
||||
cal.clear();
|
||||
ParsePosition pp = new ParsePosition(0);
|
||||
SimpleDateFormat sdf = new SimpleDateFormat(hmzmdy);
|
||||
sdf.parse(hmzmdyStr, cal, pp);
|
||||
assertEquals(date, cal.getTime());
|
||||
// note: java doesn't return the parsed time zone
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.SimpleDateFormat.clone()'
|
||||
*/
|
||||
public void testClone() {
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.SimpleDateFormat.SimpleDateFormat()'
|
||||
*/
|
||||
public void testSimpleDateFormat() {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat();
|
||||
java.text.SimpleDateFormat jsdf = new java.text.SimpleDateFormat();
|
||||
assertEquals(jsdf.format(date), sdf.format(date));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.SimpleDateFormat.SimpleDateFormat(String)'
|
||||
*/
|
||||
public void testSimpleDateFormatString() {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat(mdy);
|
||||
java.text.SimpleDateFormat jsdf = new java.text.SimpleDateFormat(mdy);
|
||||
assertEquals(jsdf.format(date), sdf.format(date));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.SimpleDateFormat.SimpleDateFormat(String, Locale)'
|
||||
*/
|
||||
public void testSimpleDateFormatStringLocale() {
|
||||
Locale l = Locale.JAPAN;
|
||||
SimpleDateFormat sdf = new SimpleDateFormat(mdy, l);
|
||||
java.text.SimpleDateFormat jsdf = new java.text.SimpleDateFormat(mdy, l);
|
||||
assertEquals(jsdf.format(date), sdf.format(date));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.SimpleDateFormat.SimpleDateFormat(String, ULocale)'
|
||||
*/
|
||||
public void testSimpleDateFormatStringULocale() {
|
||||
ULocale l = ULocale.JAPAN;
|
||||
SimpleDateFormat sdf = new SimpleDateFormat(mdy, l);
|
||||
java.text.SimpleDateFormat jsdf = new java.text.SimpleDateFormat(mdy, l.toLocale());
|
||||
assertEquals(jsdf.format(date), sdf.format(date));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.SimpleDateFormat.SimpleDateFormat(String, DateFormatSymbols)'
|
||||
*/
|
||||
public void testSimpleDateFormatStringDateFormatSymbols() {
|
||||
Locale l = Locale.US;
|
||||
DateFormatSymbols dfs = new DateFormatSymbols(l);
|
||||
java.text.DateFormatSymbols jdfs = new java.text.DateFormatSymbols(l);
|
||||
SimpleDateFormat sdf = new SimpleDateFormat(mdy, dfs);
|
||||
java.text.SimpleDateFormat jsdf = new java.text.SimpleDateFormat(mdy, jdfs);
|
||||
assertEquals(jsdf.format(date), sdf.format(date));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.SimpleDateFormat.set2DigitYearStart(Date)'
|
||||
*/
|
||||
public void testSet2DigitYearStart() {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat(md2);
|
||||
sdf.set2DigitYearStart(date);
|
||||
try {
|
||||
Date d = sdf.parse("Jan 15 04");
|
||||
assertNotEqual(-1, d.toString().indexOf("2104"));
|
||||
}
|
||||
catch (ParseException pe) {
|
||||
fail(pe.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.SimpleDateFormat.get2DigitYearStart()'
|
||||
*/
|
||||
public void testGet2DigitYearStart() {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat(md2);
|
||||
sdf.set2DigitYearStart(date);
|
||||
assertEquals(date, sdf.get2DigitYearStart());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.SimpleDateFormat.toPattern()'
|
||||
*/
|
||||
public void testToPattern() {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat(mdy);
|
||||
assertEquals(mdy, sdf.toPattern());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.SimpleDateFormat.toLocalizedPattern()'
|
||||
*/
|
||||
public void testToLocalizedPattern() {
|
||||
Locale l = Locale.getDefault();
|
||||
Locale.setDefault(Locale.US);
|
||||
SimpleDateFormat sdf = new SimpleDateFormat(mdy);
|
||||
assertEquals(mdy, sdf.toLocalizedPattern());
|
||||
Locale.setDefault(l);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.SimpleDateFormat.applyPattern(String)'
|
||||
*/
|
||||
public void testApplyPattern() {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat();
|
||||
sdf.setTimeZone(tzc);
|
||||
sdf.applyPattern(hmzmdy);
|
||||
assertEquals(hmzmdyStr, sdf.format(date));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.SimpleDateFormat.applyLocalizedPattern(String)'
|
||||
*/
|
||||
public void testApplyLocalizedPattern() {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat();
|
||||
sdf.setTimeZone(tzc);
|
||||
sdf.applyLocalizedPattern(hmzmdy);
|
||||
assertEquals(hmzmdyStr, sdf.format(date));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.SimpleDateFormat.getDateFormatSymbols()'
|
||||
*/
|
||||
public void testGetDateFormatSymbols() {
|
||||
DateFormatSymbols dfs = new DateFormatSymbols(Locale.US);
|
||||
SimpleDateFormat sdf = new SimpleDateFormat(mdy, dfs);
|
||||
assertEquals(dfs, sdf.getDateFormatSymbols());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.text.SimpleDateFormat.setDateFormatSymbols(DateFormatSymbols)'
|
||||
*/
|
||||
public void testSetDateFormatSymbols() {
|
||||
DateFormatSymbols dfs = new DateFormatSymbols(Locale.JAPAN);
|
||||
SimpleDateFormat sdf = new SimpleDateFormat(hmzmdy);
|
||||
sdf.setDateFormatSymbols(dfs);
|
||||
// assumes Japanese symbols do not have gregorian month names
|
||||
assertEquals(-1, sdf.format(date).indexOf("Jan"));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,235 +1,235 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2006-2011, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
package com.ibm.icu.tests;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
|
||||
import com.ibm.icu.util.Calendar;
|
||||
import com.ibm.icu.util.TimeZone;
|
||||
import com.ibm.icu.util.ULocale;
|
||||
|
||||
public class TimeZoneTest extends ICUTestCase {
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.util.TimeZone.hashCode()'
|
||||
*/
|
||||
public void testHashCode() {
|
||||
TimeZone tz1 = TimeZone.getTimeZone("PST");
|
||||
TimeZone tz2 = TimeZone.getTimeZone("PST");
|
||||
TimeZone tzn = TimeZone.getTimeZone("CST");
|
||||
testEHCS(tz1, tz2, tzn);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.util.TimeZone.TimeZone(TimeZone)'
|
||||
*/
|
||||
public void testTimeZone() {
|
||||
// implicitly tested everywhere
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.util.TimeZone.getOffset(int, int, int, int, int, int)'
|
||||
*/
|
||||
public void testGetOffset() {
|
||||
TimeZone tz = TimeZone.getTimeZone("PST");
|
||||
int offset = tz.getOffset(1, 2004, 0, 01, 1, 0);
|
||||
assertEquals(-28800000, offset);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.util.TimeZone.setRawOffset(int)'
|
||||
*/
|
||||
public void testSetRawOffset() {
|
||||
TimeZone tz = TimeZone.getTimeZone("PST");
|
||||
int value = tz.getRawOffset();
|
||||
int value1 = value + 100000;
|
||||
tz.setRawOffset(value1);
|
||||
int result = tz.getRawOffset();
|
||||
assertNotEqual(value, result);
|
||||
assertEquals(value1, result);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.util.TimeZone.getRawOffset()'
|
||||
*/
|
||||
public void testGetRawOffset() {
|
||||
TimeZone tz = TimeZone.getTimeZone("PST");
|
||||
int offset = tz.getRawOffset();
|
||||
assertEquals(-28800000, offset);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.util.TimeZone.getID()'
|
||||
*/
|
||||
public void testGetID() {
|
||||
TimeZone tz = TimeZone.getTimeZone("PST");
|
||||
assertEquals("PST", tz.getID());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.util.TimeZone.setID(String)'
|
||||
*/
|
||||
public void testSetID() {
|
||||
TimeZone tz = TimeZone.getTimeZone("PST");
|
||||
String value1 = tz.getID();
|
||||
String value2 = value1 + "!";
|
||||
tz.setID(value2);
|
||||
String result = tz.getID();
|
||||
assertNotEqual(value1, result);
|
||||
assertEquals(value2, result);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.util.TimeZone.getDisplayName()'
|
||||
*/
|
||||
public void testGetDisplayName() {
|
||||
TimeZone tz = TimeZone.getTimeZone("PST");
|
||||
assertEquals("Pacific Standard Time", tz.getDisplayName());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.util.TimeZone.getDisplayName(Locale)'
|
||||
*/
|
||||
public void testGetDisplayNameLocale() {
|
||||
TimeZone tz = TimeZone.getTimeZone("PST");
|
||||
assertEquals("Pacific Standard Time", tz.getDisplayName(Locale.US));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.util.TimeZone.getDisplayName(ULocale)'
|
||||
*/
|
||||
public void testGetDisplayNameULocale() {
|
||||
TimeZone tz = TimeZone.getTimeZone("PST");
|
||||
assertEquals("Pacific Standard Time", tz.getDisplayName(ULocale.US));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.util.TimeZone.getDisplayName(boolean, int)'
|
||||
*/
|
||||
public void testGetDisplayNameBooleanInt() {
|
||||
TimeZone tz = TimeZone.getTimeZone("PST");
|
||||
assertEquals("PDT", tz.getDisplayName(true, TimeZone.SHORT));
|
||||
assertEquals("Pacific Daylight Time", tz.getDisplayName(true, TimeZone.LONG));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.util.TimeZone.getDisplayName(boolean, int, Locale)'
|
||||
*/
|
||||
public void testGetDisplayNameBooleanIntLocale() {
|
||||
TimeZone tz = TimeZone.getTimeZone("PST");
|
||||
assertEquals("PDT", tz.getDisplayName(true, TimeZone.SHORT, Locale.US));
|
||||
assertEquals("Pacific Daylight Time", tz.getDisplayName(true, TimeZone.LONG, Locale.US));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.util.TimeZone.getDisplayName(boolean, int, ULocale)'
|
||||
*/
|
||||
public void testGetDisplayNameBooleanIntULocale() {
|
||||
TimeZone tz = TimeZone.getTimeZone("PST");
|
||||
assertEquals("PDT", tz.getDisplayName(true, TimeZone.SHORT, ULocale.US));
|
||||
assertEquals("Pacific Daylight Time", tz.getDisplayName(true, TimeZone.LONG, ULocale.US));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.util.TimeZone.getDSTSavings()'
|
||||
*/
|
||||
public void testGetDSTSavings() {
|
||||
TimeZone tz = TimeZone.getTimeZone("PST");
|
||||
assertEquals(3600000, tz.getDSTSavings());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.util.TimeZone.useDaylightTime()'
|
||||
*/
|
||||
public void testUseDaylightTime() {
|
||||
TimeZone tz = TimeZone.getTimeZone("PST");
|
||||
assertTrue(tz.useDaylightTime());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.util.TimeZone.inDaylightTime(Date)'
|
||||
*/
|
||||
public void testInDaylightTime() {
|
||||
TimeZone tz = TimeZone.getTimeZone("PST");
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.set(2005, 0, 17);
|
||||
Date date = cal.getTime();
|
||||
assertFalse(tz.inDaylightTime(date));
|
||||
cal.set(2005, 6, 17);
|
||||
date = cal.getTime();
|
||||
assertTrue(tz.inDaylightTime(date));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.util.TimeZone.getTimeZone(String)'
|
||||
*/
|
||||
public void testGetTimeZone() {
|
||||
// implicitly tested everywhere
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.util.TimeZone.getAvailableIDs(int)'
|
||||
*/
|
||||
public void testGetAvailableIDsInt() {
|
||||
String[] ids = TimeZone.getAvailableIDs(-28800000);
|
||||
assertNotNull(ids);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.util.TimeZone.getAvailableIDs()'
|
||||
*/
|
||||
public void testGetAvailableIDs() {
|
||||
String[] ids = TimeZone.getAvailableIDs();
|
||||
assertNotNull(ids);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.util.TimeZone.getDefault()'
|
||||
*/
|
||||
public void testGetDefault() {
|
||||
TimeZone tz = TimeZone.getDefault();
|
||||
assertNotNull(tz);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.util.TimeZone.setDefault(TimeZone)'
|
||||
*/
|
||||
public void testSetDefault() {
|
||||
TimeZone tz1 = TimeZone.getDefault();
|
||||
String newCode = "PDT".equals(tz1.getID()) ? "CST" : "PDT";
|
||||
TimeZone tz2 = TimeZone.getTimeZone(newCode);
|
||||
TimeZone.setDefault(tz2);
|
||||
TimeZone result = TimeZone.getDefault();
|
||||
assertNotEqual(tz1, result);
|
||||
assertEquals(tz2, result);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.util.TimeZone.hasSameRules(TimeZone)'
|
||||
*/
|
||||
public void testHasSameRules() {
|
||||
TimeZone tz1 = TimeZone.getTimeZone("PST");
|
||||
TimeZone tz2 = TimeZone.getTimeZone("America/Los_Angeles");
|
||||
assertTrue(tz1.hasSameRules(tz2));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.util.TimeZone.clone()'
|
||||
*/
|
||||
public void testClone() {
|
||||
// tested by testHashCode
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.util.TimeZone.equals(Object)'
|
||||
*/
|
||||
public void testEqualsObject() {
|
||||
// tested by testHashCode
|
||||
}
|
||||
}
|
||||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2006-2011, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
package com.ibm.icu.tests;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
|
||||
import com.ibm.icu.util.Calendar;
|
||||
import com.ibm.icu.util.TimeZone;
|
||||
import com.ibm.icu.util.ULocale;
|
||||
|
||||
public class TimeZoneTest extends ICUTestCase {
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.util.TimeZone.hashCode()'
|
||||
*/
|
||||
public void testHashCode() {
|
||||
TimeZone tz1 = TimeZone.getTimeZone("PST");
|
||||
TimeZone tz2 = TimeZone.getTimeZone("PST");
|
||||
TimeZone tzn = TimeZone.getTimeZone("CST");
|
||||
testEHCS(tz1, tz2, tzn);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.util.TimeZone.TimeZone(TimeZone)'
|
||||
*/
|
||||
public void testTimeZone() {
|
||||
// implicitly tested everywhere
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.util.TimeZone.getOffset(int, int, int, int, int, int)'
|
||||
*/
|
||||
public void testGetOffset() {
|
||||
TimeZone tz = TimeZone.getTimeZone("PST");
|
||||
int offset = tz.getOffset(1, 2004, 0, 01, 1, 0);
|
||||
assertEquals(-28800000, offset);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.util.TimeZone.setRawOffset(int)'
|
||||
*/
|
||||
public void testSetRawOffset() {
|
||||
TimeZone tz = TimeZone.getTimeZone("PST");
|
||||
int value = tz.getRawOffset();
|
||||
int value1 = value + 100000;
|
||||
tz.setRawOffset(value1);
|
||||
int result = tz.getRawOffset();
|
||||
assertNotEqual(value, result);
|
||||
assertEquals(value1, result);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.util.TimeZone.getRawOffset()'
|
||||
*/
|
||||
public void testGetRawOffset() {
|
||||
TimeZone tz = TimeZone.getTimeZone("PST");
|
||||
int offset = tz.getRawOffset();
|
||||
assertEquals(-28800000, offset);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.util.TimeZone.getID()'
|
||||
*/
|
||||
public void testGetID() {
|
||||
TimeZone tz = TimeZone.getTimeZone("PST");
|
||||
assertEquals("PST", tz.getID());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.util.TimeZone.setID(String)'
|
||||
*/
|
||||
public void testSetID() {
|
||||
TimeZone tz = TimeZone.getTimeZone("PST");
|
||||
String value1 = tz.getID();
|
||||
String value2 = value1 + "!";
|
||||
tz.setID(value2);
|
||||
String result = tz.getID();
|
||||
assertNotEqual(value1, result);
|
||||
assertEquals(value2, result);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.util.TimeZone.getDisplayName()'
|
||||
*/
|
||||
public void testGetDisplayName() {
|
||||
TimeZone tz = TimeZone.getTimeZone("PST");
|
||||
assertEquals("Pacific Standard Time", tz.getDisplayName());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.util.TimeZone.getDisplayName(Locale)'
|
||||
*/
|
||||
public void testGetDisplayNameLocale() {
|
||||
TimeZone tz = TimeZone.getTimeZone("PST");
|
||||
assertEquals("Pacific Standard Time", tz.getDisplayName(Locale.US));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.util.TimeZone.getDisplayName(ULocale)'
|
||||
*/
|
||||
public void testGetDisplayNameULocale() {
|
||||
TimeZone tz = TimeZone.getTimeZone("PST");
|
||||
assertEquals("Pacific Standard Time", tz.getDisplayName(ULocale.US));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.util.TimeZone.getDisplayName(boolean, int)'
|
||||
*/
|
||||
public void testGetDisplayNameBooleanInt() {
|
||||
TimeZone tz = TimeZone.getTimeZone("PST");
|
||||
assertEquals("PDT", tz.getDisplayName(true, TimeZone.SHORT));
|
||||
assertEquals("Pacific Daylight Time", tz.getDisplayName(true, TimeZone.LONG));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.util.TimeZone.getDisplayName(boolean, int, Locale)'
|
||||
*/
|
||||
public void testGetDisplayNameBooleanIntLocale() {
|
||||
TimeZone tz = TimeZone.getTimeZone("PST");
|
||||
assertEquals("PDT", tz.getDisplayName(true, TimeZone.SHORT, Locale.US));
|
||||
assertEquals("Pacific Daylight Time", tz.getDisplayName(true, TimeZone.LONG, Locale.US));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.util.TimeZone.getDisplayName(boolean, int, ULocale)'
|
||||
*/
|
||||
public void testGetDisplayNameBooleanIntULocale() {
|
||||
TimeZone tz = TimeZone.getTimeZone("PST");
|
||||
assertEquals("PDT", tz.getDisplayName(true, TimeZone.SHORT, ULocale.US));
|
||||
assertEquals("Pacific Daylight Time", tz.getDisplayName(true, TimeZone.LONG, ULocale.US));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.util.TimeZone.getDSTSavings()'
|
||||
*/
|
||||
public void testGetDSTSavings() {
|
||||
TimeZone tz = TimeZone.getTimeZone("PST");
|
||||
assertEquals(3600000, tz.getDSTSavings());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.util.TimeZone.useDaylightTime()'
|
||||
*/
|
||||
public void testUseDaylightTime() {
|
||||
TimeZone tz = TimeZone.getTimeZone("PST");
|
||||
assertTrue(tz.useDaylightTime());
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.util.TimeZone.inDaylightTime(Date)'
|
||||
*/
|
||||
public void testInDaylightTime() {
|
||||
TimeZone tz = TimeZone.getTimeZone("PST");
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.set(2005, 0, 17);
|
||||
Date date = cal.getTime();
|
||||
assertFalse(tz.inDaylightTime(date));
|
||||
cal.set(2005, 6, 17);
|
||||
date = cal.getTime();
|
||||
assertTrue(tz.inDaylightTime(date));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.util.TimeZone.getTimeZone(String)'
|
||||
*/
|
||||
public void testGetTimeZone() {
|
||||
// implicitly tested everywhere
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.util.TimeZone.getAvailableIDs(int)'
|
||||
*/
|
||||
public void testGetAvailableIDsInt() {
|
||||
String[] ids = TimeZone.getAvailableIDs(-28800000);
|
||||
assertNotNull(ids);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.util.TimeZone.getAvailableIDs()'
|
||||
*/
|
||||
public void testGetAvailableIDs() {
|
||||
String[] ids = TimeZone.getAvailableIDs();
|
||||
assertNotNull(ids);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.util.TimeZone.getDefault()'
|
||||
*/
|
||||
public void testGetDefault() {
|
||||
TimeZone tz = TimeZone.getDefault();
|
||||
assertNotNull(tz);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.util.TimeZone.setDefault(TimeZone)'
|
||||
*/
|
||||
public void testSetDefault() {
|
||||
TimeZone tz1 = TimeZone.getDefault();
|
||||
String newCode = "PDT".equals(tz1.getID()) ? "CST" : "PDT";
|
||||
TimeZone tz2 = TimeZone.getTimeZone(newCode);
|
||||
TimeZone.setDefault(tz2);
|
||||
TimeZone result = TimeZone.getDefault();
|
||||
assertNotEqual(tz1, result);
|
||||
assertEquals(tz2, result);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.util.TimeZone.hasSameRules(TimeZone)'
|
||||
*/
|
||||
public void testHasSameRules() {
|
||||
TimeZone tz1 = TimeZone.getTimeZone("PST");
|
||||
TimeZone tz2 = TimeZone.getTimeZone("America/Los_Angeles");
|
||||
assertTrue(tz1.hasSameRules(tz2));
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.util.TimeZone.clone()'
|
||||
*/
|
||||
public void testClone() {
|
||||
// tested by testHashCode
|
||||
}
|
||||
|
||||
/*
|
||||
* Test method for 'com.ibm.icu.util.TimeZone.equals(Object)'
|
||||
*/
|
||||
public void testEqualsObject() {
|
||||
// tested by testHashCode
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,21 +1,21 @@
|
|||
/*
|
||||
***************************************************************************
|
||||
* Copyright (c) 2007-2011 International Business Machines Corporation and *
|
||||
* others. All rights reserved. *
|
||||
***************************************************************************
|
||||
*/
|
||||
|
||||
package com.ibm.icu.impl;
|
||||
|
||||
public interface ICUCache<K, V> {
|
||||
// Type of reference holding the Map instance
|
||||
public static final int SOFT = 0;
|
||||
public static final int WEAK = 1;
|
||||
|
||||
// NULL object, which may be used for a cache key
|
||||
public static final Object NULL = new Object();
|
||||
|
||||
public void clear();
|
||||
public void put(K key, V value);
|
||||
public V get(Object key);
|
||||
}
|
||||
/*
|
||||
***************************************************************************
|
||||
* Copyright (c) 2007-2011 International Business Machines Corporation and *
|
||||
* others. All rights reserved. *
|
||||
***************************************************************************
|
||||
*/
|
||||
|
||||
package com.ibm.icu.impl;
|
||||
|
||||
public interface ICUCache<K, V> {
|
||||
// Type of reference holding the Map instance
|
||||
public static final int SOFT = 0;
|
||||
public static final int WEAK = 1;
|
||||
|
||||
// NULL object, which may be used for a cache key
|
||||
public static final Object NULL = new Object();
|
||||
|
||||
public void clear();
|
||||
public void put(K key, V value);
|
||||
public V get(Object key);
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -1,132 +1,132 @@
|
|||
/*
|
||||
******************************************************************************
|
||||
* Copyright (C) 1996-2011, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
******************************************************************************
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
package com.ibm.icu.impl;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* A class to hold utility functions missing from java.util.Locale.
|
||||
*/
|
||||
public class LocaleUtility {
|
||||
|
||||
/**
|
||||
* A helper function to convert a string of the form
|
||||
* aa_BB_CC to a locale object. Why isn't this in Locale?
|
||||
*/
|
||||
public static Locale getLocaleFromName(String name) {
|
||||
String language = "";
|
||||
String country = "";
|
||||
String variant = "";
|
||||
|
||||
int i1 = name.indexOf('_');
|
||||
if (i1 < 0) {
|
||||
language = name;
|
||||
} else {
|
||||
language = name.substring(0, i1);
|
||||
++i1;
|
||||
int i2 = name.indexOf('_', i1);
|
||||
if (i2 < 0) {
|
||||
country = name.substring(i1);
|
||||
} else {
|
||||
country = name.substring(i1, i2);
|
||||
variant = name.substring(i2+1);
|
||||
}
|
||||
}
|
||||
|
||||
return new Locale(language, country, variant);
|
||||
}
|
||||
|
||||
/**
|
||||
* Compare two locale strings of the form aa_BB_CC, and
|
||||
* return true if parent is a 'strict' fallback of child, that is,
|
||||
* if child =~ "^parent(_.+)*" (roughly).
|
||||
*/
|
||||
public static boolean isFallbackOf(String parent, String child) {
|
||||
if (!child.startsWith(parent)) {
|
||||
return false;
|
||||
}
|
||||
int i = parent.length();
|
||||
return (i == child.length() ||
|
||||
child.charAt(i) == '_');
|
||||
}
|
||||
|
||||
/**
|
||||
* Compare two locales, and return true if the parent is a
|
||||
* 'strict' fallback of the child (parent string is a fallback
|
||||
* of child string).
|
||||
*/
|
||||
public static boolean isFallbackOf(Locale parent, Locale child) {
|
||||
return isFallbackOf(parent.toString(), child.toString());
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Convenience method that calls canonicalLocaleString(String) with
|
||||
* locale.toString();
|
||||
*/
|
||||
/*public static String canonicalLocaleString(Locale locale) {
|
||||
return canonicalLocaleString(locale.toString());
|
||||
}*/
|
||||
|
||||
/*
|
||||
* You'd think that Locale canonicalizes, since it munges the
|
||||
* renamed languages, but it doesn't quite. It forces the region
|
||||
* to be upper case but doesn't do anything about the language or
|
||||
* variant. Our canonical form is 'lower_UPPER_UPPER'.
|
||||
*/
|
||||
/*public static String canonicalLocaleString(String id) {
|
||||
if (id != null) {
|
||||
int x = id.indexOf("_");
|
||||
if (x == -1) {
|
||||
id = id.toLowerCase(Locale.ENGLISH);
|
||||
} else {
|
||||
StringBuffer buf = new StringBuffer();
|
||||
buf.append(id.substring(0, x).toLowerCase(Locale.ENGLISH));
|
||||
buf.append(id.substring(x).toUpperCase(Locale.ENGLISH));
|
||||
|
||||
int len = buf.length();
|
||||
int n = len;
|
||||
while (--n >= 0 && buf.charAt(n) == '_') {
|
||||
}
|
||||
if (++n != len) {
|
||||
buf.delete(n, len);
|
||||
}
|
||||
id = buf.toString();
|
||||
}
|
||||
}
|
||||
return id;
|
||||
}*/
|
||||
|
||||
/**
|
||||
* Fallback from the given locale name by removing the rightmost _-delimited
|
||||
* element. If there is none, return the root locale ("", "", ""). If this
|
||||
* is the root locale, return null. NOTE: The string "root" is not
|
||||
* recognized; do not use it.
|
||||
*
|
||||
* @return a new Locale that is a fallback from the given locale, or null.
|
||||
*/
|
||||
public static Locale fallback(Locale loc) {
|
||||
|
||||
// Split the locale into parts and remove the rightmost part
|
||||
String[] parts = new String[]
|
||||
{ loc.getLanguage(), loc.getCountry(), loc.getVariant() };
|
||||
int i;
|
||||
for (i=2; i>=0; --i) {
|
||||
if (parts[i].length() != 0) {
|
||||
parts[i] = "";
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i<0) {
|
||||
return null; // All parts were empty
|
||||
}
|
||||
return new Locale(parts[0], parts[1], parts[2]);
|
||||
}
|
||||
}
|
||||
/*
|
||||
******************************************************************************
|
||||
* Copyright (C) 1996-2011, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
******************************************************************************
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
package com.ibm.icu.impl;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* A class to hold utility functions missing from java.util.Locale.
|
||||
*/
|
||||
public class LocaleUtility {
|
||||
|
||||
/**
|
||||
* A helper function to convert a string of the form
|
||||
* aa_BB_CC to a locale object. Why isn't this in Locale?
|
||||
*/
|
||||
public static Locale getLocaleFromName(String name) {
|
||||
String language = "";
|
||||
String country = "";
|
||||
String variant = "";
|
||||
|
||||
int i1 = name.indexOf('_');
|
||||
if (i1 < 0) {
|
||||
language = name;
|
||||
} else {
|
||||
language = name.substring(0, i1);
|
||||
++i1;
|
||||
int i2 = name.indexOf('_', i1);
|
||||
if (i2 < 0) {
|
||||
country = name.substring(i1);
|
||||
} else {
|
||||
country = name.substring(i1, i2);
|
||||
variant = name.substring(i2+1);
|
||||
}
|
||||
}
|
||||
|
||||
return new Locale(language, country, variant);
|
||||
}
|
||||
|
||||
/**
|
||||
* Compare two locale strings of the form aa_BB_CC, and
|
||||
* return true if parent is a 'strict' fallback of child, that is,
|
||||
* if child =~ "^parent(_.+)*" (roughly).
|
||||
*/
|
||||
public static boolean isFallbackOf(String parent, String child) {
|
||||
if (!child.startsWith(parent)) {
|
||||
return false;
|
||||
}
|
||||
int i = parent.length();
|
||||
return (i == child.length() ||
|
||||
child.charAt(i) == '_');
|
||||
}
|
||||
|
||||
/**
|
||||
* Compare two locales, and return true if the parent is a
|
||||
* 'strict' fallback of the child (parent string is a fallback
|
||||
* of child string).
|
||||
*/
|
||||
public static boolean isFallbackOf(Locale parent, Locale child) {
|
||||
return isFallbackOf(parent.toString(), child.toString());
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Convenience method that calls canonicalLocaleString(String) with
|
||||
* locale.toString();
|
||||
*/
|
||||
/*public static String canonicalLocaleString(Locale locale) {
|
||||
return canonicalLocaleString(locale.toString());
|
||||
}*/
|
||||
|
||||
/*
|
||||
* You'd think that Locale canonicalizes, since it munges the
|
||||
* renamed languages, but it doesn't quite. It forces the region
|
||||
* to be upper case but doesn't do anything about the language or
|
||||
* variant. Our canonical form is 'lower_UPPER_UPPER'.
|
||||
*/
|
||||
/*public static String canonicalLocaleString(String id) {
|
||||
if (id != null) {
|
||||
int x = id.indexOf("_");
|
||||
if (x == -1) {
|
||||
id = id.toLowerCase(Locale.ENGLISH);
|
||||
} else {
|
||||
StringBuffer buf = new StringBuffer();
|
||||
buf.append(id.substring(0, x).toLowerCase(Locale.ENGLISH));
|
||||
buf.append(id.substring(x).toUpperCase(Locale.ENGLISH));
|
||||
|
||||
int len = buf.length();
|
||||
int n = len;
|
||||
while (--n >= 0 && buf.charAt(n) == '_') {
|
||||
}
|
||||
if (++n != len) {
|
||||
buf.delete(n, len);
|
||||
}
|
||||
id = buf.toString();
|
||||
}
|
||||
}
|
||||
return id;
|
||||
}*/
|
||||
|
||||
/**
|
||||
* Fallback from the given locale name by removing the rightmost _-delimited
|
||||
* element. If there is none, return the root locale ("", "", ""). If this
|
||||
* is the root locale, return null. NOTE: The string "root" is not
|
||||
* recognized; do not use it.
|
||||
*
|
||||
* @return a new Locale that is a fallback from the given locale, or null.
|
||||
*/
|
||||
public static Locale fallback(Locale loc) {
|
||||
|
||||
// Split the locale into parts and remove the rightmost part
|
||||
String[] parts = new String[]
|
||||
{ loc.getLanguage(), loc.getCountry(), loc.getVariant() };
|
||||
int i;
|
||||
for (i=2; i>=0; --i) {
|
||||
if (parts[i].length() != 0) {
|
||||
parts[i] = "";
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i<0) {
|
||||
return null; // All parts were empty
|
||||
}
|
||||
return new Locale(parts[0], parts[1], parts[2]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,73 +1,73 @@
|
|||
/*
|
||||
****************************************************************************
|
||||
* Copyright (c) 2007-2011 International Business Machines Corporation and *
|
||||
* others. All rights reserved. *
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
package com.ibm.icu.impl;
|
||||
|
||||
import java.lang.ref.Reference;
|
||||
import java.lang.ref.SoftReference;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class SimpleCache<K, V> implements ICUCache<K, V> {
|
||||
private static final int DEFAULT_CAPACITY = 16;
|
||||
|
||||
private Reference<Map<K, V>> cacheRef = null;
|
||||
private int type = ICUCache.SOFT;
|
||||
private int capacity = DEFAULT_CAPACITY;
|
||||
|
||||
public SimpleCache() {
|
||||
}
|
||||
|
||||
public SimpleCache(int cacheType) {
|
||||
this(cacheType, DEFAULT_CAPACITY);
|
||||
}
|
||||
|
||||
public SimpleCache(int cacheType, int initialCapacity) {
|
||||
if (cacheType == ICUCache.WEAK) {
|
||||
type = cacheType;
|
||||
}
|
||||
if (initialCapacity > 0) {
|
||||
capacity = initialCapacity;
|
||||
}
|
||||
}
|
||||
|
||||
public V get(Object key) {
|
||||
Reference<Map<K, V>> ref = cacheRef;
|
||||
if (ref != null) {
|
||||
Map<K, V> map = ref.get();
|
||||
if (map != null) {
|
||||
return map.get(key);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void put(K key, V value) {
|
||||
Reference<Map<K, V>> ref = cacheRef;
|
||||
Map<K, V> map = null;
|
||||
if (ref != null) {
|
||||
map = ref.get();
|
||||
}
|
||||
if (map == null) {
|
||||
map = Collections.synchronizedMap(new HashMap<K, V>(capacity));
|
||||
if (type == ICUCache.WEAK) {
|
||||
ref = new WeakReference<Map<K, V>>(map);
|
||||
} else {
|
||||
ref = new SoftReference<Map<K, V>>(map);
|
||||
}
|
||||
cacheRef = ref;
|
||||
}
|
||||
map.put(key, value);
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
cacheRef = null;
|
||||
}
|
||||
|
||||
}
|
||||
/*
|
||||
****************************************************************************
|
||||
* Copyright (c) 2007-2011 International Business Machines Corporation and *
|
||||
* others. All rights reserved. *
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
package com.ibm.icu.impl;
|
||||
|
||||
import java.lang.ref.Reference;
|
||||
import java.lang.ref.SoftReference;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class SimpleCache<K, V> implements ICUCache<K, V> {
|
||||
private static final int DEFAULT_CAPACITY = 16;
|
||||
|
||||
private Reference<Map<K, V>> cacheRef = null;
|
||||
private int type = ICUCache.SOFT;
|
||||
private int capacity = DEFAULT_CAPACITY;
|
||||
|
||||
public SimpleCache() {
|
||||
}
|
||||
|
||||
public SimpleCache(int cacheType) {
|
||||
this(cacheType, DEFAULT_CAPACITY);
|
||||
}
|
||||
|
||||
public SimpleCache(int cacheType, int initialCapacity) {
|
||||
if (cacheType == ICUCache.WEAK) {
|
||||
type = cacheType;
|
||||
}
|
||||
if (initialCapacity > 0) {
|
||||
capacity = initialCapacity;
|
||||
}
|
||||
}
|
||||
|
||||
public V get(Object key) {
|
||||
Reference<Map<K, V>> ref = cacheRef;
|
||||
if (ref != null) {
|
||||
Map<K, V> map = ref.get();
|
||||
if (map != null) {
|
||||
return map.get(key);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void put(K key, V value) {
|
||||
Reference<Map<K, V>> ref = cacheRef;
|
||||
Map<K, V> map = null;
|
||||
if (ref != null) {
|
||||
map = ref.get();
|
||||
}
|
||||
if (map == null) {
|
||||
map = Collections.synchronizedMap(new HashMap<K, V>(capacity));
|
||||
if (type == ICUCache.WEAK) {
|
||||
ref = new WeakReference<Map<K, V>>(map);
|
||||
} else {
|
||||
ref = new SoftReference<Map<K, V>>(map);
|
||||
}
|
||||
cacheRef = ref;
|
||||
}
|
||||
map.put(key, value);
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
cacheRef = null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,180 +1,180 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2009-2011, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
package com.ibm.icu.impl.locale;
|
||||
|
||||
public final class AsciiUtil {
|
||||
public static boolean caseIgnoreMatch(String s1, String s2) {
|
||||
if (s1 == s2) {
|
||||
return true;
|
||||
}
|
||||
int len = s1.length();
|
||||
if (len != s2.length()) {
|
||||
return false;
|
||||
}
|
||||
int i = 0;
|
||||
while (i < len) {
|
||||
char c1 = s1.charAt(i);
|
||||
char c2 = s2.charAt(i);
|
||||
if (c1 != c2 && toLower(c1) != toLower(c2)) {
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
return (i == len);
|
||||
}
|
||||
|
||||
public static int caseIgnoreCompare(String s1, String s2) {
|
||||
if (s1 == s2) {
|
||||
return 0;
|
||||
}
|
||||
return AsciiUtil.toLowerString(s1).compareTo(AsciiUtil.toLowerString(s2));
|
||||
}
|
||||
|
||||
|
||||
public static char toUpper(char c) {
|
||||
if (c >= 'a' && c <= 'z') {
|
||||
c -= 0x20;
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
public static char toLower(char c) {
|
||||
if (c >= 'A' && c <= 'Z') {
|
||||
c += 0x20;
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
public static String toLowerString(String s) {
|
||||
int idx = 0;
|
||||
for (; idx < s.length(); idx++) {
|
||||
char c = s.charAt(idx);
|
||||
if (c >= 'A' && c <= 'Z') {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (idx == s.length()) {
|
||||
return s;
|
||||
}
|
||||
StringBuilder buf = new StringBuilder(s.substring(0, idx));
|
||||
for (; idx < s.length(); idx++) {
|
||||
buf.append(toLower(s.charAt(idx)));
|
||||
}
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
public static String toUpperString(String s) {
|
||||
int idx = 0;
|
||||
for (; idx < s.length(); idx++) {
|
||||
char c = s.charAt(idx);
|
||||
if (c >= 'a' && c <= 'z') {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (idx == s.length()) {
|
||||
return s;
|
||||
}
|
||||
StringBuilder buf = new StringBuilder(s.substring(0, idx));
|
||||
for (; idx < s.length(); idx++) {
|
||||
buf.append(toUpper(s.charAt(idx)));
|
||||
}
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
public static String toTitleString(String s) {
|
||||
if (s.length() == 0) {
|
||||
return s;
|
||||
}
|
||||
int idx = 0;
|
||||
char c = s.charAt(idx);
|
||||
if (!(c >= 'a' && c <= 'z')) {
|
||||
for (idx = 1; idx < s.length(); idx++) {
|
||||
if (c >= 'A' && c <= 'Z') {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (idx == s.length()) {
|
||||
return s;
|
||||
}
|
||||
StringBuilder buf = new StringBuilder(s.substring(0, idx));
|
||||
if (idx == 0) {
|
||||
buf.append(toUpper(s.charAt(idx)));
|
||||
idx++;
|
||||
}
|
||||
for (; idx < s.length(); idx++) {
|
||||
buf.append(toLower(s.charAt(idx)));
|
||||
}
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
public static boolean isAlpha(char c) {
|
||||
return (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z');
|
||||
}
|
||||
|
||||
public static boolean isAlphaString(String s) {
|
||||
boolean b = true;
|
||||
for (int i = 0; i < s.length(); i++) {
|
||||
if (!isAlpha(s.charAt(i))) {
|
||||
b = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return b;
|
||||
}
|
||||
|
||||
public static boolean isNumeric(char c) {
|
||||
return (c >= '0' && c <= '9');
|
||||
}
|
||||
|
||||
public static boolean isNumericString(String s) {
|
||||
boolean b = true;
|
||||
for (int i = 0; i < s.length(); i++) {
|
||||
if (!isNumeric(s.charAt(i))) {
|
||||
b = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return b;
|
||||
}
|
||||
|
||||
public static boolean isAlphaNumeric(char c) {
|
||||
return isAlpha(c) || isNumeric(c);
|
||||
}
|
||||
|
||||
public static boolean isAlphaNumericString(String s) {
|
||||
boolean b = true;
|
||||
for (int i = 0; i < s.length(); i++) {
|
||||
if (!isAlphaNumeric(s.charAt(i))) {
|
||||
b = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return b;
|
||||
}
|
||||
|
||||
public static class CaseInsensitiveKey {
|
||||
private String _key;
|
||||
private int _hash;
|
||||
|
||||
public CaseInsensitiveKey(String key) {
|
||||
_key = key;
|
||||
_hash = AsciiUtil.toLowerString(key).hashCode();
|
||||
}
|
||||
|
||||
public boolean equals(Object o) {
|
||||
if (o instanceof CaseInsensitiveKey) {
|
||||
return AsciiUtil.caseIgnoreMatch(_key, ((CaseInsensitiveKey)o)._key);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
return _hash;
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2009-2011, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
package com.ibm.icu.impl.locale;
|
||||
|
||||
public final class AsciiUtil {
|
||||
public static boolean caseIgnoreMatch(String s1, String s2) {
|
||||
if (s1 == s2) {
|
||||
return true;
|
||||
}
|
||||
int len = s1.length();
|
||||
if (len != s2.length()) {
|
||||
return false;
|
||||
}
|
||||
int i = 0;
|
||||
while (i < len) {
|
||||
char c1 = s1.charAt(i);
|
||||
char c2 = s2.charAt(i);
|
||||
if (c1 != c2 && toLower(c1) != toLower(c2)) {
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
return (i == len);
|
||||
}
|
||||
|
||||
public static int caseIgnoreCompare(String s1, String s2) {
|
||||
if (s1 == s2) {
|
||||
return 0;
|
||||
}
|
||||
return AsciiUtil.toLowerString(s1).compareTo(AsciiUtil.toLowerString(s2));
|
||||
}
|
||||
|
||||
|
||||
public static char toUpper(char c) {
|
||||
if (c >= 'a' && c <= 'z') {
|
||||
c -= 0x20;
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
public static char toLower(char c) {
|
||||
if (c >= 'A' && c <= 'Z') {
|
||||
c += 0x20;
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
public static String toLowerString(String s) {
|
||||
int idx = 0;
|
||||
for (; idx < s.length(); idx++) {
|
||||
char c = s.charAt(idx);
|
||||
if (c >= 'A' && c <= 'Z') {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (idx == s.length()) {
|
||||
return s;
|
||||
}
|
||||
StringBuilder buf = new StringBuilder(s.substring(0, idx));
|
||||
for (; idx < s.length(); idx++) {
|
||||
buf.append(toLower(s.charAt(idx)));
|
||||
}
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
public static String toUpperString(String s) {
|
||||
int idx = 0;
|
||||
for (; idx < s.length(); idx++) {
|
||||
char c = s.charAt(idx);
|
||||
if (c >= 'a' && c <= 'z') {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (idx == s.length()) {
|
||||
return s;
|
||||
}
|
||||
StringBuilder buf = new StringBuilder(s.substring(0, idx));
|
||||
for (; idx < s.length(); idx++) {
|
||||
buf.append(toUpper(s.charAt(idx)));
|
||||
}
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
public static String toTitleString(String s) {
|
||||
if (s.length() == 0) {
|
||||
return s;
|
||||
}
|
||||
int idx = 0;
|
||||
char c = s.charAt(idx);
|
||||
if (!(c >= 'a' && c <= 'z')) {
|
||||
for (idx = 1; idx < s.length(); idx++) {
|
||||
if (c >= 'A' && c <= 'Z') {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (idx == s.length()) {
|
||||
return s;
|
||||
}
|
||||
StringBuilder buf = new StringBuilder(s.substring(0, idx));
|
||||
if (idx == 0) {
|
||||
buf.append(toUpper(s.charAt(idx)));
|
||||
idx++;
|
||||
}
|
||||
for (; idx < s.length(); idx++) {
|
||||
buf.append(toLower(s.charAt(idx)));
|
||||
}
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
public static boolean isAlpha(char c) {
|
||||
return (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z');
|
||||
}
|
||||
|
||||
public static boolean isAlphaString(String s) {
|
||||
boolean b = true;
|
||||
for (int i = 0; i < s.length(); i++) {
|
||||
if (!isAlpha(s.charAt(i))) {
|
||||
b = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return b;
|
||||
}
|
||||
|
||||
public static boolean isNumeric(char c) {
|
||||
return (c >= '0' && c <= '9');
|
||||
}
|
||||
|
||||
public static boolean isNumericString(String s) {
|
||||
boolean b = true;
|
||||
for (int i = 0; i < s.length(); i++) {
|
||||
if (!isNumeric(s.charAt(i))) {
|
||||
b = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return b;
|
||||
}
|
||||
|
||||
public static boolean isAlphaNumeric(char c) {
|
||||
return isAlpha(c) || isNumeric(c);
|
||||
}
|
||||
|
||||
public static boolean isAlphaNumericString(String s) {
|
||||
boolean b = true;
|
||||
for (int i = 0; i < s.length(); i++) {
|
||||
if (!isAlphaNumeric(s.charAt(i))) {
|
||||
b = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return b;
|
||||
}
|
||||
|
||||
public static class CaseInsensitiveKey {
|
||||
private String _key;
|
||||
private int _hash;
|
||||
|
||||
public CaseInsensitiveKey(String key) {
|
||||
_key = key;
|
||||
_hash = AsciiUtil.toLowerString(key).hashCode();
|
||||
}
|
||||
|
||||
public boolean equals(Object o) {
|
||||
if (o instanceof CaseInsensitiveKey) {
|
||||
return AsciiUtil.caseIgnoreMatch(_key, ((CaseInsensitiveKey)o)._key);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
return _hash;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -1,14 +1,14 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2011, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
package com.ibm.icu.text;
|
||||
|
||||
/*
|
||||
* Empty stub
|
||||
*/
|
||||
public class BidiClassifier {
|
||||
private BidiClassifier() {}
|
||||
}
|
||||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2011, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
package com.ibm.icu.text;
|
||||
|
||||
/*
|
||||
* Empty stub
|
||||
*/
|
||||
public class BidiClassifier {
|
||||
private BidiClassifier() {}
|
||||
}
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2011, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
package com.ibm.icu.text;
|
||||
|
||||
/*
|
||||
* Empty stub
|
||||
*/
|
||||
public class BidiRun {
|
||||
private BidiRun() {}
|
||||
}
|
||||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2011, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
package com.ibm.icu.text;
|
||||
|
||||
/*
|
||||
* Empty stub
|
||||
*/
|
||||
public class BidiRun {
|
||||
private BidiRun() {}
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,415 +1,415 @@
|
|||
/**
|
||||
*******************************************************************************
|
||||
* Copyright (C) 1996-2011, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
package com.ibm.icu.text;
|
||||
|
||||
/**
|
||||
* <p>A <code>CollationKey</code> represents a <code>String</code>
|
||||
* under the rules of a specific <code>Collator</code>
|
||||
* object. Comparing two <code>CollationKey</code>s returns the
|
||||
* relative order of the <code>String</code>s they represent.</p>
|
||||
*
|
||||
* <p>Since the rule set of <code>Collator</code>s can differ, the
|
||||
* sort orders of the same string under two different
|
||||
* <code>Collator</code>s might differ. Hence comparing
|
||||
* <code>CollationKey</code>s generated from different
|
||||
* <code>Collator</code>s can give incorrect results.</p>
|
||||
|
||||
* <p>Both the method
|
||||
* <code>CollationKey.compareTo(CollationKey)</code> and the method
|
||||
* <code>Collator.compare(String, String)</code> compare two strings
|
||||
* and returns their relative order. The performance characterictics
|
||||
* of these two approaches can differ.</p>
|
||||
*
|
||||
* <p>During the construction of a <code>CollationKey</code>, the
|
||||
* entire source string is examined and processed into a series of
|
||||
* bits terminated by a null, that are stored in the <code>CollationKey</code>.
|
||||
* When <code>CollationKey.compareTo(CollationKey)</code> executes, it
|
||||
* performs bitwise comparison on the bit sequences. This can incurs
|
||||
* startup cost when creating the <code>CollationKey</code>, but once
|
||||
* the key is created, binary comparisons are fast. This approach is
|
||||
* recommended when the same strings are to be compared over and over
|
||||
* again.</p>
|
||||
*
|
||||
* <p>On the other hand, implementations of
|
||||
* <code>Collator.compare(String, String)</code> can examine and
|
||||
* process the strings only until the first characters differing in
|
||||
* order. This approach is recommended if the strings are to be
|
||||
* compared only once.</p>
|
||||
*
|
||||
* <p>More information about the composition of the bit sequence can
|
||||
* be found in the
|
||||
* <a href="http://www.icu-project.org/userguide/Collate_ServiceArchitecture.html">
|
||||
* user guide</a>.</p>
|
||||
*
|
||||
* <p>The following example shows how <code>CollationKey</code>s can be used
|
||||
* to sort a list of <code>String</code>s.</p>
|
||||
* <blockquote>
|
||||
* <pre>
|
||||
* // Create an array of CollationKeys for the Strings to be sorted.
|
||||
* Collator myCollator = Collator.getInstance();
|
||||
* CollationKey[] keys = new CollationKey[3];
|
||||
* keys[0] = myCollator.getCollationKey("Tom");
|
||||
* keys[1] = myCollator.getCollationKey("Dick");
|
||||
* keys[2] = myCollator.getCollationKey("Harry");
|
||||
* sort( keys );
|
||||
* <br>
|
||||
* //...
|
||||
* <br>
|
||||
* // Inside body of sort routine, compare keys this way
|
||||
* if( keys[i].compareTo( keys[j] ) > 0 )
|
||||
* // swap keys[i] and keys[j]
|
||||
* <br>
|
||||
* //...
|
||||
* <br>
|
||||
* // Finally, when we've returned from sort.
|
||||
* System.out.println( keys[0].getSourceString() );
|
||||
* System.out.println( keys[1].getSourceString() );
|
||||
* System.out.println( keys[2].getSourceString() );
|
||||
* </pre>
|
||||
* </blockquote>
|
||||
* </p>
|
||||
* <p>
|
||||
* This class is not subclassable
|
||||
* </p>
|
||||
* @see Collator
|
||||
* @see RuleBasedCollator
|
||||
* @author Syn Wee Quek
|
||||
* @stable ICU 2.8
|
||||
*/
|
||||
public final class CollationKey implements Comparable<CollationKey>
|
||||
{
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
final java.text.CollationKey key;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
CollationKey(java.text.CollationKey delegate) {
|
||||
this.key = delegate;
|
||||
}
|
||||
|
||||
// public inner classes -------------------------------------------------
|
||||
|
||||
/**
|
||||
* Options that used in the API CollationKey.getBound() for getting a
|
||||
* CollationKey based on the bound mode requested.
|
||||
* @stable ICU 2.6
|
||||
*/
|
||||
public static final class BoundMode
|
||||
{
|
||||
/*
|
||||
* do not change the values assigned to the members of this enum.
|
||||
* Underlying code depends on them having these numbers
|
||||
*/
|
||||
|
||||
/**
|
||||
* Lower bound
|
||||
* @stable ICU 2.6
|
||||
*/
|
||||
public static final int LOWER = 0;
|
||||
|
||||
/**
|
||||
* Upper bound that will match strings of exact size
|
||||
* @stable ICU 2.6
|
||||
*/
|
||||
public static final int UPPER = 1;
|
||||
|
||||
/**
|
||||
* Upper bound that will match all the strings that have the same
|
||||
* initial substring as the given string
|
||||
* @stable ICU 2.6
|
||||
*/
|
||||
public static final int UPPER_LONG = 2;
|
||||
|
||||
/**
|
||||
* Number of bound mode
|
||||
* @stable ICU 2.6
|
||||
*/
|
||||
public static final int COUNT = 3;
|
||||
|
||||
/**
|
||||
* Private Constructor
|
||||
*/
|
||||
///CLOVER:OFF
|
||||
private BoundMode(){}
|
||||
///CLOVER:ON
|
||||
}
|
||||
|
||||
// public constructor ---------------------------------------------------
|
||||
|
||||
/**
|
||||
* CollationKey constructor.
|
||||
* This constructor is given public access, unlike the JDK version, to
|
||||
* allow access to users extending the Collator class. See
|
||||
* {@link Collator#getCollationKey(String)}.
|
||||
* @param source string this CollationKey is to represent
|
||||
* @param key array of bytes that represent the collation order of argument
|
||||
* source terminated by a null
|
||||
* @see Collator
|
||||
* @stable ICU 2.8
|
||||
*/
|
||||
public CollationKey(String source, byte key[])
|
||||
{
|
||||
throw new UnsupportedOperationException("Constructor not supported by com.ibm.icu.base");
|
||||
}
|
||||
|
||||
/**
|
||||
* CollationKey constructor that forces key to release its internal byte
|
||||
* array for adoption. key will have a null byte array after this
|
||||
* construction.
|
||||
* @param source string this CollationKey is to represent
|
||||
* @param key RawCollationKey object that represents the collation order of
|
||||
* argument source.
|
||||
* @see Collator
|
||||
* @see RawCollationKey
|
||||
* @stable ICU 2.8
|
||||
*/
|
||||
public CollationKey(String source, RawCollationKey key)
|
||||
{
|
||||
throw new UnsupportedOperationException("Constructor not supported by com.ibm.icu.base");
|
||||
}
|
||||
|
||||
// public getters -------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Return the source string that this CollationKey represents.
|
||||
* @return source string that this CollationKey represents
|
||||
* @stable ICU 2.8
|
||||
*/
|
||||
public String getSourceString()
|
||||
{
|
||||
return key.getSourceString();
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Duplicates and returns the value of this CollationKey as a sequence
|
||||
* of big-endian bytes terminated by a null.</p>
|
||||
*
|
||||
* <p>If two CollationKeys can be legitimately compared, then one can
|
||||
* compare the byte arrays of each to obtain the same result, e.g.
|
||||
* <pre>
|
||||
* byte key1[] = collationkey1.toByteArray();
|
||||
* byte key2[] = collationkey2.toByteArray();
|
||||
* int key, targetkey;
|
||||
* int i = 0;
|
||||
* do {
|
||||
* key = key1[i] & 0xFF;
|
||||
* targetkey = key2[i] & 0xFF;
|
||||
* if (key < targetkey) {
|
||||
* System.out.println("String 1 is less than string 2");
|
||||
* return;
|
||||
* }
|
||||
* if (targetkey < key) {
|
||||
* System.out.println("String 1 is more than string 2");
|
||||
* }
|
||||
* i ++;
|
||||
* } while (key != 0 && targetKey != 0);
|
||||
*
|
||||
* System.out.println("Strings are equal.");
|
||||
* </pre>
|
||||
* </p>
|
||||
* @return CollationKey value in a sequence of big-endian byte bytes
|
||||
* terminated by a null.
|
||||
* @stable ICU 2.8
|
||||
*/
|
||||
public byte[] toByteArray()
|
||||
{
|
||||
return key.toByteArray();
|
||||
}
|
||||
|
||||
// public other methods -------------------------------------------------
|
||||
|
||||
/**
|
||||
* <p>Compare this CollationKey to another CollationKey. The
|
||||
* collation rules of the Collator that created this key are
|
||||
* applied.</p>
|
||||
*
|
||||
* <p><strong>Note:</strong> Comparison between CollationKeys
|
||||
* created by different Collators might return incorrect
|
||||
* results. See class documentation.</p>
|
||||
*
|
||||
* @param target target CollationKey
|
||||
* @return an integer value. If the value is less than zero this CollationKey
|
||||
* is less than than target, if the value is zero they are equal, and
|
||||
* if the value is greater than zero this CollationKey is greater
|
||||
* than target.
|
||||
* @exception NullPointerException is thrown if argument is null.
|
||||
* @see Collator#compare(String, String)
|
||||
* @stable ICU 2.8
|
||||
*/
|
||||
public int compareTo(CollationKey target)
|
||||
{
|
||||
return key.compareTo(target.key);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Compare this CollationKey and the specified Object for
|
||||
* equality. The collation rules of the Collator that created
|
||||
* this key are applied.</p>
|
||||
*
|
||||
* <p>See note in compareTo(CollationKey) for warnings about
|
||||
* possible incorrect results.</p>
|
||||
*
|
||||
* @param target the object to compare to.
|
||||
* @return true if the two keys compare as equal, false otherwise.
|
||||
* @see #compareTo(CollationKey)
|
||||
* @exception ClassCastException is thrown when the argument is not
|
||||
* a CollationKey. NullPointerException is thrown when the argument
|
||||
* is null.
|
||||
* @stable ICU 2.8
|
||||
*/
|
||||
public boolean equals(Object target)
|
||||
{
|
||||
if (!(target instanceof CollationKey)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return equals((CollationKey)target);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Compare this CollationKey and the argument target CollationKey for
|
||||
* equality.
|
||||
* The collation
|
||||
* rules of the Collator object which created these objects are applied.
|
||||
* </p>
|
||||
* <p>
|
||||
* See note in compareTo(CollationKey) for warnings of incorrect results
|
||||
* </p>
|
||||
* @param target the CollationKey to compare to.
|
||||
* @return true if two objects are equal, false otherwise.
|
||||
* @exception NullPointerException is thrown when the argument is null.
|
||||
* @stable ICU 2.8
|
||||
*/
|
||||
public boolean equals(CollationKey target)
|
||||
{
|
||||
return key.equals(target.key);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Returns a hash code for this CollationKey. The hash value is calculated
|
||||
* on the key itself, not the String from which the key was created. Thus
|
||||
* if x and y are CollationKeys, then x.hashCode(x) == y.hashCode()
|
||||
* if x.equals(y) is true. This allows language-sensitive comparison in a
|
||||
* hash table.
|
||||
* </p>
|
||||
* @return the hash value.
|
||||
* @stable ICU 2.8
|
||||
*/
|
||||
public int hashCode()
|
||||
{
|
||||
return key.hashCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Produce a bound for the sort order of a given collation key and a
|
||||
* strength level. This API does not attempt to find a bound for the
|
||||
* CollationKey String representation, hence null will be returned in its
|
||||
* place.
|
||||
* </p>
|
||||
* <p>
|
||||
* Resulting bounds can be used to produce a range of strings that are
|
||||
* between upper and lower bounds. For example, if bounds are produced
|
||||
* for a sortkey of string "smith", strings between upper and lower
|
||||
* bounds with primary strength would include "Smith", "SMITH", "sMiTh".
|
||||
* </p>
|
||||
* <p>
|
||||
* There are two upper bounds that can be produced. If BoundMode.UPPER
|
||||
* is produced, strings matched would be as above. However, if a bound
|
||||
* is produced using BoundMode.UPPER_LONG is used, the above example will
|
||||
* also match "Smithsonian" and similar.
|
||||
* </p>
|
||||
* <p>
|
||||
* For more on usage, see example in test procedure
|
||||
* <a href="http://source.icu-project.org/repos/icu/icu4j/trunk/src/com/ibm/icu/dev/test/collator/CollationAPITest.java">
|
||||
* src/com/ibm/icu/dev/test/collator/CollationAPITest/TestBounds.
|
||||
* </a>
|
||||
* </p>
|
||||
* <p>
|
||||
* Collation keys produced may be compared using the <TT>compare</TT> API.
|
||||
* </p>
|
||||
* @param boundType Mode of bound required. It can be BoundMode.LOWER, which
|
||||
* produces a lower inclusive bound, BoundMode.UPPER, that
|
||||
* produces upper bound that matches strings of the same
|
||||
* length or BoundMode.UPPER_LONG that matches strings that
|
||||
* have the same starting substring as the source string.
|
||||
* @param noOfLevels Strength levels required in the resulting bound
|
||||
* (for most uses, the recommended value is PRIMARY). This
|
||||
* strength should be less than the maximum strength of
|
||||
* this CollationKey.
|
||||
* See users guide for explanation on the strength levels a
|
||||
* collation key can have.
|
||||
* @return the result bounded CollationKey with a valid sort order but
|
||||
* a null String representation.
|
||||
* @exception IllegalArgumentException thrown when the strength level
|
||||
* requested is higher than or equal to the strength in this
|
||||
* CollationKey.
|
||||
* In the case of an Exception, information
|
||||
* about the maximum strength to use will be returned in the
|
||||
* Exception. The user can then call getBound() again with the
|
||||
* appropriate strength.
|
||||
* @see CollationKey
|
||||
* @see CollationKey.BoundMode
|
||||
* @see Collator#PRIMARY
|
||||
* @see Collator#SECONDARY
|
||||
* @see Collator#TERTIARY
|
||||
* @see Collator#QUATERNARY
|
||||
* @see Collator#IDENTICAL
|
||||
* @stable ICU 2.6
|
||||
*/
|
||||
public CollationKey getBound(int boundType, int noOfLevels)
|
||||
{
|
||||
throw new UnsupportedOperationException("Method not supported by com.ibm.icu.base");
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Merges this CollationKey with another. Only the sorting order of the
|
||||
* CollationKeys will be merged. This API does not attempt to merge the
|
||||
* String representations of the CollationKeys, hence null will be returned
|
||||
* as the String representation.
|
||||
* </p>
|
||||
* <p>
|
||||
* The strength levels are merged with their corresponding counterparts
|
||||
* (PRIMARIES with PRIMARIES, SECONDARIES with SECONDARIES etc.).
|
||||
* </p>
|
||||
* <p>
|
||||
* The merged String representation of the result CollationKey will be a
|
||||
* concatenation of the String representations of the 2 source
|
||||
* CollationKeys.
|
||||
* </p>
|
||||
* <p>
|
||||
* Between the values from the same level a separator is inserted.
|
||||
* example (uncompressed):
|
||||
* <pre>
|
||||
* 191B1D 01 050505 01 910505 00 and 1F2123 01 050505 01 910505 00
|
||||
* will be merged as
|
||||
* 191B1D 02 1F212301 050505 02 050505 01 910505 02 910505 00
|
||||
* </pre>
|
||||
* </p>
|
||||
* <p>
|
||||
* This allows for concatenating of first and last names for sorting, among
|
||||
* other things.
|
||||
* </p>
|
||||
* </p>
|
||||
* @param source CollationKey to merge with
|
||||
* @return a CollationKey that contains the valid merged sorting order
|
||||
* with a null String representation,
|
||||
* i.e. <tt>new CollationKey(null, merge_sort_order)</tt>
|
||||
* @exception IllegalArgumentException thrown if source CollationKey
|
||||
* argument is null or of 0 length.
|
||||
* @stable ICU 2.6
|
||||
*/
|
||||
public CollationKey merge(CollationKey source)
|
||||
{
|
||||
throw new UnsupportedOperationException("Method not supported by com.ibm.icu.base");
|
||||
}
|
||||
}
|
||||
/**
|
||||
*******************************************************************************
|
||||
* Copyright (C) 1996-2011, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
package com.ibm.icu.text;
|
||||
|
||||
/**
|
||||
* <p>A <code>CollationKey</code> represents a <code>String</code>
|
||||
* under the rules of a specific <code>Collator</code>
|
||||
* object. Comparing two <code>CollationKey</code>s returns the
|
||||
* relative order of the <code>String</code>s they represent.</p>
|
||||
*
|
||||
* <p>Since the rule set of <code>Collator</code>s can differ, the
|
||||
* sort orders of the same string under two different
|
||||
* <code>Collator</code>s might differ. Hence comparing
|
||||
* <code>CollationKey</code>s generated from different
|
||||
* <code>Collator</code>s can give incorrect results.</p>
|
||||
|
||||
* <p>Both the method
|
||||
* <code>CollationKey.compareTo(CollationKey)</code> and the method
|
||||
* <code>Collator.compare(String, String)</code> compare two strings
|
||||
* and returns their relative order. The performance characterictics
|
||||
* of these two approaches can differ.</p>
|
||||
*
|
||||
* <p>During the construction of a <code>CollationKey</code>, the
|
||||
* entire source string is examined and processed into a series of
|
||||
* bits terminated by a null, that are stored in the <code>CollationKey</code>.
|
||||
* When <code>CollationKey.compareTo(CollationKey)</code> executes, it
|
||||
* performs bitwise comparison on the bit sequences. This can incurs
|
||||
* startup cost when creating the <code>CollationKey</code>, but once
|
||||
* the key is created, binary comparisons are fast. This approach is
|
||||
* recommended when the same strings are to be compared over and over
|
||||
* again.</p>
|
||||
*
|
||||
* <p>On the other hand, implementations of
|
||||
* <code>Collator.compare(String, String)</code> can examine and
|
||||
* process the strings only until the first characters differing in
|
||||
* order. This approach is recommended if the strings are to be
|
||||
* compared only once.</p>
|
||||
*
|
||||
* <p>More information about the composition of the bit sequence can
|
||||
* be found in the
|
||||
* <a href="http://www.icu-project.org/userguide/Collate_ServiceArchitecture.html">
|
||||
* user guide</a>.</p>
|
||||
*
|
||||
* <p>The following example shows how <code>CollationKey</code>s can be used
|
||||
* to sort a list of <code>String</code>s.</p>
|
||||
* <blockquote>
|
||||
* <pre>
|
||||
* // Create an array of CollationKeys for the Strings to be sorted.
|
||||
* Collator myCollator = Collator.getInstance();
|
||||
* CollationKey[] keys = new CollationKey[3];
|
||||
* keys[0] = myCollator.getCollationKey("Tom");
|
||||
* keys[1] = myCollator.getCollationKey("Dick");
|
||||
* keys[2] = myCollator.getCollationKey("Harry");
|
||||
* sort( keys );
|
||||
* <br>
|
||||
* //...
|
||||
* <br>
|
||||
* // Inside body of sort routine, compare keys this way
|
||||
* if( keys[i].compareTo( keys[j] ) > 0 )
|
||||
* // swap keys[i] and keys[j]
|
||||
* <br>
|
||||
* //...
|
||||
* <br>
|
||||
* // Finally, when we've returned from sort.
|
||||
* System.out.println( keys[0].getSourceString() );
|
||||
* System.out.println( keys[1].getSourceString() );
|
||||
* System.out.println( keys[2].getSourceString() );
|
||||
* </pre>
|
||||
* </blockquote>
|
||||
* </p>
|
||||
* <p>
|
||||
* This class is not subclassable
|
||||
* </p>
|
||||
* @see Collator
|
||||
* @see RuleBasedCollator
|
||||
* @author Syn Wee Quek
|
||||
* @stable ICU 2.8
|
||||
*/
|
||||
public final class CollationKey implements Comparable<CollationKey>
|
||||
{
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
final java.text.CollationKey key;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
CollationKey(java.text.CollationKey delegate) {
|
||||
this.key = delegate;
|
||||
}
|
||||
|
||||
// public inner classes -------------------------------------------------
|
||||
|
||||
/**
|
||||
* Options that used in the API CollationKey.getBound() for getting a
|
||||
* CollationKey based on the bound mode requested.
|
||||
* @stable ICU 2.6
|
||||
*/
|
||||
public static final class BoundMode
|
||||
{
|
||||
/*
|
||||
* do not change the values assigned to the members of this enum.
|
||||
* Underlying code depends on them having these numbers
|
||||
*/
|
||||
|
||||
/**
|
||||
* Lower bound
|
||||
* @stable ICU 2.6
|
||||
*/
|
||||
public static final int LOWER = 0;
|
||||
|
||||
/**
|
||||
* Upper bound that will match strings of exact size
|
||||
* @stable ICU 2.6
|
||||
*/
|
||||
public static final int UPPER = 1;
|
||||
|
||||
/**
|
||||
* Upper bound that will match all the strings that have the same
|
||||
* initial substring as the given string
|
||||
* @stable ICU 2.6
|
||||
*/
|
||||
public static final int UPPER_LONG = 2;
|
||||
|
||||
/**
|
||||
* Number of bound mode
|
||||
* @stable ICU 2.6
|
||||
*/
|
||||
public static final int COUNT = 3;
|
||||
|
||||
/**
|
||||
* Private Constructor
|
||||
*/
|
||||
///CLOVER:OFF
|
||||
private BoundMode(){}
|
||||
///CLOVER:ON
|
||||
}
|
||||
|
||||
// public constructor ---------------------------------------------------
|
||||
|
||||
/**
|
||||
* CollationKey constructor.
|
||||
* This constructor is given public access, unlike the JDK version, to
|
||||
* allow access to users extending the Collator class. See
|
||||
* {@link Collator#getCollationKey(String)}.
|
||||
* @param source string this CollationKey is to represent
|
||||
* @param key array of bytes that represent the collation order of argument
|
||||
* source terminated by a null
|
||||
* @see Collator
|
||||
* @stable ICU 2.8
|
||||
*/
|
||||
public CollationKey(String source, byte key[])
|
||||
{
|
||||
throw new UnsupportedOperationException("Constructor not supported by com.ibm.icu.base");
|
||||
}
|
||||
|
||||
/**
|
||||
* CollationKey constructor that forces key to release its internal byte
|
||||
* array for adoption. key will have a null byte array after this
|
||||
* construction.
|
||||
* @param source string this CollationKey is to represent
|
||||
* @param key RawCollationKey object that represents the collation order of
|
||||
* argument source.
|
||||
* @see Collator
|
||||
* @see RawCollationKey
|
||||
* @stable ICU 2.8
|
||||
*/
|
||||
public CollationKey(String source, RawCollationKey key)
|
||||
{
|
||||
throw new UnsupportedOperationException("Constructor not supported by com.ibm.icu.base");
|
||||
}
|
||||
|
||||
// public getters -------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Return the source string that this CollationKey represents.
|
||||
* @return source string that this CollationKey represents
|
||||
* @stable ICU 2.8
|
||||
*/
|
||||
public String getSourceString()
|
||||
{
|
||||
return key.getSourceString();
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Duplicates and returns the value of this CollationKey as a sequence
|
||||
* of big-endian bytes terminated by a null.</p>
|
||||
*
|
||||
* <p>If two CollationKeys can be legitimately compared, then one can
|
||||
* compare the byte arrays of each to obtain the same result, e.g.
|
||||
* <pre>
|
||||
* byte key1[] = collationkey1.toByteArray();
|
||||
* byte key2[] = collationkey2.toByteArray();
|
||||
* int key, targetkey;
|
||||
* int i = 0;
|
||||
* do {
|
||||
* key = key1[i] & 0xFF;
|
||||
* targetkey = key2[i] & 0xFF;
|
||||
* if (key < targetkey) {
|
||||
* System.out.println("String 1 is less than string 2");
|
||||
* return;
|
||||
* }
|
||||
* if (targetkey < key) {
|
||||
* System.out.println("String 1 is more than string 2");
|
||||
* }
|
||||
* i ++;
|
||||
* } while (key != 0 && targetKey != 0);
|
||||
*
|
||||
* System.out.println("Strings are equal.");
|
||||
* </pre>
|
||||
* </p>
|
||||
* @return CollationKey value in a sequence of big-endian byte bytes
|
||||
* terminated by a null.
|
||||
* @stable ICU 2.8
|
||||
*/
|
||||
public byte[] toByteArray()
|
||||
{
|
||||
return key.toByteArray();
|
||||
}
|
||||
|
||||
// public other methods -------------------------------------------------
|
||||
|
||||
/**
|
||||
* <p>Compare this CollationKey to another CollationKey. The
|
||||
* collation rules of the Collator that created this key are
|
||||
* applied.</p>
|
||||
*
|
||||
* <p><strong>Note:</strong> Comparison between CollationKeys
|
||||
* created by different Collators might return incorrect
|
||||
* results. See class documentation.</p>
|
||||
*
|
||||
* @param target target CollationKey
|
||||
* @return an integer value. If the value is less than zero this CollationKey
|
||||
* is less than than target, if the value is zero they are equal, and
|
||||
* if the value is greater than zero this CollationKey is greater
|
||||
* than target.
|
||||
* @exception NullPointerException is thrown if argument is null.
|
||||
* @see Collator#compare(String, String)
|
||||
* @stable ICU 2.8
|
||||
*/
|
||||
public int compareTo(CollationKey target)
|
||||
{
|
||||
return key.compareTo(target.key);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Compare this CollationKey and the specified Object for
|
||||
* equality. The collation rules of the Collator that created
|
||||
* this key are applied.</p>
|
||||
*
|
||||
* <p>See note in compareTo(CollationKey) for warnings about
|
||||
* possible incorrect results.</p>
|
||||
*
|
||||
* @param target the object to compare to.
|
||||
* @return true if the two keys compare as equal, false otherwise.
|
||||
* @see #compareTo(CollationKey)
|
||||
* @exception ClassCastException is thrown when the argument is not
|
||||
* a CollationKey. NullPointerException is thrown when the argument
|
||||
* is null.
|
||||
* @stable ICU 2.8
|
||||
*/
|
||||
public boolean equals(Object target)
|
||||
{
|
||||
if (!(target instanceof CollationKey)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return equals((CollationKey)target);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Compare this CollationKey and the argument target CollationKey for
|
||||
* equality.
|
||||
* The collation
|
||||
* rules of the Collator object which created these objects are applied.
|
||||
* </p>
|
||||
* <p>
|
||||
* See note in compareTo(CollationKey) for warnings of incorrect results
|
||||
* </p>
|
||||
* @param target the CollationKey to compare to.
|
||||
* @return true if two objects are equal, false otherwise.
|
||||
* @exception NullPointerException is thrown when the argument is null.
|
||||
* @stable ICU 2.8
|
||||
*/
|
||||
public boolean equals(CollationKey target)
|
||||
{
|
||||
return key.equals(target.key);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Returns a hash code for this CollationKey. The hash value is calculated
|
||||
* on the key itself, not the String from which the key was created. Thus
|
||||
* if x and y are CollationKeys, then x.hashCode(x) == y.hashCode()
|
||||
* if x.equals(y) is true. This allows language-sensitive comparison in a
|
||||
* hash table.
|
||||
* </p>
|
||||
* @return the hash value.
|
||||
* @stable ICU 2.8
|
||||
*/
|
||||
public int hashCode()
|
||||
{
|
||||
return key.hashCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Produce a bound for the sort order of a given collation key and a
|
||||
* strength level. This API does not attempt to find a bound for the
|
||||
* CollationKey String representation, hence null will be returned in its
|
||||
* place.
|
||||
* </p>
|
||||
* <p>
|
||||
* Resulting bounds can be used to produce a range of strings that are
|
||||
* between upper and lower bounds. For example, if bounds are produced
|
||||
* for a sortkey of string "smith", strings between upper and lower
|
||||
* bounds with primary strength would include "Smith", "SMITH", "sMiTh".
|
||||
* </p>
|
||||
* <p>
|
||||
* There are two upper bounds that can be produced. If BoundMode.UPPER
|
||||
* is produced, strings matched would be as above. However, if a bound
|
||||
* is produced using BoundMode.UPPER_LONG is used, the above example will
|
||||
* also match "Smithsonian" and similar.
|
||||
* </p>
|
||||
* <p>
|
||||
* For more on usage, see example in test procedure
|
||||
* <a href="http://source.icu-project.org/repos/icu/icu4j/trunk/src/com/ibm/icu/dev/test/collator/CollationAPITest.java">
|
||||
* src/com/ibm/icu/dev/test/collator/CollationAPITest/TestBounds.
|
||||
* </a>
|
||||
* </p>
|
||||
* <p>
|
||||
* Collation keys produced may be compared using the <TT>compare</TT> API.
|
||||
* </p>
|
||||
* @param boundType Mode of bound required. It can be BoundMode.LOWER, which
|
||||
* produces a lower inclusive bound, BoundMode.UPPER, that
|
||||
* produces upper bound that matches strings of the same
|
||||
* length or BoundMode.UPPER_LONG that matches strings that
|
||||
* have the same starting substring as the source string.
|
||||
* @param noOfLevels Strength levels required in the resulting bound
|
||||
* (for most uses, the recommended value is PRIMARY). This
|
||||
* strength should be less than the maximum strength of
|
||||
* this CollationKey.
|
||||
* See users guide for explanation on the strength levels a
|
||||
* collation key can have.
|
||||
* @return the result bounded CollationKey with a valid sort order but
|
||||
* a null String representation.
|
||||
* @exception IllegalArgumentException thrown when the strength level
|
||||
* requested is higher than or equal to the strength in this
|
||||
* CollationKey.
|
||||
* In the case of an Exception, information
|
||||
* about the maximum strength to use will be returned in the
|
||||
* Exception. The user can then call getBound() again with the
|
||||
* appropriate strength.
|
||||
* @see CollationKey
|
||||
* @see CollationKey.BoundMode
|
||||
* @see Collator#PRIMARY
|
||||
* @see Collator#SECONDARY
|
||||
* @see Collator#TERTIARY
|
||||
* @see Collator#QUATERNARY
|
||||
* @see Collator#IDENTICAL
|
||||
* @stable ICU 2.6
|
||||
*/
|
||||
public CollationKey getBound(int boundType, int noOfLevels)
|
||||
{
|
||||
throw new UnsupportedOperationException("Method not supported by com.ibm.icu.base");
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Merges this CollationKey with another. Only the sorting order of the
|
||||
* CollationKeys will be merged. This API does not attempt to merge the
|
||||
* String representations of the CollationKeys, hence null will be returned
|
||||
* as the String representation.
|
||||
* </p>
|
||||
* <p>
|
||||
* The strength levels are merged with their corresponding counterparts
|
||||
* (PRIMARIES with PRIMARIES, SECONDARIES with SECONDARIES etc.).
|
||||
* </p>
|
||||
* <p>
|
||||
* The merged String representation of the result CollationKey will be a
|
||||
* concatenation of the String representations of the 2 source
|
||||
* CollationKeys.
|
||||
* </p>
|
||||
* <p>
|
||||
* Between the values from the same level a separator is inserted.
|
||||
* example (uncompressed):
|
||||
* <pre>
|
||||
* 191B1D 01 050505 01 910505 00 and 1F2123 01 050505 01 910505 00
|
||||
* will be merged as
|
||||
* 191B1D 02 1F212301 050505 02 050505 01 910505 02 910505 00
|
||||
* </pre>
|
||||
* </p>
|
||||
* <p>
|
||||
* This allows for concatenating of first and last names for sorting, among
|
||||
* other things.
|
||||
* </p>
|
||||
* </p>
|
||||
* @param source CollationKey to merge with
|
||||
* @return a CollationKey that contains the valid merged sorting order
|
||||
* with a null String representation,
|
||||
* i.e. <tt>new CollationKey(null, merge_sort_order)</tt>
|
||||
* @exception IllegalArgumentException thrown if source CollationKey
|
||||
* argument is null or of 0 length.
|
||||
* @stable ICU 2.6
|
||||
*/
|
||||
public CollationKey merge(CollationKey source)
|
||||
{
|
||||
throw new UnsupportedOperationException("Method not supported by com.ibm.icu.base");
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,14 +1,14 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2011, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
package com.ibm.icu.text;
|
||||
|
||||
/*
|
||||
* Empty stub
|
||||
*/
|
||||
public class CurrencyPluralInfo {
|
||||
private CurrencyPluralInfo() {}
|
||||
}
|
||||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2011, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
package com.ibm.icu.text;
|
||||
|
||||
/*
|
||||
* Empty stub
|
||||
*/
|
||||
public class CurrencyPluralInfo {
|
||||
private CurrencyPluralInfo() {}
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -1,350 +1,350 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 1996-2011, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
package com.ibm.icu.text;
|
||||
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Locale;
|
||||
|
||||
import com.ibm.icu.util.ULocale;
|
||||
|
||||
/**
|
||||
* This class represents the set of symbols (such as the decimal separator, the
|
||||
* grouping separator, and so on) needed by <code>DecimalFormat</code> to format
|
||||
* numbers. <code>DecimalFormat</code> creates for itself an instance of
|
||||
* <code>DecimalFormatSymbols</code> from its locale data. If you need to
|
||||
* change any of these symbols, you can get the
|
||||
* <code>DecimalFormatSymbols</code> object from your <code>DecimalFormat</code>
|
||||
* and modify it.
|
||||
*
|
||||
* <p><strong>This is an enhanced version of <code>DecimalFormatSymbols</code> that
|
||||
* is based on the standard version in the JDK. New or changed functionality
|
||||
* is labeled
|
||||
* <strong><font face=helvetica color=red>NEW</font></strong>.</strong>
|
||||
*
|
||||
* @see java.util.Locale
|
||||
* @see DecimalFormat
|
||||
* @author Mark Davis
|
||||
* @author Alan Liu
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
final public class DecimalFormatSymbols implements Cloneable, Serializable {
|
||||
|
||||
private static final long serialVersionUID =1L;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
public final java.text.DecimalFormatSymbols dfs;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
public DecimalFormatSymbols(java.text.DecimalFormatSymbols delegate) {
|
||||
this.dfs = delegate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a DecimalFormatSymbols object for the default locale.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
public DecimalFormatSymbols() {
|
||||
this(new java.text.DecimalFormatSymbols());
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a DecimalFormatSymbols object for the given locale.
|
||||
* @param locale the locale
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
public DecimalFormatSymbols(Locale locale) {
|
||||
this(new java.text.DecimalFormatSymbols(locale));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a DecimalFormatSymbols object for the given locale.
|
||||
* @param locale the locale
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
public DecimalFormatSymbols(ULocale locale) {
|
||||
this(new java.text.DecimalFormatSymbols(locale.toLocale()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the character used for zero. Different for Arabic, etc.
|
||||
* @return the character
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
public char getZeroDigit() {
|
||||
return dfs.getZeroDigit();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the character used for zero.
|
||||
* @param zeroDigit the zero character.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
public void setZeroDigit(char zeroDigit) {
|
||||
dfs.setZeroDigit(zeroDigit);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the character used for thousands separator. Different for French, etc.
|
||||
* @return the thousands character
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
public char getGroupingSeparator() {
|
||||
return dfs.getGroupingSeparator();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the character used for thousands separator. Different for French, etc.
|
||||
* @param groupingSeparator the thousands character
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
public void setGroupingSeparator(char groupingSeparator) {
|
||||
dfs.setGroupingSeparator(groupingSeparator);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the character used for decimal sign. Different for French, etc.
|
||||
* @return the decimal character
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
public char getDecimalSeparator() {
|
||||
return dfs.getDecimalSeparator();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the character used for decimal sign. Different for French, etc.
|
||||
* @param decimalSeparator the decimal character
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
public void setDecimalSeparator(char decimalSeparator) {
|
||||
dfs.setDecimalSeparator(decimalSeparator);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the character used for mille percent sign. Different for Arabic, etc.
|
||||
* @return the mille percent character
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
public char getPerMill() {
|
||||
return dfs.getPerMill();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the character used for mille percent sign. Different for Arabic, etc.
|
||||
* @param perMill the mille percent character
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
public void setPerMill(char perMill) {
|
||||
dfs.setPerMill(perMill);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the character used for percent sign. Different for Arabic, etc.
|
||||
* @return the percent character
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
public char getPercent() {
|
||||
return dfs.getPercent();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the character used for percent sign. Different for Arabic, etc.
|
||||
* @param percent the percent character
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
public void setPercent(char percent) {
|
||||
dfs.setPercent(percent);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the character used for a digit in a pattern.
|
||||
* @return the digit pattern character
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
public char getDigit() {
|
||||
return dfs.getDigit();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the character used for a digit in a pattern.
|
||||
* @param digit the digit pattern character
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
public void setDigit(char digit) {
|
||||
dfs.setDigit(digit);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the character used to separate positive and negative subpatterns
|
||||
* in a pattern.
|
||||
* @return the pattern separator character
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
public char getPatternSeparator() {
|
||||
return dfs.getPatternSeparator();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the character used to separate positive and negative subpatterns
|
||||
* in a pattern.
|
||||
* @param patternSeparator the pattern separator character
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
public void setPatternSeparator(char patternSeparator) {
|
||||
dfs.setPatternSeparator(patternSeparator);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the String used to represent infinity. Almost always left
|
||||
* unchanged.
|
||||
* @return the Infinity string
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
public String getInfinity() {
|
||||
return dfs.getInfinity();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the String used to represent infinity. Almost always left
|
||||
* unchanged.
|
||||
* @param infinity the Infinity String
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
public void setInfinity(String infinity) {
|
||||
dfs.setInfinity(infinity);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the String used to represent NaN. Almost always left
|
||||
* unchanged.
|
||||
* @return the NaN String
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
public String getNaN() {
|
||||
return dfs.getNaN();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the String used to represent NaN. Almost always left
|
||||
* unchanged.
|
||||
* @param NaN the NaN String
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
public void setNaN(String NaN) {
|
||||
dfs.setNaN(NaN);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the character used to represent minus sign. If no explicit
|
||||
* negative format is specified, one is formed by prefixing
|
||||
* minusSign to the positive format.
|
||||
* @return the minus sign character
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
public char getMinusSign() {
|
||||
return dfs.getMinusSign();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the character used to represent minus sign. If no explicit
|
||||
* negative format is specified, one is formed by prefixing
|
||||
* minusSign to the positive format.
|
||||
* @param minusSign the minus sign character
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
public void setMinusSign(char minusSign) {
|
||||
dfs.setMinusSign(minusSign);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the string denoting the local currency.
|
||||
* @return the local currency String.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
public String getCurrencySymbol() {
|
||||
return dfs.getCurrencySymbol();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the string denoting the local currency.
|
||||
* @param currency the local currency String.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
public void setCurrencySymbol(String currency) {
|
||||
dfs.setCurrencySymbol(currency);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the international string denoting the local currency.
|
||||
* @return the international string denoting the local currency
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
public String getInternationalCurrencySymbol() {
|
||||
return dfs.getInternationalCurrencySymbol();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the international string denoting the local currency.
|
||||
* @param currency the international string denoting the local currency.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
public void setInternationalCurrencySymbol(String currency) {
|
||||
dfs.setInternationalCurrencySymbol(currency);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the monetary decimal separator.
|
||||
* @return the monetary decimal separator character
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
public char getMonetaryDecimalSeparator() {
|
||||
return dfs.getMonetaryDecimalSeparator();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the monetary decimal separator.
|
||||
* @param sep the monetary decimal separator character
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
public void setMonetaryDecimalSeparator(char sep) {
|
||||
dfs.setMonetaryDecimalSeparator(sep);
|
||||
}
|
||||
|
||||
/**
|
||||
* Standard override.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
public Object clone() {
|
||||
return new DecimalFormatSymbols((java.text.DecimalFormatSymbols)dfs.clone());
|
||||
}
|
||||
|
||||
/**
|
||||
* Override equals.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
public boolean equals(Object obj) {
|
||||
try {
|
||||
return dfs.equals(((DecimalFormatSymbols)obj).dfs);
|
||||
}
|
||||
catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Override hashCode
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
public int hashCode() {
|
||||
return dfs.hashCode();
|
||||
}
|
||||
}
|
||||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 1996-2011, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
package com.ibm.icu.text;
|
||||
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Locale;
|
||||
|
||||
import com.ibm.icu.util.ULocale;
|
||||
|
||||
/**
|
||||
* This class represents the set of symbols (such as the decimal separator, the
|
||||
* grouping separator, and so on) needed by <code>DecimalFormat</code> to format
|
||||
* numbers. <code>DecimalFormat</code> creates for itself an instance of
|
||||
* <code>DecimalFormatSymbols</code> from its locale data. If you need to
|
||||
* change any of these symbols, you can get the
|
||||
* <code>DecimalFormatSymbols</code> object from your <code>DecimalFormat</code>
|
||||
* and modify it.
|
||||
*
|
||||
* <p><strong>This is an enhanced version of <code>DecimalFormatSymbols</code> that
|
||||
* is based on the standard version in the JDK. New or changed functionality
|
||||
* is labeled
|
||||
* <strong><font face=helvetica color=red>NEW</font></strong>.</strong>
|
||||
*
|
||||
* @see java.util.Locale
|
||||
* @see DecimalFormat
|
||||
* @author Mark Davis
|
||||
* @author Alan Liu
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
final public class DecimalFormatSymbols implements Cloneable, Serializable {
|
||||
|
||||
private static final long serialVersionUID =1L;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
public final java.text.DecimalFormatSymbols dfs;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
public DecimalFormatSymbols(java.text.DecimalFormatSymbols delegate) {
|
||||
this.dfs = delegate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a DecimalFormatSymbols object for the default locale.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
public DecimalFormatSymbols() {
|
||||
this(new java.text.DecimalFormatSymbols());
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a DecimalFormatSymbols object for the given locale.
|
||||
* @param locale the locale
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
public DecimalFormatSymbols(Locale locale) {
|
||||
this(new java.text.DecimalFormatSymbols(locale));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a DecimalFormatSymbols object for the given locale.
|
||||
* @param locale the locale
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
public DecimalFormatSymbols(ULocale locale) {
|
||||
this(new java.text.DecimalFormatSymbols(locale.toLocale()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the character used for zero. Different for Arabic, etc.
|
||||
* @return the character
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
public char getZeroDigit() {
|
||||
return dfs.getZeroDigit();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the character used for zero.
|
||||
* @param zeroDigit the zero character.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
public void setZeroDigit(char zeroDigit) {
|
||||
dfs.setZeroDigit(zeroDigit);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the character used for thousands separator. Different for French, etc.
|
||||
* @return the thousands character
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
public char getGroupingSeparator() {
|
||||
return dfs.getGroupingSeparator();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the character used for thousands separator. Different for French, etc.
|
||||
* @param groupingSeparator the thousands character
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
public void setGroupingSeparator(char groupingSeparator) {
|
||||
dfs.setGroupingSeparator(groupingSeparator);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the character used for decimal sign. Different for French, etc.
|
||||
* @return the decimal character
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
public char getDecimalSeparator() {
|
||||
return dfs.getDecimalSeparator();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the character used for decimal sign. Different for French, etc.
|
||||
* @param decimalSeparator the decimal character
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
public void setDecimalSeparator(char decimalSeparator) {
|
||||
dfs.setDecimalSeparator(decimalSeparator);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the character used for mille percent sign. Different for Arabic, etc.
|
||||
* @return the mille percent character
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
public char getPerMill() {
|
||||
return dfs.getPerMill();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the character used for mille percent sign. Different for Arabic, etc.
|
||||
* @param perMill the mille percent character
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
public void setPerMill(char perMill) {
|
||||
dfs.setPerMill(perMill);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the character used for percent sign. Different for Arabic, etc.
|
||||
* @return the percent character
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
public char getPercent() {
|
||||
return dfs.getPercent();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the character used for percent sign. Different for Arabic, etc.
|
||||
* @param percent the percent character
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
public void setPercent(char percent) {
|
||||
dfs.setPercent(percent);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the character used for a digit in a pattern.
|
||||
* @return the digit pattern character
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
public char getDigit() {
|
||||
return dfs.getDigit();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the character used for a digit in a pattern.
|
||||
* @param digit the digit pattern character
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
public void setDigit(char digit) {
|
||||
dfs.setDigit(digit);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the character used to separate positive and negative subpatterns
|
||||
* in a pattern.
|
||||
* @return the pattern separator character
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
public char getPatternSeparator() {
|
||||
return dfs.getPatternSeparator();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the character used to separate positive and negative subpatterns
|
||||
* in a pattern.
|
||||
* @param patternSeparator the pattern separator character
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
public void setPatternSeparator(char patternSeparator) {
|
||||
dfs.setPatternSeparator(patternSeparator);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the String used to represent infinity. Almost always left
|
||||
* unchanged.
|
||||
* @return the Infinity string
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
public String getInfinity() {
|
||||
return dfs.getInfinity();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the String used to represent infinity. Almost always left
|
||||
* unchanged.
|
||||
* @param infinity the Infinity String
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
public void setInfinity(String infinity) {
|
||||
dfs.setInfinity(infinity);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the String used to represent NaN. Almost always left
|
||||
* unchanged.
|
||||
* @return the NaN String
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
public String getNaN() {
|
||||
return dfs.getNaN();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the String used to represent NaN. Almost always left
|
||||
* unchanged.
|
||||
* @param NaN the NaN String
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
public void setNaN(String NaN) {
|
||||
dfs.setNaN(NaN);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the character used to represent minus sign. If no explicit
|
||||
* negative format is specified, one is formed by prefixing
|
||||
* minusSign to the positive format.
|
||||
* @return the minus sign character
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
public char getMinusSign() {
|
||||
return dfs.getMinusSign();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the character used to represent minus sign. If no explicit
|
||||
* negative format is specified, one is formed by prefixing
|
||||
* minusSign to the positive format.
|
||||
* @param minusSign the minus sign character
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
public void setMinusSign(char minusSign) {
|
||||
dfs.setMinusSign(minusSign);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the string denoting the local currency.
|
||||
* @return the local currency String.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
public String getCurrencySymbol() {
|
||||
return dfs.getCurrencySymbol();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the string denoting the local currency.
|
||||
* @param currency the local currency String.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
public void setCurrencySymbol(String currency) {
|
||||
dfs.setCurrencySymbol(currency);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the international string denoting the local currency.
|
||||
* @return the international string denoting the local currency
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
public String getInternationalCurrencySymbol() {
|
||||
return dfs.getInternationalCurrencySymbol();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the international string denoting the local currency.
|
||||
* @param currency the international string denoting the local currency.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
public void setInternationalCurrencySymbol(String currency) {
|
||||
dfs.setInternationalCurrencySymbol(currency);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the monetary decimal separator.
|
||||
* @return the monetary decimal separator character
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
public char getMonetaryDecimalSeparator() {
|
||||
return dfs.getMonetaryDecimalSeparator();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the monetary decimal separator.
|
||||
* @param sep the monetary decimal separator character
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
public void setMonetaryDecimalSeparator(char sep) {
|
||||
dfs.setMonetaryDecimalSeparator(sep);
|
||||
}
|
||||
|
||||
/**
|
||||
* Standard override.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
public Object clone() {
|
||||
return new DecimalFormatSymbols((java.text.DecimalFormatSymbols)dfs.clone());
|
||||
}
|
||||
|
||||
/**
|
||||
* Override equals.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
public boolean equals(Object obj) {
|
||||
try {
|
||||
return dfs.equals(((DecimalFormatSymbols)obj).dfs);
|
||||
}
|
||||
catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Override hashCode
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
public int hashCode() {
|
||||
return dfs.hashCode();
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -1,14 +1,14 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2011, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
package com.ibm.icu.text;
|
||||
|
||||
/*
|
||||
* Empty stub
|
||||
*/
|
||||
public class RawCollationKey {
|
||||
private RawCollationKey() {}
|
||||
}
|
||||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2011, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
package com.ibm.icu.text;
|
||||
|
||||
/*
|
||||
* Empty stub
|
||||
*/
|
||||
public class RawCollationKey {
|
||||
private RawCollationKey() {}
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,80 +1,80 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2003-2011, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
package com.ibm.icu.text;
|
||||
|
||||
import java.text.Format;
|
||||
|
||||
import com.ibm.icu.util.ULocale;
|
||||
|
||||
/**
|
||||
* An abstract class that extends {@link java.text.Format} to provide
|
||||
* additional ICU protocol, specifically, the <tt>getLocale()</tt>
|
||||
* API. All ICU format classes are subclasses of this class.
|
||||
*
|
||||
* @see com.ibm.icu.util.ULocale
|
||||
* @author weiv
|
||||
* @author Alan Liu
|
||||
* @draft ICU 2.8 (retain)
|
||||
* @provisional This API might change or be removed in a future release.
|
||||
*/
|
||||
public abstract class UFormat extends Format {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* @draft ICU 2.8 (retain)
|
||||
* @provisional This API might change or be removed in a future release.
|
||||
*/
|
||||
public UFormat() {}
|
||||
|
||||
/**
|
||||
* Return the locale that was used to create this object, or null.
|
||||
* This may may differ from the locale requested at the time of
|
||||
* this object's creation. For example, if an object is created
|
||||
* for locale <tt>en_US_CALIFORNIA</tt>, the actual data may be
|
||||
* drawn from <tt>en</tt> (the <i>actual</i> locale), and
|
||||
* <tt>en_US</tt> may be the most specific locale that exists (the
|
||||
* <i>valid</i> locale).
|
||||
*
|
||||
* <p>Note: This method will be implemented in ICU 3.0; ICU 2.8
|
||||
* contains a partial preview implementation. The <i>actual</i>
|
||||
* locale is returned correctly, but the <i>valid</i> locale is
|
||||
* not, in most cases.
|
||||
* @param type type of information requested, either {@link
|
||||
* com.ibm.icu.util.ULocale#VALID_LOCALE} or {@link
|
||||
* com.ibm.icu.util.ULocale#ACTUAL_LOCALE}.
|
||||
* @return the information specified by <i>type</i>, or null if
|
||||
* this object was not constructed from locale data.
|
||||
* @see com.ibm.icu.util.ULocale
|
||||
* @see com.ibm.icu.util.ULocale#VALID_LOCALE
|
||||
* @see com.ibm.icu.util.ULocale#ACTUAL_LOCALE
|
||||
* @draft ICU 2.8 (retain)
|
||||
* @provisional This API might change or be removed in a future release.
|
||||
*/
|
||||
public final ULocale getLocale(ULocale.Type type) {
|
||||
throw new UnsupportedOperationException("Method not supported by com.ibm.icu.base");
|
||||
}
|
||||
|
||||
/**
|
||||
* Set information about the locales that were used to create this
|
||||
* object. If the object was not constructed from locale data,
|
||||
* both arguments should be set to null. Otherwise, neither
|
||||
* should be null. The actual locale must be at the same level or
|
||||
* less specific than the valid locale. This method is intended
|
||||
* for use by factories or other entities that create objects of
|
||||
* this class.
|
||||
* @param valid the most specific locale containing any resource
|
||||
* data, or null
|
||||
* @param actual the locale containing data used to construct this
|
||||
* object, or null
|
||||
* @see com.ibm.icu.util.ULocale
|
||||
* @see com.ibm.icu.util.ULocale#VALID_LOCALE
|
||||
* @see com.ibm.icu.util.ULocale#ACTUAL_LOCALE
|
||||
*/
|
||||
final void setLocale(ULocale valid, ULocale actual) {
|
||||
throw new UnsupportedOperationException("Method not supported by com.ibm.icu.base");
|
||||
}
|
||||
}
|
||||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2003-2011, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
package com.ibm.icu.text;
|
||||
|
||||
import java.text.Format;
|
||||
|
||||
import com.ibm.icu.util.ULocale;
|
||||
|
||||
/**
|
||||
* An abstract class that extends {@link java.text.Format} to provide
|
||||
* additional ICU protocol, specifically, the <tt>getLocale()</tt>
|
||||
* API. All ICU format classes are subclasses of this class.
|
||||
*
|
||||
* @see com.ibm.icu.util.ULocale
|
||||
* @author weiv
|
||||
* @author Alan Liu
|
||||
* @draft ICU 2.8 (retain)
|
||||
* @provisional This API might change or be removed in a future release.
|
||||
*/
|
||||
public abstract class UFormat extends Format {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* @draft ICU 2.8 (retain)
|
||||
* @provisional This API might change or be removed in a future release.
|
||||
*/
|
||||
public UFormat() {}
|
||||
|
||||
/**
|
||||
* Return the locale that was used to create this object, or null.
|
||||
* This may may differ from the locale requested at the time of
|
||||
* this object's creation. For example, if an object is created
|
||||
* for locale <tt>en_US_CALIFORNIA</tt>, the actual data may be
|
||||
* drawn from <tt>en</tt> (the <i>actual</i> locale), and
|
||||
* <tt>en_US</tt> may be the most specific locale that exists (the
|
||||
* <i>valid</i> locale).
|
||||
*
|
||||
* <p>Note: This method will be implemented in ICU 3.0; ICU 2.8
|
||||
* contains a partial preview implementation. The <i>actual</i>
|
||||
* locale is returned correctly, but the <i>valid</i> locale is
|
||||
* not, in most cases.
|
||||
* @param type type of information requested, either {@link
|
||||
* com.ibm.icu.util.ULocale#VALID_LOCALE} or {@link
|
||||
* com.ibm.icu.util.ULocale#ACTUAL_LOCALE}.
|
||||
* @return the information specified by <i>type</i>, or null if
|
||||
* this object was not constructed from locale data.
|
||||
* @see com.ibm.icu.util.ULocale
|
||||
* @see com.ibm.icu.util.ULocale#VALID_LOCALE
|
||||
* @see com.ibm.icu.util.ULocale#ACTUAL_LOCALE
|
||||
* @draft ICU 2.8 (retain)
|
||||
* @provisional This API might change or be removed in a future release.
|
||||
*/
|
||||
public final ULocale getLocale(ULocale.Type type) {
|
||||
throw new UnsupportedOperationException("Method not supported by com.ibm.icu.base");
|
||||
}
|
||||
|
||||
/**
|
||||
* Set information about the locales that were used to create this
|
||||
* object. If the object was not constructed from locale data,
|
||||
* both arguments should be set to null. Otherwise, neither
|
||||
* should be null. The actual locale must be at the same level or
|
||||
* less specific than the valid locale. This method is intended
|
||||
* for use by factories or other entities that create objects of
|
||||
* this class.
|
||||
* @param valid the most specific locale containing any resource
|
||||
* data, or null
|
||||
* @param actual the locale containing data used to construct this
|
||||
* object, or null
|
||||
* @see com.ibm.icu.util.ULocale
|
||||
* @see com.ibm.icu.util.ULocale#VALID_LOCALE
|
||||
* @see com.ibm.icu.util.ULocale#ACTUAL_LOCALE
|
||||
*/
|
||||
final void setLocale(ULocale valid, ULocale actual) {
|
||||
throw new UnsupportedOperationException("Method not supported by com.ibm.icu.base");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2011, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
package com.ibm.icu.text;
|
||||
|
||||
/*
|
||||
* Empty stub
|
||||
*/
|
||||
public class UnicodeSet {
|
||||
private UnicodeSet() {}
|
||||
}
|
||||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2011, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
package com.ibm.icu.text;
|
||||
|
||||
/*
|
||||
* Empty stub
|
||||
*/
|
||||
public class UnicodeSet {
|
||||
private UnicodeSet() {}
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,420 +1,420 @@
|
|||
/**
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2001-2011, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
package com.ibm.icu.util;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.text.ParsePosition;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* A class encapsulating a currency, as defined by ISO 4217. A
|
||||
* <tt>Currency</tt> object can be created given a <tt>Locale</tt> or
|
||||
* given an ISO 4217 code. Once created, the <tt>Currency</tt> object
|
||||
* can return various data necessary to its proper display:
|
||||
*
|
||||
* <ul><li>A display symbol, for a specific locale
|
||||
* <li>The number of fraction digits to display
|
||||
* <li>A rounding increment
|
||||
* </ul>
|
||||
*
|
||||
* The <tt>DecimalFormat</tt> class uses these data to display
|
||||
* currencies.
|
||||
*
|
||||
* <p>Note: This class deliberately resembles
|
||||
* <tt>java.util.Currency</tt> but it has a completely independent
|
||||
* implementation, and adds features not present in the JDK.
|
||||
* @author Alan Liu
|
||||
* @stable ICU 2.2
|
||||
*/
|
||||
public class Currency implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
public final java.util.Currency currency;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
* @param delegate the NumberFormat to which to delegate
|
||||
*/
|
||||
public Currency(java.util.Currency delegate) {
|
||||
this.currency = delegate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Selector for getName() indicating a symbolic name for a
|
||||
* currency, such as "$" for USD.
|
||||
* @stable ICU 2.6
|
||||
*/
|
||||
public static final int SYMBOL_NAME = 0;
|
||||
|
||||
/**
|
||||
* Selector for ucurr_getName indicating the long name for a
|
||||
* currency, such as "US Dollar" for USD.
|
||||
* @stable ICU 2.6
|
||||
*/
|
||||
public static final int LONG_NAME = 1;
|
||||
|
||||
/**
|
||||
* Selector for getName() indicating the plural long name for a
|
||||
* currency, such as "US dollar" for USD in "1 US dollar",
|
||||
* and "US dollars" for USD in "2 US dollars".
|
||||
* @stable ICU 4.2
|
||||
*/
|
||||
public static final int PLURAL_LONG_NAME = 2;
|
||||
|
||||
/**
|
||||
* Returns a currency object for the default currency in the given
|
||||
* locale.
|
||||
* @param locale the locale
|
||||
* @return the currency object for this locale
|
||||
* @stable ICU 2.2
|
||||
*/
|
||||
public static Currency getInstance(Locale locale) {
|
||||
return new Currency(java.util.Currency.getInstance(locale));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a currency object for the default currency in the given
|
||||
* locale.
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
public static Currency getInstance(ULocale locale) {
|
||||
return new Currency(java.util.Currency.getInstance(locale.toLocale()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of Strings which contain the currency
|
||||
* identifiers that are valid for the given locale on the
|
||||
* given date. If there are no such identifiers, returns null.
|
||||
* Returned identifiers are in preference order.
|
||||
* @param loc the locale for which to retrieve currency codes.
|
||||
* @param d the date for which to retrieve currency codes for the given locale.
|
||||
* @return The array of ISO currency codes.
|
||||
* @stable ICU 4.0
|
||||
*/
|
||||
public static String[] getAvailableCurrencyCodes(ULocale loc, Date d) {
|
||||
throw new UnsupportedOperationException("Method not supproted by com.ibm.icu.base");
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a currency object given an ISO 4217 3-letter code.
|
||||
* @param theISOCode the iso code
|
||||
* @return the currency for this iso code
|
||||
* @throws NullPointerException if <code>theISOCode</code> is null.
|
||||
* @throws IllegalArgumentException if <code>theISOCode</code> is not a
|
||||
* 3-letter alpha code.
|
||||
* @stable ICU 2.2
|
||||
*/
|
||||
public static Currency getInstance(String theISOCode) {
|
||||
return new Currency(java.util.Currency.getInstance(theISOCode));
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a new currency for the provided locale. The returned object
|
||||
* is a key that can be used to unregister this currency object.
|
||||
* @param currency the currency to register
|
||||
* @param locale the ulocale under which to register the currency
|
||||
* @return a registry key that can be used to unregister this currency
|
||||
* @see #unregister
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
public static Object registerInstance(Currency currency, ULocale locale) {
|
||||
throw new UnsupportedOperationException("Method not supported by com.ibm.icu.base");
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregister the currency associated with this key (obtained from
|
||||
* registerInstance).
|
||||
* @param registryKey the registry key returned from registerInstance
|
||||
* @see #registerInstance
|
||||
* @stable ICU 2.6
|
||||
*/
|
||||
public static boolean unregister(Object registryKey) {
|
||||
throw new UnsupportedOperationException("Method not supported by com.ibm.icu.base");
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an array of the locales for which a currency
|
||||
* is defined.
|
||||
* @return an array of the available locales
|
||||
* @stable ICU 2.2
|
||||
*/
|
||||
public static Locale[] getAvailableLocales() {
|
||||
throw new UnsupportedOperationException("Method not supported by com.ibm.icu.base");
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an array of the ulocales for which a currency
|
||||
* is defined.
|
||||
* @return an array of the available ulocales
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
public static ULocale[] getAvailableULocales() {
|
||||
throw new UnsupportedOperationException("Method not supported by com.ibm.icu.base");
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a key and a locale, returns an array of values for the key for which data
|
||||
* exists. If commonlyUsed is true, these are the values that typically are used
|
||||
* with this locale, otherwise these are all values for which data exists.
|
||||
* This is a common service API.
|
||||
* <p>
|
||||
* The only supported key is "currency", other values return an empty array.
|
||||
* <p>
|
||||
* Currency information is based on the region of the locale. If the locale does not
|
||||
* indicate a region, {@link ULocale#addLikelySubtags(ULocale)} is used to infer a region,
|
||||
* except for the 'und' locale.
|
||||
* <p>
|
||||
* If commonlyUsed is true, only the currencies known to be in use as of the current date
|
||||
* are returned. When there are more than one, these are returned in preference order
|
||||
* (typically, this occurs when a country is transitioning to a new currency, and the
|
||||
* newer currency is preferred), see
|
||||
* <a href="http://unicode.org/reports/tr35/#Supplemental_Currency_Data">Unicode TR#35 Sec. C1</a>.
|
||||
* If commonlyUsed is false, all currencies ever used in any locale are returned, in no
|
||||
* particular order.
|
||||
*
|
||||
* @param key key whose values to look up. the only recognized key is "currency"
|
||||
* @param locale the locale
|
||||
* @param commonlyUsed if true, return only values that are currently used in the locale.
|
||||
* Otherwise returns all values.
|
||||
* @return an array of values for the given key and the locale. If there is no data, the
|
||||
* array will be empty.
|
||||
* @stable ICU 4.2
|
||||
*/
|
||||
public static final String[] getKeywordValuesForLocale(String key, ULocale locale,
|
||||
boolean commonlyUsed) {
|
||||
throw new UnsupportedOperationException("Method not supported by com.ibm.icu.base");
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a hashcode for this currency.
|
||||
* @stable ICU 2.2
|
||||
*/
|
||||
public int hashCode() {
|
||||
return currency.hashCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if rhs is a Currency instance,
|
||||
* is non-null, and has the same currency code.
|
||||
* @stable ICU 2.2
|
||||
*/
|
||||
public boolean equals(Object rhs) {
|
||||
try {
|
||||
return currency.equals(((Currency)rhs).currency);
|
||||
}
|
||||
catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the ISO 4217 3-letter code for this currency object.
|
||||
* @stable ICU 2.2
|
||||
*/
|
||||
public String getCurrencyCode() {
|
||||
return currency.getCurrencyCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience and compatibility override of getName that
|
||||
* requests the symbol name.
|
||||
* @see #getName
|
||||
* @stable ICU 3.4
|
||||
*/
|
||||
public String getSymbol() {
|
||||
return currency.getSymbol();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience and compatibility override of getName that
|
||||
* requests the symbol name.
|
||||
* @param loc the Locale for the symbol
|
||||
* @see #getName
|
||||
* @stable ICU 3.4
|
||||
*/
|
||||
public String getSymbol(Locale loc) {
|
||||
return currency.getSymbol(loc);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience and compatibility override of getName that
|
||||
* requests the symbol name.
|
||||
* @param uloc the ULocale for the symbol
|
||||
* @see #getName
|
||||
* @stable ICU 3.4
|
||||
*/
|
||||
public String getSymbol(ULocale uloc) {
|
||||
return currency.getSymbol(uloc.toLocale());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the display name for the given currency in the
|
||||
* given locale.
|
||||
* This is a convenient method for
|
||||
* getName(ULocale, int, boolean[]);
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
public String getName(Locale locale,
|
||||
int nameStyle,
|
||||
boolean[] isChoiceFormat) {
|
||||
throw new UnsupportedOperationException("Method not supported by com.ibm.icu.base");
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the display name for the given currency in the
|
||||
* given locale. For example, the display name for the USD
|
||||
* currency object in the en_US locale is "$".
|
||||
* @param locale locale in which to display currency
|
||||
* @param nameStyle selector for which kind of name to return.
|
||||
* The nameStyle should be either SYMBOL_NAME or
|
||||
* LONG_NAME. Otherwise, throw IllegalArgumentException.
|
||||
* @param isChoiceFormat fill-in; isChoiceFormat[0] is set to true
|
||||
* if the returned value is a ChoiceFormat pattern; otherwise it
|
||||
* is set to false
|
||||
* @return display string for this currency. If the resource data
|
||||
* contains no entry for this currency, then the ISO 4217 code is
|
||||
* returned. If isChoiceFormat[0] is true, then the result is a
|
||||
* ChoiceFormat pattern. Otherwise it is a static string. <b>Note:</b>
|
||||
* as of ICU 4.4, choice formats are not used, and the value returned
|
||||
* in isChoiceFormat is always false.
|
||||
* <p>
|
||||
* @throws IllegalArgumentException if the nameStyle is not SYMBOL_NAME
|
||||
* or LONG_NAME.
|
||||
* @see #getName(ULocale, int, String, boolean[])
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
public String getName(ULocale locale, int nameStyle, boolean[] isChoiceFormat) {
|
||||
throw new UnsupportedOperationException("Method not supported by com.ibm.icu.base");
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the display name for the given currency in the given locale.
|
||||
* This is a convenience overload of getName(ULocale, int, String, boolean[]);
|
||||
* @stable ICU 4.2
|
||||
*/
|
||||
public String getName(Locale locale, int nameStyle, String pluralCount,
|
||||
boolean[] isChoiceFormat) {
|
||||
throw new UnsupportedOperationException("Method not supported by com.ibm.icu.base");
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the display name for the given currency in the
|
||||
* given locale. For example, the SYMBOL_NAME for the USD
|
||||
* currency object in the en_US locale is "$".
|
||||
* The PLURAL_LONG_NAME for the USD currency object when the currency
|
||||
* amount is plural is "US dollars", such as in "3.00 US dollars";
|
||||
* while the PLURAL_LONG_NAME for the USD currency object when the currency
|
||||
* amount is singular is "US dollar", such as in "1.00 US dollar".
|
||||
* @param locale locale in which to display currency
|
||||
* @param nameStyle selector for which kind of name to return
|
||||
* @param pluralCount plural count string for this locale
|
||||
* @param isChoiceFormat fill-in; isChoiceFormat[0] is set to true
|
||||
* if the returned value is a ChoiceFormat pattern; otherwise it
|
||||
* is set to false
|
||||
* @return display string for this currency. If the resource data
|
||||
* contains no entry for this currency, then the ISO 4217 code is
|
||||
* returned. If isChoiceFormat[0] is true, then the result is a
|
||||
* ChoiceFormat pattern. Otherwise it is a static string. <b>Note:</b>
|
||||
* as of ICU 4.4, choice formats are not used, and the value returned
|
||||
* in isChoiceFormat is always false.
|
||||
* @throws IllegalArgumentException if the nameStyle is not SYMBOL_NAME,
|
||||
* LONG_NAME, or PLURAL_LONG_NAME.
|
||||
* @stable ICU 4.2
|
||||
*/
|
||||
public String getName(ULocale locale, int nameStyle, String pluralCount,
|
||||
boolean[] isChoiceFormat) {
|
||||
throw new UnsupportedOperationException("Method not supported by com.ibm.icu.base");
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempt to parse the given string as a currency, either as a
|
||||
* display name in the given locale, or as a 3-letter ISO 4217
|
||||
* code. If multiple display names match, then the longest one is
|
||||
* selected. If both a display name and a 3-letter ISO code
|
||||
* match, then the display name is preferred, unless it's length
|
||||
* is less than 3.
|
||||
*
|
||||
* @param locale the locale of the display names to match
|
||||
* @param text the text to parse
|
||||
* @param type parse against currency type: LONG_NAME only or not
|
||||
* @param pos input-output position; on input, the position within
|
||||
* text to match; must have 0 <= pos.getIndex() < text.length();
|
||||
* on output, the position after the last matched character. If
|
||||
* the parse fails, the position in unchanged upon output.
|
||||
* @return the ISO 4217 code, as a string, of the best match, or
|
||||
* null if there is no match
|
||||
*
|
||||
* @internal
|
||||
* @deprecated This API is ICU internal only.
|
||||
*/
|
||||
public static String parse(ULocale locale, String text, int type, ParsePosition pos) {
|
||||
throw new UnsupportedOperationException("Method not supported by com.ibm.icu.base");
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of the number of fraction digits that should
|
||||
* be displayed for this currency.
|
||||
* @return a non-negative number of fraction digits to be
|
||||
* displayed
|
||||
* @stable ICU 2.2
|
||||
*/
|
||||
public int getDefaultFractionDigits() {
|
||||
return currency.getDefaultFractionDigits();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the rounding increment for this currency, or 0.0 if no
|
||||
* rounding is done by this currency.
|
||||
* @return the non-negative rounding increment, or 0.0 if none
|
||||
* @stable ICU 2.2
|
||||
*/
|
||||
public double getRoundingIncrement() {
|
||||
throw new UnsupportedOperationException("Method not supported by com.ibm.icu.base");
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the ISO 4217 code for this currency.
|
||||
* @stable ICU 2.2
|
||||
*/
|
||||
public String toString() {
|
||||
return currency.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the locale that was used to create this object, or null.
|
||||
* This may may differ from the locale requested at the time of
|
||||
* this object's creation. For example, if an object is created
|
||||
* for locale <tt>en_US_CALIFORNIA</tt>, the actual data may be
|
||||
* drawn from <tt>en</tt> (the <i>actual</i> locale), and
|
||||
* <tt>en_US</tt> may be the most specific locale that exists (the
|
||||
* <i>valid</i> locale).
|
||||
*
|
||||
* <p>Note: This method will be obsoleted. The implementation is
|
||||
* no longer locale-specific and so there is no longer a valid or
|
||||
* actual locale associated with the Currency object. Until
|
||||
* it is removed, this method will return the root locale.
|
||||
* @param type type of information requested, either {@link
|
||||
* com.ibm.icu.util.ULocale#VALID_LOCALE} or {@link
|
||||
* com.ibm.icu.util.ULocale#ACTUAL_LOCALE}.
|
||||
* @return the information specified by <i>type</i>, or null if
|
||||
* this object was not constructed from locale data.
|
||||
* @see com.ibm.icu.util.ULocale
|
||||
* @see com.ibm.icu.util.ULocale#VALID_LOCALE
|
||||
* @see com.ibm.icu.util.ULocale#ACTUAL_LOCALE
|
||||
* @obsolete ICU 3.2 to be removed
|
||||
* @deprecated This API is obsolete.
|
||||
*/
|
||||
public final ULocale getLocale(ULocale.Type type) {
|
||||
throw new UnsupportedOperationException("Method not supported by com.ibm.icu.base");
|
||||
}
|
||||
}
|
||||
|
||||
//eof
|
||||
/**
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2001-2011, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
package com.ibm.icu.util;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.text.ParsePosition;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* A class encapsulating a currency, as defined by ISO 4217. A
|
||||
* <tt>Currency</tt> object can be created given a <tt>Locale</tt> or
|
||||
* given an ISO 4217 code. Once created, the <tt>Currency</tt> object
|
||||
* can return various data necessary to its proper display:
|
||||
*
|
||||
* <ul><li>A display symbol, for a specific locale
|
||||
* <li>The number of fraction digits to display
|
||||
* <li>A rounding increment
|
||||
* </ul>
|
||||
*
|
||||
* The <tt>DecimalFormat</tt> class uses these data to display
|
||||
* currencies.
|
||||
*
|
||||
* <p>Note: This class deliberately resembles
|
||||
* <tt>java.util.Currency</tt> but it has a completely independent
|
||||
* implementation, and adds features not present in the JDK.
|
||||
* @author Alan Liu
|
||||
* @stable ICU 2.2
|
||||
*/
|
||||
public class Currency implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
public final java.util.Currency currency;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
* @param delegate the NumberFormat to which to delegate
|
||||
*/
|
||||
public Currency(java.util.Currency delegate) {
|
||||
this.currency = delegate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Selector for getName() indicating a symbolic name for a
|
||||
* currency, such as "$" for USD.
|
||||
* @stable ICU 2.6
|
||||
*/
|
||||
public static final int SYMBOL_NAME = 0;
|
||||
|
||||
/**
|
||||
* Selector for ucurr_getName indicating the long name for a
|
||||
* currency, such as "US Dollar" for USD.
|
||||
* @stable ICU 2.6
|
||||
*/
|
||||
public static final int LONG_NAME = 1;
|
||||
|
||||
/**
|
||||
* Selector for getName() indicating the plural long name for a
|
||||
* currency, such as "US dollar" for USD in "1 US dollar",
|
||||
* and "US dollars" for USD in "2 US dollars".
|
||||
* @stable ICU 4.2
|
||||
*/
|
||||
public static final int PLURAL_LONG_NAME = 2;
|
||||
|
||||
/**
|
||||
* Returns a currency object for the default currency in the given
|
||||
* locale.
|
||||
* @param locale the locale
|
||||
* @return the currency object for this locale
|
||||
* @stable ICU 2.2
|
||||
*/
|
||||
public static Currency getInstance(Locale locale) {
|
||||
return new Currency(java.util.Currency.getInstance(locale));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a currency object for the default currency in the given
|
||||
* locale.
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
public static Currency getInstance(ULocale locale) {
|
||||
return new Currency(java.util.Currency.getInstance(locale.toLocale()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of Strings which contain the currency
|
||||
* identifiers that are valid for the given locale on the
|
||||
* given date. If there are no such identifiers, returns null.
|
||||
* Returned identifiers are in preference order.
|
||||
* @param loc the locale for which to retrieve currency codes.
|
||||
* @param d the date for which to retrieve currency codes for the given locale.
|
||||
* @return The array of ISO currency codes.
|
||||
* @stable ICU 4.0
|
||||
*/
|
||||
public static String[] getAvailableCurrencyCodes(ULocale loc, Date d) {
|
||||
throw new UnsupportedOperationException("Method not supproted by com.ibm.icu.base");
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a currency object given an ISO 4217 3-letter code.
|
||||
* @param theISOCode the iso code
|
||||
* @return the currency for this iso code
|
||||
* @throws NullPointerException if <code>theISOCode</code> is null.
|
||||
* @throws IllegalArgumentException if <code>theISOCode</code> is not a
|
||||
* 3-letter alpha code.
|
||||
* @stable ICU 2.2
|
||||
*/
|
||||
public static Currency getInstance(String theISOCode) {
|
||||
return new Currency(java.util.Currency.getInstance(theISOCode));
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a new currency for the provided locale. The returned object
|
||||
* is a key that can be used to unregister this currency object.
|
||||
* @param currency the currency to register
|
||||
* @param locale the ulocale under which to register the currency
|
||||
* @return a registry key that can be used to unregister this currency
|
||||
* @see #unregister
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
public static Object registerInstance(Currency currency, ULocale locale) {
|
||||
throw new UnsupportedOperationException("Method not supported by com.ibm.icu.base");
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregister the currency associated with this key (obtained from
|
||||
* registerInstance).
|
||||
* @param registryKey the registry key returned from registerInstance
|
||||
* @see #registerInstance
|
||||
* @stable ICU 2.6
|
||||
*/
|
||||
public static boolean unregister(Object registryKey) {
|
||||
throw new UnsupportedOperationException("Method not supported by com.ibm.icu.base");
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an array of the locales for which a currency
|
||||
* is defined.
|
||||
* @return an array of the available locales
|
||||
* @stable ICU 2.2
|
||||
*/
|
||||
public static Locale[] getAvailableLocales() {
|
||||
throw new UnsupportedOperationException("Method not supported by com.ibm.icu.base");
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an array of the ulocales for which a currency
|
||||
* is defined.
|
||||
* @return an array of the available ulocales
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
public static ULocale[] getAvailableULocales() {
|
||||
throw new UnsupportedOperationException("Method not supported by com.ibm.icu.base");
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a key and a locale, returns an array of values for the key for which data
|
||||
* exists. If commonlyUsed is true, these are the values that typically are used
|
||||
* with this locale, otherwise these are all values for which data exists.
|
||||
* This is a common service API.
|
||||
* <p>
|
||||
* The only supported key is "currency", other values return an empty array.
|
||||
* <p>
|
||||
* Currency information is based on the region of the locale. If the locale does not
|
||||
* indicate a region, {@link ULocale#addLikelySubtags(ULocale)} is used to infer a region,
|
||||
* except for the 'und' locale.
|
||||
* <p>
|
||||
* If commonlyUsed is true, only the currencies known to be in use as of the current date
|
||||
* are returned. When there are more than one, these are returned in preference order
|
||||
* (typically, this occurs when a country is transitioning to a new currency, and the
|
||||
* newer currency is preferred), see
|
||||
* <a href="http://unicode.org/reports/tr35/#Supplemental_Currency_Data">Unicode TR#35 Sec. C1</a>.
|
||||
* If commonlyUsed is false, all currencies ever used in any locale are returned, in no
|
||||
* particular order.
|
||||
*
|
||||
* @param key key whose values to look up. the only recognized key is "currency"
|
||||
* @param locale the locale
|
||||
* @param commonlyUsed if true, return only values that are currently used in the locale.
|
||||
* Otherwise returns all values.
|
||||
* @return an array of values for the given key and the locale. If there is no data, the
|
||||
* array will be empty.
|
||||
* @stable ICU 4.2
|
||||
*/
|
||||
public static final String[] getKeywordValuesForLocale(String key, ULocale locale,
|
||||
boolean commonlyUsed) {
|
||||
throw new UnsupportedOperationException("Method not supported by com.ibm.icu.base");
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a hashcode for this currency.
|
||||
* @stable ICU 2.2
|
||||
*/
|
||||
public int hashCode() {
|
||||
return currency.hashCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if rhs is a Currency instance,
|
||||
* is non-null, and has the same currency code.
|
||||
* @stable ICU 2.2
|
||||
*/
|
||||
public boolean equals(Object rhs) {
|
||||
try {
|
||||
return currency.equals(((Currency)rhs).currency);
|
||||
}
|
||||
catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the ISO 4217 3-letter code for this currency object.
|
||||
* @stable ICU 2.2
|
||||
*/
|
||||
public String getCurrencyCode() {
|
||||
return currency.getCurrencyCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience and compatibility override of getName that
|
||||
* requests the symbol name.
|
||||
* @see #getName
|
||||
* @stable ICU 3.4
|
||||
*/
|
||||
public String getSymbol() {
|
||||
return currency.getSymbol();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience and compatibility override of getName that
|
||||
* requests the symbol name.
|
||||
* @param loc the Locale for the symbol
|
||||
* @see #getName
|
||||
* @stable ICU 3.4
|
||||
*/
|
||||
public String getSymbol(Locale loc) {
|
||||
return currency.getSymbol(loc);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience and compatibility override of getName that
|
||||
* requests the symbol name.
|
||||
* @param uloc the ULocale for the symbol
|
||||
* @see #getName
|
||||
* @stable ICU 3.4
|
||||
*/
|
||||
public String getSymbol(ULocale uloc) {
|
||||
return currency.getSymbol(uloc.toLocale());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the display name for the given currency in the
|
||||
* given locale.
|
||||
* This is a convenient method for
|
||||
* getName(ULocale, int, boolean[]);
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
public String getName(Locale locale,
|
||||
int nameStyle,
|
||||
boolean[] isChoiceFormat) {
|
||||
throw new UnsupportedOperationException("Method not supported by com.ibm.icu.base");
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the display name for the given currency in the
|
||||
* given locale. For example, the display name for the USD
|
||||
* currency object in the en_US locale is "$".
|
||||
* @param locale locale in which to display currency
|
||||
* @param nameStyle selector for which kind of name to return.
|
||||
* The nameStyle should be either SYMBOL_NAME or
|
||||
* LONG_NAME. Otherwise, throw IllegalArgumentException.
|
||||
* @param isChoiceFormat fill-in; isChoiceFormat[0] is set to true
|
||||
* if the returned value is a ChoiceFormat pattern; otherwise it
|
||||
* is set to false
|
||||
* @return display string for this currency. If the resource data
|
||||
* contains no entry for this currency, then the ISO 4217 code is
|
||||
* returned. If isChoiceFormat[0] is true, then the result is a
|
||||
* ChoiceFormat pattern. Otherwise it is a static string. <b>Note:</b>
|
||||
* as of ICU 4.4, choice formats are not used, and the value returned
|
||||
* in isChoiceFormat is always false.
|
||||
* <p>
|
||||
* @throws IllegalArgumentException if the nameStyle is not SYMBOL_NAME
|
||||
* or LONG_NAME.
|
||||
* @see #getName(ULocale, int, String, boolean[])
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
public String getName(ULocale locale, int nameStyle, boolean[] isChoiceFormat) {
|
||||
throw new UnsupportedOperationException("Method not supported by com.ibm.icu.base");
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the display name for the given currency in the given locale.
|
||||
* This is a convenience overload of getName(ULocale, int, String, boolean[]);
|
||||
* @stable ICU 4.2
|
||||
*/
|
||||
public String getName(Locale locale, int nameStyle, String pluralCount,
|
||||
boolean[] isChoiceFormat) {
|
||||
throw new UnsupportedOperationException("Method not supported by com.ibm.icu.base");
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the display name for the given currency in the
|
||||
* given locale. For example, the SYMBOL_NAME for the USD
|
||||
* currency object in the en_US locale is "$".
|
||||
* The PLURAL_LONG_NAME for the USD currency object when the currency
|
||||
* amount is plural is "US dollars", such as in "3.00 US dollars";
|
||||
* while the PLURAL_LONG_NAME for the USD currency object when the currency
|
||||
* amount is singular is "US dollar", such as in "1.00 US dollar".
|
||||
* @param locale locale in which to display currency
|
||||
* @param nameStyle selector for which kind of name to return
|
||||
* @param pluralCount plural count string for this locale
|
||||
* @param isChoiceFormat fill-in; isChoiceFormat[0] is set to true
|
||||
* if the returned value is a ChoiceFormat pattern; otherwise it
|
||||
* is set to false
|
||||
* @return display string for this currency. If the resource data
|
||||
* contains no entry for this currency, then the ISO 4217 code is
|
||||
* returned. If isChoiceFormat[0] is true, then the result is a
|
||||
* ChoiceFormat pattern. Otherwise it is a static string. <b>Note:</b>
|
||||
* as of ICU 4.4, choice formats are not used, and the value returned
|
||||
* in isChoiceFormat is always false.
|
||||
* @throws IllegalArgumentException if the nameStyle is not SYMBOL_NAME,
|
||||
* LONG_NAME, or PLURAL_LONG_NAME.
|
||||
* @stable ICU 4.2
|
||||
*/
|
||||
public String getName(ULocale locale, int nameStyle, String pluralCount,
|
||||
boolean[] isChoiceFormat) {
|
||||
throw new UnsupportedOperationException("Method not supported by com.ibm.icu.base");
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempt to parse the given string as a currency, either as a
|
||||
* display name in the given locale, or as a 3-letter ISO 4217
|
||||
* code. If multiple display names match, then the longest one is
|
||||
* selected. If both a display name and a 3-letter ISO code
|
||||
* match, then the display name is preferred, unless it's length
|
||||
* is less than 3.
|
||||
*
|
||||
* @param locale the locale of the display names to match
|
||||
* @param text the text to parse
|
||||
* @param type parse against currency type: LONG_NAME only or not
|
||||
* @param pos input-output position; on input, the position within
|
||||
* text to match; must have 0 <= pos.getIndex() < text.length();
|
||||
* on output, the position after the last matched character. If
|
||||
* the parse fails, the position in unchanged upon output.
|
||||
* @return the ISO 4217 code, as a string, of the best match, or
|
||||
* null if there is no match
|
||||
*
|
||||
* @internal
|
||||
* @deprecated This API is ICU internal only.
|
||||
*/
|
||||
public static String parse(ULocale locale, String text, int type, ParsePosition pos) {
|
||||
throw new UnsupportedOperationException("Method not supported by com.ibm.icu.base");
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of the number of fraction digits that should
|
||||
* be displayed for this currency.
|
||||
* @return a non-negative number of fraction digits to be
|
||||
* displayed
|
||||
* @stable ICU 2.2
|
||||
*/
|
||||
public int getDefaultFractionDigits() {
|
||||
return currency.getDefaultFractionDigits();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the rounding increment for this currency, or 0.0 if no
|
||||
* rounding is done by this currency.
|
||||
* @return the non-negative rounding increment, or 0.0 if none
|
||||
* @stable ICU 2.2
|
||||
*/
|
||||
public double getRoundingIncrement() {
|
||||
throw new UnsupportedOperationException("Method not supported by com.ibm.icu.base");
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the ISO 4217 code for this currency.
|
||||
* @stable ICU 2.2
|
||||
*/
|
||||
public String toString() {
|
||||
return currency.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the locale that was used to create this object, or null.
|
||||
* This may may differ from the locale requested at the time of
|
||||
* this object's creation. For example, if an object is created
|
||||
* for locale <tt>en_US_CALIFORNIA</tt>, the actual data may be
|
||||
* drawn from <tt>en</tt> (the <i>actual</i> locale), and
|
||||
* <tt>en_US</tt> may be the most specific locale that exists (the
|
||||
* <i>valid</i> locale).
|
||||
*
|
||||
* <p>Note: This method will be obsoleted. The implementation is
|
||||
* no longer locale-specific and so there is no longer a valid or
|
||||
* actual locale associated with the Currency object. Until
|
||||
* it is removed, this method will return the root locale.
|
||||
* @param type type of information requested, either {@link
|
||||
* com.ibm.icu.util.ULocale#VALID_LOCALE} or {@link
|
||||
* com.ibm.icu.util.ULocale#ACTUAL_LOCALE}.
|
||||
* @return the information specified by <i>type</i>, or null if
|
||||
* this object was not constructed from locale data.
|
||||
* @see com.ibm.icu.util.ULocale
|
||||
* @see com.ibm.icu.util.ULocale#VALID_LOCALE
|
||||
* @see com.ibm.icu.util.ULocale#ACTUAL_LOCALE
|
||||
* @obsolete ICU 3.2 to be removed
|
||||
* @deprecated This API is obsolete.
|
||||
*/
|
||||
public final ULocale getLocale(ULocale.Type type) {
|
||||
throw new UnsupportedOperationException("Method not supported by com.ibm.icu.base");
|
||||
}
|
||||
}
|
||||
|
||||
//eof
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2011, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
package com.ibm.icu.util;
|
||||
|
||||
/*
|
||||
* Empty stub
|
||||
*/
|
||||
public class CurrencyAmount {
|
||||
private CurrencyAmount() {}
|
||||
}
|
||||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2011, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
package com.ibm.icu.util;
|
||||
|
||||
/*
|
||||
* Empty stub
|
||||
*/
|
||||
public class CurrencyAmount {
|
||||
private CurrencyAmount() {}
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -1,14 +1,14 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2011, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
package com.ibm.icu.util;
|
||||
|
||||
/*
|
||||
* Empty stub
|
||||
*/
|
||||
public final class VersionInfo {
|
||||
private VersionInfo() {}
|
||||
}
|
||||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2011, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
package com.ibm.icu.util;
|
||||
|
||||
/*
|
||||
* Empty stub
|
||||
*/
|
||||
public final class VersionInfo {
|
||||
private VersionInfo() {}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue