From 7dcc85ac131ca20a7d0563814df59942f8363a2c Mon Sep 17 00:00:00 2001
From: Andy Heninger
Date: Thu, 3 Mar 2011 18:45:22 +0000
Subject: [PATCH] ICU-8400 fixes for DOS line endings and missing svn
properties. (BRS)
X-SVN-Rev: 29528
---
.gitattributes | 53 -
icu4j/eclipse-build/eclipse_mod_classes.txt | 10 +-
.../eclipse_mod_test_classes.txt | 14 +-
.../com.ibm.icu.base/feature.xml | 66 +-
.../com/ibm/icu/tests/BreakIteratorTest.java | 718 +-
.../src/com/ibm/icu/tests/CalendarTest.java | 1130 +--
.../com/ibm/icu/tests/CollationKeyTest.java | 204 +-
.../src/com/ibm/icu/tests/CollatorTest.java | 410 +-
.../ibm/icu/tests/DateFormatSymbolsTest.java | 514 +-
.../src/com/ibm/icu/tests/DateFormatTest.java | 908 +-
.../icu/tests/DecimalFormatSymbolsTest.java | 688 +-
.../com/ibm/icu/tests/DecimalFormatTest.java | 484 +-
.../src/com/ibm/icu/tests/ICUTestCase.java | 572 +-
.../com/ibm/icu/tests/MessageFormatTest.java | 614 +-
.../com/ibm/icu/tests/NumberFormatTest.java | 894 +-
.../ibm/icu/tests/SimpleDateFormatTest.java | 404 +-
.../src/com/ibm/icu/tests/TimeZoneTest.java | 470 +-
.../src/com/ibm/icu/tests/ULocaleTest.java | 1496 ++--
.../src/com/ibm/icu/impl/ICUCache.java | 42 +-
.../src/com/ibm/icu/impl/LocaleIDParser.java | 1480 ++--
.../src/com/ibm/icu/impl/LocaleIDs.java | 1072 +--
.../src/com/ibm/icu/impl/LocaleUtility.java | 264 +-
.../src/com/ibm/icu/impl/SimpleCache.java | 146 +-
.../com/ibm/icu/impl/locale/AsciiUtil.java | 360 +-
.../src/com/ibm/icu/math/BigDecimal.java | 7760 ++++++++---------
.../src/com/ibm/icu/math/MathContext.java | 1202 +--
.../src/com/ibm/icu/text/Bidi.java | 5172 +++++------
.../src/com/ibm/icu/text/BidiClassifier.java | 28 +-
.../src/com/ibm/icu/text/BidiRun.java | 28 +-
.../src/com/ibm/icu/text/BreakIterator.java | 1666 ++--
.../src/com/ibm/icu/text/CollationKey.java | 830 +-
.../src/com/ibm/icu/text/Collator.java | 1864 ++--
.../com/ibm/icu/text/CurrencyPluralInfo.java | 28 +-
.../src/com/ibm/icu/text/DateFormat.java | 3898 ++++-----
.../com/ibm/icu/text/DateFormatSymbols.java | 1680 ++--
.../src/com/ibm/icu/text/DecimalFormat.java | 3524 ++++----
.../ibm/icu/text/DecimalFormatSymbols.java | 700 +-
.../src/com/ibm/icu/text/MessageFormat.java | 2830 +++---
.../src/com/ibm/icu/text/NumberFormat.java | 2624 +++---
.../src/com/ibm/icu/text/RawCollationKey.java | 28 +-
.../com/ibm/icu/text/SimpleDateFormat.java | 1028 +--
.../src/com/ibm/icu/text/UFormat.java | 160 +-
.../src/com/ibm/icu/text/UnicodeSet.java | 28 +-
.../src/com/ibm/icu/util/Calendar.java | 4690 +++++-----
.../src/com/ibm/icu/util/Currency.java | 840 +-
.../src/com/ibm/icu/util/CurrencyAmount.java | 28 +-
.../src/com/ibm/icu/util/TimeZone.java | 1420 +--
.../src/com/ibm/icu/util/ULocale.java | 4986 +++++------
.../src/com/ibm/icu/util/VersionInfo.java | 28 +-
49 files changed, 30015 insertions(+), 30068 deletions(-)
diff --git a/.gitattributes b/.gitattributes
index 600c859b712..fbc0dcb59c4 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -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
diff --git a/icu4j/eclipse-build/eclipse_mod_classes.txt b/icu4j/eclipse-build/eclipse_mod_classes.txt
index dc2f9c68ef4..d279e2e7897 100644
--- a/icu4j/eclipse-build/eclipse_mod_classes.txt
+++ b/icu4j/eclipse-build/eclipse_mod_classes.txt
@@ -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
diff --git a/icu4j/eclipse-build/eclipse_mod_test_classes.txt b/icu4j/eclipse-build/eclipse_mod_test_classes.txt
index 20b52928f3d..7059aeb914a 100644
--- a/icu4j/eclipse-build/eclipse_mod_test_classes.txt
+++ b/icu4j/eclipse-build/eclipse_mod_test_classes.txt
@@ -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
diff --git a/icu4j/eclipse-build/features.template/com.ibm.icu.base/feature.xml b/icu4j/eclipse-build/features.template/com.ibm.icu.base/feature.xml
index 367bcd27097..5102e29769f 100644
--- a/icu4j/eclipse-build/features.template/com.ibm.icu.base/feature.xml
+++ b/icu4j/eclipse-build/features.template/com.ibm.icu.base/feature.xml
@@ -1,33 +1,33 @@
-
-
-
-
- [Enter Feature Description here.]
-
-
-
- [Enter Copyright Description here.]
-
-
-
- [Enter License Description here.]
-
-
-
-
-
-
-
+
+
+
+
+ [Enter Feature Description here.]
+
+
+
+ [Enter Copyright Description here.]
+
+
+
+ [Enter License Description here.]
+
+
+
+
+
+
+
diff --git a/icu4j/eclipse-build/plugins.template/com.ibm.icu.base.tests/src/com/ibm/icu/tests/BreakIteratorTest.java b/icu4j/eclipse-build/plugins.template/com.ibm.icu.base.tests/src/com/ibm/icu/tests/BreakIteratorTest.java
index 6b26f3b2f30..3db154648c4 100644
--- a/icu4j/eclipse-build/plugins.template/com.ibm.icu.base.tests/src/com/ibm/icu/tests/BreakIteratorTest.java
+++ b/icu4j/eclipse-build/plugins.template/com.ibm.icu.base.tests/src/com/ibm/icu/tests/BreakIteratorTest.java
@@ -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
+ }
+}
diff --git a/icu4j/eclipse-build/plugins.template/com.ibm.icu.base.tests/src/com/ibm/icu/tests/CalendarTest.java b/icu4j/eclipse-build/plugins.template/com.ibm.icu.base.tests/src/com/ibm/icu/tests/CalendarTest.java
index 69195a2a4e9..3237a940363 100644
--- a/icu4j/eclipse-build/plugins.template/com.ibm.icu.base.tests/src/com/ibm/icu/tests/CalendarTest.java
+++ b/icu4j/eclipse-build/plugins.template/com.ibm.icu.base.tests/src/com/ibm/icu/tests/CalendarTest.java
@@ -1,565 +1,565 @@
-/*
- *******************************************************************************
- * 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.text.DateFormat;
-import com.ibm.icu.util.Calendar;
-import com.ibm.icu.util.TimeZone;
-import com.ibm.icu.util.ULocale;
-
-public class CalendarTest extends ICUTestCase {
-
- /*
- * Test method for 'com.ibm.icu.util.Calendar.hashCode()'
- */
- public void testHashCode() {
- Calendar cal1 = Calendar.getInstance();
- Calendar cal2 = Calendar.getInstance();
- Calendar cal3 = Calendar.getInstance();
-
- long t = System.currentTimeMillis();
- cal1.setTimeInMillis(t);
- cal2.setTimeInMillis(t);
- cal3.setTimeInMillis(t);
-
- cal3.setMinimalDaysInFirstWeek(cal3.getMinimalDaysInFirstWeek()+1);
- testEHCS(cal1, cal2, cal3);
- }
-
- /*
- * Test method for 'com.ibm.icu.util.Calendar.Calendar(Calendar)'
- */
- public void testCalendar() {
- // tested implicitly everywhere
- }
-
- /*
- * Test method for 'com.ibm.icu.util.Calendar.getInstance()'
- */
- public void testGetInstance() {
- // tested by testEHCS
- }
-
- /*
- * Test method for 'com.ibm.icu.util.Calendar.getInstance(TimeZone)'
- */
- public void testGetInstanceTimeZone() {
- TimeZone tz = TimeZone.getTimeZone("America/Los_Angeles");
- Calendar cal = Calendar.getInstance(tz);
- assertNotNull(cal);
- assertNotNull(cal.getTime());
- assertEquals(tz, cal.getTimeZone());
- }
-
- /*
- * Test method for 'com.ibm.icu.util.Calendar.getInstance(Locale)'
- */
- public void testGetInstanceLocale() {
- Calendar cal = Calendar.getInstance(Locale.US);
- assertNotNull(cal);
- assertNotNull(cal.getTime());
- }
-
- /*
- * Test method for 'com.ibm.icu.util.Calendar.getInstance(ULocale)'
- */
- public void testGetInstanceULocale() {
- Calendar cal = Calendar.getInstance(ULocale.US);
- assertNotNull(cal);
- assertNotNull(cal.getTime());
- }
-
- /*
- * Test method for 'com.ibm.icu.util.Calendar.getInstance(TimeZone, Locale)'
- */
- public void testGetInstanceTimeZoneLocale() {
- TimeZone tz = TimeZone.getTimeZone("America/New_York");
- Calendar cal = Calendar.getInstance(tz, Locale.US);
- assertNotNull(cal);
- assertNotNull(cal.getTime());
- }
-
- /*
- * Test method for 'com.ibm.icu.util.Calendar.getInstance(TimeZone, ULocale)'
- */
- public void testGetInstanceTimeZoneULocale() {
- TimeZone tz = TimeZone.getTimeZone("America/New_York");
- Calendar cal = Calendar.getInstance(tz, ULocale.US);
- assertNotNull(cal);
- assertNotNull(cal.getTime());
- }
-
- /*
- * Test method for 'com.ibm.icu.util.Calendar.getAvailableLocales()'
- */
- public void testGetAvailableLocales() {
- assertNotNull(Calendar.getAvailableLocales());
- }
-
- /*
- * Test method for 'com.ibm.icu.util.Calendar.getAvailableULocales()'
- */
- public void testGetAvailableULocales() {
- assertNotNull(Calendar.getAvailableULocales());
- }
-
- /*
- * Test method for 'com.ibm.icu.util.Calendar.getTime()'
- */
- public void testGetTime() {
- Calendar cal = Calendar.getInstance();
- assertNotNull(cal.getTime());
- }
-
- /*
- * Test method for 'com.ibm.icu.util.Calendar.setTime(Date)'
- */
- public void testSetTime() {
- Calendar cal = Calendar.getInstance();
- cal.clear();
- cal.set(2006, 0, 20, 9, 30, 0);
- Date date = cal.getTime();
- cal = Calendar.getInstance();
- cal.setTime(date);
- assertEquals(date, cal.getTime());
- }
-
- /*
- * Test method for 'com.ibm.icu.util.Calendar.getTimeInMillis()'
- */
- public void testGetTimeInMillis() {
- Calendar cal = Calendar.getInstance();
- assertTrue(0 != cal.getTimeInMillis());
- }
-
- /*
- * Test method for 'com.ibm.icu.util.Calendar.setTimeInMillis(long)'
- */
- public void testSetTimeInMillis() {
- Calendar cal = Calendar.getInstance();
- cal.clear();
- cal.set(2006, 0, 20, 9, 30, 0);
- long millis = cal.getTimeInMillis();
- Date date = cal.getTime();
-
- cal = Calendar.getInstance();
- cal.setTimeInMillis(millis);
-
- assertEquals(date, cal.getTime());
- }
-
- /*
- * Test method for 'com.ibm.icu.util.Calendar.get(int)'
- */
- public void testGet() {
- Calendar cal = Calendar.getInstance();
- cal.clear();
- cal.set(2006, 0, 20, 9, 30, 0);
- assertEquals(0, cal.get(Calendar.MONTH));
- assertEquals(20, cal.get(Calendar.DAY_OF_MONTH));
- assertEquals(30, cal.get(Calendar.MINUTE));
- }
-
- /*
- * Test method for 'com.ibm.icu.util.Calendar.set(int, int)'
- */
- public void testSetIntInt() {
- Calendar cal = Calendar.getInstance();
- cal.set(Calendar.YEAR, 1977);
- assertEquals(1977, cal.get(Calendar.YEAR));
- }
-
- /*
- * Test method for 'com.ibm.icu.util.Calendar.set(int, int, int)'
- */
- public void testSetIntIntInt() {
- Calendar cal = Calendar.getInstance();
- cal.set(1997, 9, 15);
- assertEquals(15, cal.get(Calendar.DATE));
- }
-
- /*
- * Test method for 'com.ibm.icu.util.Calendar.set(int, int, int, int, int)'
- */
- public void testSetIntIntIntIntInt() {
- Calendar cal = Calendar.getInstance();
- cal.set(1997, 9, 15, 14, 25);
- assertEquals(25, cal.get(Calendar.MINUTE));
- }
-
- /*
- * Test method for 'com.ibm.icu.util.Calendar.set(int, int, int, int, int, int)'
- */
- public void testSetIntIntIntIntIntInt() {
- Calendar cal = Calendar.getInstance();
- cal.set(1997, 9, 15, 14, 25, 51);
- assertEquals(51, cal.get(Calendar.SECOND));
- }
-
- /*
- * Test method for 'com.ibm.icu.util.Calendar.clear()'
- */
- public void testClear() {
- Calendar cal = Calendar.getInstance();
- cal.set(1997, 9, 15, 14, 25, 51);
- cal.clear();
- assertEquals(0, cal.get(Calendar.MONTH));
- }
-
- /*
- * Test method for 'com.ibm.icu.util.Calendar.clear(int)'
- */
- public void testClearInt() {
- Calendar cal = Calendar.getInstance();
- cal.set(1997, 9, 15, 14, 25, 51);
- assertTrue(cal.isSet(Calendar.DAY_OF_MONTH));
- cal.clear(Calendar.DAY_OF_MONTH);
- assertFalse(cal.isSet(Calendar.DAY_OF_MONTH));
- }
-
- /*
- * Test method for 'com.ibm.icu.util.Calendar.isSet(int)'
- */
- public void testIsSet() {
- // see testClearInt
- }
-
- /*
- * Test method for 'com.ibm.icu.util.Calendar.equals(Object)'
- */
- public void testEqualsObject() {
- // tested by testHashCode
- }
-
- /*
- * Test method for 'com.ibm.icu.util.Calendar.isEquivalentTo(Calendar)'
- */
- public void testIsEquivalentTo() {
- Calendar cal = Calendar.getInstance();
- Calendar cal2 = Calendar.getInstance();
- cal2.set(1994, 6, 21, 8, 7);
- assertTrue(cal.isEquivalentTo(cal2));
- cal.setTimeZone(TimeZone.getTimeZone("CST"));
- cal2.setTimeZone(TimeZone.getTimeZone("PDT"));
- assertFalse(cal.isEquivalentTo(cal2));
- }
-
- /*
- * Test method for 'com.ibm.icu.util.Calendar.before(Object)'
- */
- public void testBefore() {
- Calendar cal = Calendar.getInstance();
- cal.set(Calendar.YEAR, 1990);
- assertTrue(cal.before(new Date()));
- assertTrue(cal.before(Calendar.getInstance()));
- }
-
- /*
- * Test method for 'com.ibm.icu.util.Calendar.after(Object)'
- */
- public void testAfter() {
- Calendar cal = Calendar.getInstance();
- cal.set(Calendar.YEAR, 3058);
- assertTrue(cal.after(new Date()));
- assertTrue(cal.after(Calendar.getInstance()));
- }
-
- /*
- * Test method for 'com.ibm.icu.util.Calendar.getActualMaximum(int)'
- */
- public void testGetActualMaximum() {
- Calendar cal = Calendar.getInstance(Locale.US);
- assertEquals(11, cal.getActualMaximum(Calendar.MONTH));
- }
-
- /*
- * Test method for 'com.ibm.icu.util.Calendar.getActualMinimum(int)'
- */
- public void testGetActualMinimum() {
- Calendar cal = Calendar.getInstance(Locale.US);
- assertEquals(0, cal.getActualMinimum(Calendar.MONTH));
- }
-
- /*
- * Test method for 'com.ibm.icu.util.Calendar.roll(int, boolean)'
- */
- public void testRollIntBoolean() {
- Calendar cal = Calendar.getInstance(Locale.US);
- cal.set(1997, 1, 27);
- cal.roll(Calendar.DATE, true);
- assertEquals(28, cal.get(Calendar.DATE));
- }
-
- /*
- * Test method for 'com.ibm.icu.util.Calendar.roll(int, int)'
- */
- public void testRollIntInt() {
- Calendar cal = Calendar.getInstance(Locale.US);
- cal.set(1997, 1, 27);
- cal.roll(Calendar.DATE, 3);
- assertEquals(2, cal.get(Calendar.DATE));
- }
-
- /*
- * Test method for 'com.ibm.icu.util.Calendar.add(int, int)'
- */
- public void testAdd() {
- Calendar cal = Calendar.getInstance(Locale.US);
- cal.set(1997, 1, 27);
- cal.add(Calendar.DATE, 3);
- assertEquals(2, cal.get(Calendar.DATE));
- assertEquals(2, cal.get(Calendar.MONTH));
- }
-
- /*
- * Test method for 'com.ibm.icu.util.Calendar.getDisplayName(Locale)'
- */
- public void testGetDisplayNameLocale() {
- Calendar cal = Calendar.getInstance();
- assertEquals("Gregorian Calendar", cal.getDisplayName(Locale.US));
- }
-
- /*
- * Test method for 'com.ibm.icu.util.Calendar.getDisplayName(ULocale)'
- */
- public void testGetDisplayNameULocale() {
- Calendar cal = Calendar.getInstance();
- assertEquals("Gregorian Calendar", cal.getDisplayName(ULocale.US));
- }
-
- /*
- * Test method for 'com.ibm.icu.util.Calendar.compareTo(Calendar)'
- */
- public void testCompareToCalendar() {
- Calendar cal = Calendar.getInstance();
- cal.set(Calendar.YEAR, 1990);
- assertTrue(0 > cal.compareTo(Calendar.getInstance()));
- }
-
- /*
- * Test method for 'com.ibm.icu.util.Calendar.compareTo(Object)'
- */
- public void testCompareToObject() {
- Calendar cal = Calendar.getInstance();
- cal.set(Calendar.YEAR, 1990);
- assertTrue(0 > cal.compareTo(Calendar.getInstance()));
- }
-
- /*
- * Test method for 'com.ibm.icu.util.Calendar.getDateTimeFormat(int, int, Locale)'
- */
- public void testGetDateTimeFormatIntIntLocale() {
- Calendar cal = Calendar.getInstance();
- cal.set(1990, 8, 16, 20, 3);
- DateFormat df = cal.getDateTimeFormat(DateFormat.LONG, DateFormat.SHORT, Locale.US);
- assertEquals("September 16, 1990 8:03 PM", df.format(cal));
- }
-
- /*
- * Test method for 'com.ibm.icu.util.Calendar.getDateTimeFormat(int, int, ULocale)'
- */
- public void testGetDateTimeFormatIntIntULocale() {
- Calendar cal = Calendar.getInstance();
- cal.set(1990, 8, 16, 20, 3);
- DateFormat df = cal.getDateTimeFormat(DateFormat.LONG, DateFormat.SHORT, ULocale.US);
- assertEquals("September 16, 1990 8:03 PM", df.format(cal));
- }
-
- /*
- * Test method for 'com.ibm.icu.util.Calendar.fieldDifference(Date, int)'
- */
- public void testFieldDifference() {
- Calendar cal = Calendar.getInstance();
- cal.set(Calendar.DAY_OF_MONTH, 0);
- Date date = cal.getTime();
- cal.add(Calendar.DAY_OF_MONTH, 5);
- assertEquals(-5, cal.fieldDifference(date, Calendar.DAY_OF_MONTH));
- }
-
- /*
- * Test method for 'com.ibm.icu.util.Calendar.getTimeZone()'
- */
- public void testGetTimeZone() {
- Calendar cal = Calendar.getInstance();
- assertNotNull(cal.getTimeZone());
- }
-
- /*
- * Test method for 'com.ibm.icu.util.Calendar.setTimeZone(TimeZone)'
- */
- public void testSetTimeZone() {
- Calendar cal = Calendar.getInstance();
- TimeZone value1 = cal.getTimeZone();
- String tzn = "PDT".equals(value1.getID()) ? "CST" : "PDT";
- TimeZone value2 = TimeZone.getTimeZone(tzn);
- cal.setTimeZone(value2);
- TimeZone result = cal.getTimeZone();
- assertNotEqual(value1, result);
- assertEquals(value2, result);
- }
-
- /*
- * Test method for 'com.ibm.icu.util.Calendar.setLenient(boolean)'
- */
- public void testSetLenient() {
- Calendar cal = Calendar.getInstance();
- boolean lenient = cal.isLenient();
- cal.setLenient(!lenient);
- assertFalse(lenient == cal.isLenient());
-
- // not testing if it has the expected effect
- }
-
- /*
- * Test method for 'com.ibm.icu.util.Calendar.isLenient()'
- */
- public void testIsLenient() {
- // tested by testSetLenient
- }
-
- /*
- * Test method for 'com.ibm.icu.util.Calendar.setFirstDayOfWeek(int)'
- */
- public void testSetFirstDayOfWeek() {
- Calendar cal = Calendar.getInstance();
- int firstDay = cal.getFirstDayOfWeek();
- cal.setFirstDayOfWeek(firstDay+1);
- assertEquals(firstDay+1, cal.getFirstDayOfWeek());
-
- // don't test functionality
- }
-
- /*
- * Test method for 'com.ibm.icu.util.Calendar.getFirstDayOfWeek()'
- */
- public void testGetFirstDayOfWeek() {
- // tested by testSetFirstDayOfWeek
- }
-
- /*
- * Test method for 'com.ibm.icu.util.Calendar.setMinimalDaysInFirstWeek(int)'
- */
- public void testSetMinimalDaysInFirstWeek() {
- Calendar cal = Calendar.getInstance();
- int firstDay = cal.getMinimalDaysInFirstWeek();
- cal.setMinimalDaysInFirstWeek(firstDay+1);
- assertEquals(firstDay+1, cal.getMinimalDaysInFirstWeek());
-
- // don't test functionality
- }
-
- /*
- * Test method for 'com.ibm.icu.util.Calendar.getMinimalDaysInFirstWeek()'
- */
- public void testGetMinimalDaysInFirstWeek() {
- // tested by testSetMinimalDaysInFirstWeek
- }
-
- /*
- * Test method for 'com.ibm.icu.util.Calendar.getMinimum(int)'
- */
- public void testGetMinimum() {
- Calendar cal = Calendar.getInstance();
- assertEquals(1, cal.getMinimum(Calendar.DAY_OF_WEEK));
- }
-
- /*
- * Test method for 'com.ibm.icu.util.Calendar.getMaximum(int)'
- */
- public void testGetMaximum() {
- Calendar cal = Calendar.getInstance();
- assertEquals(7, cal.getMaximum(Calendar.DAY_OF_WEEK));
- }
-
- /*
- * Test method for 'com.ibm.icu.util.Calendar.getGreatestMinimum(int)'
- */
- public void testGetGreatestMinimum() {
- Calendar cal = Calendar.getInstance();
- assertEquals(1, cal.getGreatestMinimum(Calendar.DATE));
- }
-
- /*
- * Test method for 'com.ibm.icu.util.Calendar.getLeastMaximum(int)'
- */
- public void testGetLeastMaximum() {
- Calendar cal = Calendar.getInstance();
- assertEquals(28, cal.getLeastMaximum(Calendar.DATE));
- }
-
- /*
- * Test method for 'com.ibm.icu.util.Calendar.getDayOfWeekType(int)'
- */
- public void testGetDayOfWeekType() {
- Calendar cal = Calendar.getInstance(Locale.US);
- assertEquals(Calendar.WEEKDAY, cal.getDayOfWeekType(Calendar.FRIDAY));
- assertEquals(Calendar.WEEKEND, cal.getDayOfWeekType(Calendar.SATURDAY));
- }
-
- /*
- * Test method for 'com.ibm.icu.util.Calendar.getWeekendTransition(int)'
- */
- public void testGetWeekendTransition() {
- Calendar cal = Calendar.getInstance(Locale.US);
- try {
- cal.getWeekendTransition(Calendar.WEEKEND_ONSET);
- fail("expected IllegalArgumentException from getWeekendTransition");
- }
- catch (UnsupportedOperationException e) {
- // ok
- }
- }
-
- /*
- * Test method for 'com.ibm.icu.util.Calendar.isWeekend(Date)'
- */
- public void testIsWeekendDate() {
- Calendar cal = Calendar.getInstance(Locale.US);
- cal.set(Calendar.DAY_OF_WEEK, Calendar.SATURDAY);
- assertTrue(cal.isWeekend(cal.getTime()));
- cal.set(Calendar.DAY_OF_WEEK, Calendar.WEDNESDAY);
- assertFalse(cal.isWeekend(cal.getTime()));
- }
-
- /*
- * Test method for 'com.ibm.icu.util.Calendar.isWeekend()'
- */
- public void testIsWeekend() {
- Calendar cal = Calendar.getInstance(Locale.US);
- cal.set(Calendar.DAY_OF_WEEK, Calendar.SATURDAY);
- assertTrue(cal.isWeekend());
- cal.set(Calendar.DAY_OF_WEEK, Calendar.WEDNESDAY);
- assertFalse(cal.isWeekend());
- }
-
- /*
- * Test method for 'com.ibm.icu.util.Calendar.clone()'
- */
- public void testClone() {
- // tested by testHashCode
- }
-
- /*
- * Test method for 'com.ibm.icu.util.Calendar.toString()'
- */
- public void testToString() {
- Calendar cal = Calendar.getInstance();
- assertNotNull(cal.toString());
- }
-
- /*
- * Test method for 'com.ibm.icu.util.Calendar.getType()'
- */
- public void testGetType() {
- Calendar cal = Calendar.getInstance(Locale.US);
- assertEquals("gregorian", cal.getType());
- }
-}
+/*
+ *******************************************************************************
+ * 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.text.DateFormat;
+import com.ibm.icu.util.Calendar;
+import com.ibm.icu.util.TimeZone;
+import com.ibm.icu.util.ULocale;
+
+public class CalendarTest extends ICUTestCase {
+
+ /*
+ * Test method for 'com.ibm.icu.util.Calendar.hashCode()'
+ */
+ public void testHashCode() {
+ Calendar cal1 = Calendar.getInstance();
+ Calendar cal2 = Calendar.getInstance();
+ Calendar cal3 = Calendar.getInstance();
+
+ long t = System.currentTimeMillis();
+ cal1.setTimeInMillis(t);
+ cal2.setTimeInMillis(t);
+ cal3.setTimeInMillis(t);
+
+ cal3.setMinimalDaysInFirstWeek(cal3.getMinimalDaysInFirstWeek()+1);
+ testEHCS(cal1, cal2, cal3);
+ }
+
+ /*
+ * Test method for 'com.ibm.icu.util.Calendar.Calendar(Calendar)'
+ */
+ public void testCalendar() {
+ // tested implicitly everywhere
+ }
+
+ /*
+ * Test method for 'com.ibm.icu.util.Calendar.getInstance()'
+ */
+ public void testGetInstance() {
+ // tested by testEHCS
+ }
+
+ /*
+ * Test method for 'com.ibm.icu.util.Calendar.getInstance(TimeZone)'
+ */
+ public void testGetInstanceTimeZone() {
+ TimeZone tz = TimeZone.getTimeZone("America/Los_Angeles");
+ Calendar cal = Calendar.getInstance(tz);
+ assertNotNull(cal);
+ assertNotNull(cal.getTime());
+ assertEquals(tz, cal.getTimeZone());
+ }
+
+ /*
+ * Test method for 'com.ibm.icu.util.Calendar.getInstance(Locale)'
+ */
+ public void testGetInstanceLocale() {
+ Calendar cal = Calendar.getInstance(Locale.US);
+ assertNotNull(cal);
+ assertNotNull(cal.getTime());
+ }
+
+ /*
+ * Test method for 'com.ibm.icu.util.Calendar.getInstance(ULocale)'
+ */
+ public void testGetInstanceULocale() {
+ Calendar cal = Calendar.getInstance(ULocale.US);
+ assertNotNull(cal);
+ assertNotNull(cal.getTime());
+ }
+
+ /*
+ * Test method for 'com.ibm.icu.util.Calendar.getInstance(TimeZone, Locale)'
+ */
+ public void testGetInstanceTimeZoneLocale() {
+ TimeZone tz = TimeZone.getTimeZone("America/New_York");
+ Calendar cal = Calendar.getInstance(tz, Locale.US);
+ assertNotNull(cal);
+ assertNotNull(cal.getTime());
+ }
+
+ /*
+ * Test method for 'com.ibm.icu.util.Calendar.getInstance(TimeZone, ULocale)'
+ */
+ public void testGetInstanceTimeZoneULocale() {
+ TimeZone tz = TimeZone.getTimeZone("America/New_York");
+ Calendar cal = Calendar.getInstance(tz, ULocale.US);
+ assertNotNull(cal);
+ assertNotNull(cal.getTime());
+ }
+
+ /*
+ * Test method for 'com.ibm.icu.util.Calendar.getAvailableLocales()'
+ */
+ public void testGetAvailableLocales() {
+ assertNotNull(Calendar.getAvailableLocales());
+ }
+
+ /*
+ * Test method for 'com.ibm.icu.util.Calendar.getAvailableULocales()'
+ */
+ public void testGetAvailableULocales() {
+ assertNotNull(Calendar.getAvailableULocales());
+ }
+
+ /*
+ * Test method for 'com.ibm.icu.util.Calendar.getTime()'
+ */
+ public void testGetTime() {
+ Calendar cal = Calendar.getInstance();
+ assertNotNull(cal.getTime());
+ }
+
+ /*
+ * Test method for 'com.ibm.icu.util.Calendar.setTime(Date)'
+ */
+ public void testSetTime() {
+ Calendar cal = Calendar.getInstance();
+ cal.clear();
+ cal.set(2006, 0, 20, 9, 30, 0);
+ Date date = cal.getTime();
+ cal = Calendar.getInstance();
+ cal.setTime(date);
+ assertEquals(date, cal.getTime());
+ }
+
+ /*
+ * Test method for 'com.ibm.icu.util.Calendar.getTimeInMillis()'
+ */
+ public void testGetTimeInMillis() {
+ Calendar cal = Calendar.getInstance();
+ assertTrue(0 != cal.getTimeInMillis());
+ }
+
+ /*
+ * Test method for 'com.ibm.icu.util.Calendar.setTimeInMillis(long)'
+ */
+ public void testSetTimeInMillis() {
+ Calendar cal = Calendar.getInstance();
+ cal.clear();
+ cal.set(2006, 0, 20, 9, 30, 0);
+ long millis = cal.getTimeInMillis();
+ Date date = cal.getTime();
+
+ cal = Calendar.getInstance();
+ cal.setTimeInMillis(millis);
+
+ assertEquals(date, cal.getTime());
+ }
+
+ /*
+ * Test method for 'com.ibm.icu.util.Calendar.get(int)'
+ */
+ public void testGet() {
+ Calendar cal = Calendar.getInstance();
+ cal.clear();
+ cal.set(2006, 0, 20, 9, 30, 0);
+ assertEquals(0, cal.get(Calendar.MONTH));
+ assertEquals(20, cal.get(Calendar.DAY_OF_MONTH));
+ assertEquals(30, cal.get(Calendar.MINUTE));
+ }
+
+ /*
+ * Test method for 'com.ibm.icu.util.Calendar.set(int, int)'
+ */
+ public void testSetIntInt() {
+ Calendar cal = Calendar.getInstance();
+ cal.set(Calendar.YEAR, 1977);
+ assertEquals(1977, cal.get(Calendar.YEAR));
+ }
+
+ /*
+ * Test method for 'com.ibm.icu.util.Calendar.set(int, int, int)'
+ */
+ public void testSetIntIntInt() {
+ Calendar cal = Calendar.getInstance();
+ cal.set(1997, 9, 15);
+ assertEquals(15, cal.get(Calendar.DATE));
+ }
+
+ /*
+ * Test method for 'com.ibm.icu.util.Calendar.set(int, int, int, int, int)'
+ */
+ public void testSetIntIntIntIntInt() {
+ Calendar cal = Calendar.getInstance();
+ cal.set(1997, 9, 15, 14, 25);
+ assertEquals(25, cal.get(Calendar.MINUTE));
+ }
+
+ /*
+ * Test method for 'com.ibm.icu.util.Calendar.set(int, int, int, int, int, int)'
+ */
+ public void testSetIntIntIntIntIntInt() {
+ Calendar cal = Calendar.getInstance();
+ cal.set(1997, 9, 15, 14, 25, 51);
+ assertEquals(51, cal.get(Calendar.SECOND));
+ }
+
+ /*
+ * Test method for 'com.ibm.icu.util.Calendar.clear()'
+ */
+ public void testClear() {
+ Calendar cal = Calendar.getInstance();
+ cal.set(1997, 9, 15, 14, 25, 51);
+ cal.clear();
+ assertEquals(0, cal.get(Calendar.MONTH));
+ }
+
+ /*
+ * Test method for 'com.ibm.icu.util.Calendar.clear(int)'
+ */
+ public void testClearInt() {
+ Calendar cal = Calendar.getInstance();
+ cal.set(1997, 9, 15, 14, 25, 51);
+ assertTrue(cal.isSet(Calendar.DAY_OF_MONTH));
+ cal.clear(Calendar.DAY_OF_MONTH);
+ assertFalse(cal.isSet(Calendar.DAY_OF_MONTH));
+ }
+
+ /*
+ * Test method for 'com.ibm.icu.util.Calendar.isSet(int)'
+ */
+ public void testIsSet() {
+ // see testClearInt
+ }
+
+ /*
+ * Test method for 'com.ibm.icu.util.Calendar.equals(Object)'
+ */
+ public void testEqualsObject() {
+ // tested by testHashCode
+ }
+
+ /*
+ * Test method for 'com.ibm.icu.util.Calendar.isEquivalentTo(Calendar)'
+ */
+ public void testIsEquivalentTo() {
+ Calendar cal = Calendar.getInstance();
+ Calendar cal2 = Calendar.getInstance();
+ cal2.set(1994, 6, 21, 8, 7);
+ assertTrue(cal.isEquivalentTo(cal2));
+ cal.setTimeZone(TimeZone.getTimeZone("CST"));
+ cal2.setTimeZone(TimeZone.getTimeZone("PDT"));
+ assertFalse(cal.isEquivalentTo(cal2));
+ }
+
+ /*
+ * Test method for 'com.ibm.icu.util.Calendar.before(Object)'
+ */
+ public void testBefore() {
+ Calendar cal = Calendar.getInstance();
+ cal.set(Calendar.YEAR, 1990);
+ assertTrue(cal.before(new Date()));
+ assertTrue(cal.before(Calendar.getInstance()));
+ }
+
+ /*
+ * Test method for 'com.ibm.icu.util.Calendar.after(Object)'
+ */
+ public void testAfter() {
+ Calendar cal = Calendar.getInstance();
+ cal.set(Calendar.YEAR, 3058);
+ assertTrue(cal.after(new Date()));
+ assertTrue(cal.after(Calendar.getInstance()));
+ }
+
+ /*
+ * Test method for 'com.ibm.icu.util.Calendar.getActualMaximum(int)'
+ */
+ public void testGetActualMaximum() {
+ Calendar cal = Calendar.getInstance(Locale.US);
+ assertEquals(11, cal.getActualMaximum(Calendar.MONTH));
+ }
+
+ /*
+ * Test method for 'com.ibm.icu.util.Calendar.getActualMinimum(int)'
+ */
+ public void testGetActualMinimum() {
+ Calendar cal = Calendar.getInstance(Locale.US);
+ assertEquals(0, cal.getActualMinimum(Calendar.MONTH));
+ }
+
+ /*
+ * Test method for 'com.ibm.icu.util.Calendar.roll(int, boolean)'
+ */
+ public void testRollIntBoolean() {
+ Calendar cal = Calendar.getInstance(Locale.US);
+ cal.set(1997, 1, 27);
+ cal.roll(Calendar.DATE, true);
+ assertEquals(28, cal.get(Calendar.DATE));
+ }
+
+ /*
+ * Test method for 'com.ibm.icu.util.Calendar.roll(int, int)'
+ */
+ public void testRollIntInt() {
+ Calendar cal = Calendar.getInstance(Locale.US);
+ cal.set(1997, 1, 27);
+ cal.roll(Calendar.DATE, 3);
+ assertEquals(2, cal.get(Calendar.DATE));
+ }
+
+ /*
+ * Test method for 'com.ibm.icu.util.Calendar.add(int, int)'
+ */
+ public void testAdd() {
+ Calendar cal = Calendar.getInstance(Locale.US);
+ cal.set(1997, 1, 27);
+ cal.add(Calendar.DATE, 3);
+ assertEquals(2, cal.get(Calendar.DATE));
+ assertEquals(2, cal.get(Calendar.MONTH));
+ }
+
+ /*
+ * Test method for 'com.ibm.icu.util.Calendar.getDisplayName(Locale)'
+ */
+ public void testGetDisplayNameLocale() {
+ Calendar cal = Calendar.getInstance();
+ assertEquals("Gregorian Calendar", cal.getDisplayName(Locale.US));
+ }
+
+ /*
+ * Test method for 'com.ibm.icu.util.Calendar.getDisplayName(ULocale)'
+ */
+ public void testGetDisplayNameULocale() {
+ Calendar cal = Calendar.getInstance();
+ assertEquals("Gregorian Calendar", cal.getDisplayName(ULocale.US));
+ }
+
+ /*
+ * Test method for 'com.ibm.icu.util.Calendar.compareTo(Calendar)'
+ */
+ public void testCompareToCalendar() {
+ Calendar cal = Calendar.getInstance();
+ cal.set(Calendar.YEAR, 1990);
+ assertTrue(0 > cal.compareTo(Calendar.getInstance()));
+ }
+
+ /*
+ * Test method for 'com.ibm.icu.util.Calendar.compareTo(Object)'
+ */
+ public void testCompareToObject() {
+ Calendar cal = Calendar.getInstance();
+ cal.set(Calendar.YEAR, 1990);
+ assertTrue(0 > cal.compareTo(Calendar.getInstance()));
+ }
+
+ /*
+ * Test method for 'com.ibm.icu.util.Calendar.getDateTimeFormat(int, int, Locale)'
+ */
+ public void testGetDateTimeFormatIntIntLocale() {
+ Calendar cal = Calendar.getInstance();
+ cal.set(1990, 8, 16, 20, 3);
+ DateFormat df = cal.getDateTimeFormat(DateFormat.LONG, DateFormat.SHORT, Locale.US);
+ assertEquals("September 16, 1990 8:03 PM", df.format(cal));
+ }
+
+ /*
+ * Test method for 'com.ibm.icu.util.Calendar.getDateTimeFormat(int, int, ULocale)'
+ */
+ public void testGetDateTimeFormatIntIntULocale() {
+ Calendar cal = Calendar.getInstance();
+ cal.set(1990, 8, 16, 20, 3);
+ DateFormat df = cal.getDateTimeFormat(DateFormat.LONG, DateFormat.SHORT, ULocale.US);
+ assertEquals("September 16, 1990 8:03 PM", df.format(cal));
+ }
+
+ /*
+ * Test method for 'com.ibm.icu.util.Calendar.fieldDifference(Date, int)'
+ */
+ public void testFieldDifference() {
+ Calendar cal = Calendar.getInstance();
+ cal.set(Calendar.DAY_OF_MONTH, 0);
+ Date date = cal.getTime();
+ cal.add(Calendar.DAY_OF_MONTH, 5);
+ assertEquals(-5, cal.fieldDifference(date, Calendar.DAY_OF_MONTH));
+ }
+
+ /*
+ * Test method for 'com.ibm.icu.util.Calendar.getTimeZone()'
+ */
+ public void testGetTimeZone() {
+ Calendar cal = Calendar.getInstance();
+ assertNotNull(cal.getTimeZone());
+ }
+
+ /*
+ * Test method for 'com.ibm.icu.util.Calendar.setTimeZone(TimeZone)'
+ */
+ public void testSetTimeZone() {
+ Calendar cal = Calendar.getInstance();
+ TimeZone value1 = cal.getTimeZone();
+ String tzn = "PDT".equals(value1.getID()) ? "CST" : "PDT";
+ TimeZone value2 = TimeZone.getTimeZone(tzn);
+ cal.setTimeZone(value2);
+ TimeZone result = cal.getTimeZone();
+ assertNotEqual(value1, result);
+ assertEquals(value2, result);
+ }
+
+ /*
+ * Test method for 'com.ibm.icu.util.Calendar.setLenient(boolean)'
+ */
+ public void testSetLenient() {
+ Calendar cal = Calendar.getInstance();
+ boolean lenient = cal.isLenient();
+ cal.setLenient(!lenient);
+ assertFalse(lenient == cal.isLenient());
+
+ // not testing if it has the expected effect
+ }
+
+ /*
+ * Test method for 'com.ibm.icu.util.Calendar.isLenient()'
+ */
+ public void testIsLenient() {
+ // tested by testSetLenient
+ }
+
+ /*
+ * Test method for 'com.ibm.icu.util.Calendar.setFirstDayOfWeek(int)'
+ */
+ public void testSetFirstDayOfWeek() {
+ Calendar cal = Calendar.getInstance();
+ int firstDay = cal.getFirstDayOfWeek();
+ cal.setFirstDayOfWeek(firstDay+1);
+ assertEquals(firstDay+1, cal.getFirstDayOfWeek());
+
+ // don't test functionality
+ }
+
+ /*
+ * Test method for 'com.ibm.icu.util.Calendar.getFirstDayOfWeek()'
+ */
+ public void testGetFirstDayOfWeek() {
+ // tested by testSetFirstDayOfWeek
+ }
+
+ /*
+ * Test method for 'com.ibm.icu.util.Calendar.setMinimalDaysInFirstWeek(int)'
+ */
+ public void testSetMinimalDaysInFirstWeek() {
+ Calendar cal = Calendar.getInstance();
+ int firstDay = cal.getMinimalDaysInFirstWeek();
+ cal.setMinimalDaysInFirstWeek(firstDay+1);
+ assertEquals(firstDay+1, cal.getMinimalDaysInFirstWeek());
+
+ // don't test functionality
+ }
+
+ /*
+ * Test method for 'com.ibm.icu.util.Calendar.getMinimalDaysInFirstWeek()'
+ */
+ public void testGetMinimalDaysInFirstWeek() {
+ // tested by testSetMinimalDaysInFirstWeek
+ }
+
+ /*
+ * Test method for 'com.ibm.icu.util.Calendar.getMinimum(int)'
+ */
+ public void testGetMinimum() {
+ Calendar cal = Calendar.getInstance();
+ assertEquals(1, cal.getMinimum(Calendar.DAY_OF_WEEK));
+ }
+
+ /*
+ * Test method for 'com.ibm.icu.util.Calendar.getMaximum(int)'
+ */
+ public void testGetMaximum() {
+ Calendar cal = Calendar.getInstance();
+ assertEquals(7, cal.getMaximum(Calendar.DAY_OF_WEEK));
+ }
+
+ /*
+ * Test method for 'com.ibm.icu.util.Calendar.getGreatestMinimum(int)'
+ */
+ public void testGetGreatestMinimum() {
+ Calendar cal = Calendar.getInstance();
+ assertEquals(1, cal.getGreatestMinimum(Calendar.DATE));
+ }
+
+ /*
+ * Test method for 'com.ibm.icu.util.Calendar.getLeastMaximum(int)'
+ */
+ public void testGetLeastMaximum() {
+ Calendar cal = Calendar.getInstance();
+ assertEquals(28, cal.getLeastMaximum(Calendar.DATE));
+ }
+
+ /*
+ * Test method for 'com.ibm.icu.util.Calendar.getDayOfWeekType(int)'
+ */
+ public void testGetDayOfWeekType() {
+ Calendar cal = Calendar.getInstance(Locale.US);
+ assertEquals(Calendar.WEEKDAY, cal.getDayOfWeekType(Calendar.FRIDAY));
+ assertEquals(Calendar.WEEKEND, cal.getDayOfWeekType(Calendar.SATURDAY));
+ }
+
+ /*
+ * Test method for 'com.ibm.icu.util.Calendar.getWeekendTransition(int)'
+ */
+ public void testGetWeekendTransition() {
+ Calendar cal = Calendar.getInstance(Locale.US);
+ try {
+ cal.getWeekendTransition(Calendar.WEEKEND_ONSET);
+ fail("expected IllegalArgumentException from getWeekendTransition");
+ }
+ catch (UnsupportedOperationException e) {
+ // ok
+ }
+ }
+
+ /*
+ * Test method for 'com.ibm.icu.util.Calendar.isWeekend(Date)'
+ */
+ public void testIsWeekendDate() {
+ Calendar cal = Calendar.getInstance(Locale.US);
+ cal.set(Calendar.DAY_OF_WEEK, Calendar.SATURDAY);
+ assertTrue(cal.isWeekend(cal.getTime()));
+ cal.set(Calendar.DAY_OF_WEEK, Calendar.WEDNESDAY);
+ assertFalse(cal.isWeekend(cal.getTime()));
+ }
+
+ /*
+ * Test method for 'com.ibm.icu.util.Calendar.isWeekend()'
+ */
+ public void testIsWeekend() {
+ Calendar cal = Calendar.getInstance(Locale.US);
+ cal.set(Calendar.DAY_OF_WEEK, Calendar.SATURDAY);
+ assertTrue(cal.isWeekend());
+ cal.set(Calendar.DAY_OF_WEEK, Calendar.WEDNESDAY);
+ assertFalse(cal.isWeekend());
+ }
+
+ /*
+ * Test method for 'com.ibm.icu.util.Calendar.clone()'
+ */
+ public void testClone() {
+ // tested by testHashCode
+ }
+
+ /*
+ * Test method for 'com.ibm.icu.util.Calendar.toString()'
+ */
+ public void testToString() {
+ Calendar cal = Calendar.getInstance();
+ assertNotNull(cal.toString());
+ }
+
+ /*
+ * Test method for 'com.ibm.icu.util.Calendar.getType()'
+ */
+ public void testGetType() {
+ Calendar cal = Calendar.getInstance(Locale.US);
+ assertEquals("gregorian", cal.getType());
+ }
+}
diff --git a/icu4j/eclipse-build/plugins.template/com.ibm.icu.base.tests/src/com/ibm/icu/tests/CollationKeyTest.java b/icu4j/eclipse-build/plugins.template/com.ibm.icu.base.tests/src/com/ibm/icu/tests/CollationKeyTest.java
index 45725be90c2..a1afd34a424 100644
--- a/icu4j/eclipse-build/plugins.template/com.ibm.icu.base.tests/src/com/ibm/icu/tests/CollationKeyTest.java
+++ b/icu4j/eclipse-build/plugins.template/com.ibm.icu.base.tests/src/com/ibm/icu/tests/CollationKeyTest.java
@@ -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);
+ }
+}
diff --git a/icu4j/eclipse-build/plugins.template/com.ibm.icu.base.tests/src/com/ibm/icu/tests/CollatorTest.java b/icu4j/eclipse-build/plugins.template/com.ibm.icu.base.tests/src/com/ibm/icu/tests/CollatorTest.java
index 08349f18cbb..28f003d7cc6 100644
--- a/icu4j/eclipse-build/plugins.template/com.ibm.icu.base.tests/src/com/ibm/icu/tests/CollatorTest.java
+++ b/icu4j/eclipse-build/plugins.template/com.ibm.icu.base.tests/src/com/ibm/icu/tests/CollatorTest.java
@@ -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
+ }
+}
diff --git a/icu4j/eclipse-build/plugins.template/com.ibm.icu.base.tests/src/com/ibm/icu/tests/DateFormatSymbolsTest.java b/icu4j/eclipse-build/plugins.template/com.ibm.icu.base.tests/src/com/ibm/icu/tests/DateFormatSymbolsTest.java
index 2021969e0f1..4636e696dcb 100644
--- a/icu4j/eclipse-build/plugins.template/com.ibm.icu.base.tests/src/com/ibm/icu/tests/DateFormatSymbolsTest.java
+++ b/icu4j/eclipse-build/plugins.template/com.ibm.icu.base.tests/src/com/ibm/icu/tests/DateFormatSymbolsTest.java
@@ -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
+ }
+}
diff --git a/icu4j/eclipse-build/plugins.template/com.ibm.icu.base.tests/src/com/ibm/icu/tests/DateFormatTest.java b/icu4j/eclipse-build/plugins.template/com.ibm.icu.base.tests/src/com/ibm/icu/tests/DateFormatTest.java
index 37f5559f0aa..1e1e7e9815b 100644
--- a/icu4j/eclipse-build/plugins.template/com.ibm.icu.base.tests/src/com/ibm/icu/tests/DateFormatTest.java
+++ b/icu4j/eclipse-build/plugins.template/com.ibm.icu.base.tests/src/com/ibm/icu/tests/DateFormatTest.java
@@ -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
+ }
+}
diff --git a/icu4j/eclipse-build/plugins.template/com.ibm.icu.base.tests/src/com/ibm/icu/tests/DecimalFormatSymbolsTest.java b/icu4j/eclipse-build/plugins.template/com.ibm.icu.base.tests/src/com/ibm/icu/tests/DecimalFormatSymbolsTest.java
index 9cc7ce6837d..22779a5b2b0 100644
--- a/icu4j/eclipse-build/plugins.template/com.ibm.icu.base.tests/src/com/ibm/icu/tests/DecimalFormatSymbolsTest.java
+++ b/icu4j/eclipse-build/plugins.template/com.ibm.icu.base.tests/src/com/ibm/icu/tests/DecimalFormatSymbolsTest.java
@@ -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
+ }
+}
diff --git a/icu4j/eclipse-build/plugins.template/com.ibm.icu.base.tests/src/com/ibm/icu/tests/DecimalFormatTest.java b/icu4j/eclipse-build/plugins.template/com.ibm.icu.base.tests/src/com/ibm/icu/tests/DecimalFormatTest.java
index 23cc40d6f52..b438e2fb95f 100644
--- a/icu4j/eclipse-build/plugins.template/com.ibm.icu.base.tests/src/com/ibm/icu/tests/DecimalFormatTest.java
+++ b/icu4j/eclipse-build/plugins.template/com.ibm.icu.base.tests/src/com/ibm/icu/tests/DecimalFormatTest.java
@@ -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));
+ }
+}
diff --git a/icu4j/eclipse-build/plugins.template/com.ibm.icu.base.tests/src/com/ibm/icu/tests/ICUTestCase.java b/icu4j/eclipse-build/plugins.template/com.ibm.icu.base.tests/src/com/ibm/icu/tests/ICUTestCase.java
index 2e3de90a441..617fc14709c 100644
--- a/icu4j/eclipse-build/plugins.template/com.ibm.icu.base.tests/src/com/ibm/icu/tests/ICUTestCase.java
+++ b/icu4j/eclipse-build/plugins.template/com.ibm.icu.base.tests/src/com/ibm/icu/tests/ICUTestCase.java
@@ -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;
+ }
+}
diff --git a/icu4j/eclipse-build/plugins.template/com.ibm.icu.base.tests/src/com/ibm/icu/tests/MessageFormatTest.java b/icu4j/eclipse-build/plugins.template/com.ibm.icu.base.tests/src/com/ibm/icu/tests/MessageFormatTest.java
index 7f269fae9aa..9947214313e 100644
--- a/icu4j/eclipse-build/plugins.template/com.ibm.icu.base.tests/src/com/ibm/icu/tests/MessageFormatTest.java
+++ b/icu4j/eclipse-build/plugins.template/com.ibm.icu.base.tests/src/com/ibm/icu/tests/MessageFormatTest.java
@@ -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
+ }
+}
diff --git a/icu4j/eclipse-build/plugins.template/com.ibm.icu.base.tests/src/com/ibm/icu/tests/NumberFormatTest.java b/icu4j/eclipse-build/plugins.template/com.ibm.icu.base.tests/src/com/ibm/icu/tests/NumberFormatTest.java
index 3c7b7dd9dca..ec7188ff5b0 100644
--- a/icu4j/eclipse-build/plugins.template/com.ibm.icu.base.tests/src/com/ibm/icu/tests/NumberFormatTest.java
+++ b/icu4j/eclipse-build/plugins.template/com.ibm.icu.base.tests/src/com/ibm/icu/tests/NumberFormatTest.java
@@ -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
+ }
+}
diff --git a/icu4j/eclipse-build/plugins.template/com.ibm.icu.base.tests/src/com/ibm/icu/tests/SimpleDateFormatTest.java b/icu4j/eclipse-build/plugins.template/com.ibm.icu.base.tests/src/com/ibm/icu/tests/SimpleDateFormatTest.java
index 2bf36232777..0136a82ab9e 100644
--- a/icu4j/eclipse-build/plugins.template/com.ibm.icu.base.tests/src/com/ibm/icu/tests/SimpleDateFormatTest.java
+++ b/icu4j/eclipse-build/plugins.template/com.ibm.icu.base.tests/src/com/ibm/icu/tests/SimpleDateFormatTest.java
@@ -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"));
+ }
+}
diff --git a/icu4j/eclipse-build/plugins.template/com.ibm.icu.base.tests/src/com/ibm/icu/tests/TimeZoneTest.java b/icu4j/eclipse-build/plugins.template/com.ibm.icu.base.tests/src/com/ibm/icu/tests/TimeZoneTest.java
index d85d0a24ddc..f8a2fe16ce1 100644
--- a/icu4j/eclipse-build/plugins.template/com.ibm.icu.base.tests/src/com/ibm/icu/tests/TimeZoneTest.java
+++ b/icu4j/eclipse-build/plugins.template/com.ibm.icu.base.tests/src/com/ibm/icu/tests/TimeZoneTest.java
@@ -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
+ }
+}
diff --git a/icu4j/eclipse-build/plugins.template/com.ibm.icu.base.tests/src/com/ibm/icu/tests/ULocaleTest.java b/icu4j/eclipse-build/plugins.template/com.ibm.icu.base.tests/src/com/ibm/icu/tests/ULocaleTest.java
index 21cf50bfc54..d8a2b85d80d 100644
--- a/icu4j/eclipse-build/plugins.template/com.ibm.icu.base.tests/src/com/ibm/icu/tests/ULocaleTest.java
+++ b/icu4j/eclipse-build/plugins.template/com.ibm.icu.base.tests/src/com/ibm/icu/tests/ULocaleTest.java
@@ -1,748 +1,748 @@
-/*
- *******************************************************************************
- * Copyright (C) 2006-2011, International Business Machines Corporation and *
- * others. All Rights Reserved. *
- *******************************************************************************
- */
-
-package com.ibm.icu.tests;
-
-import java.util.Iterator;
-import java.util.Locale;
-
-import com.ibm.icu.util.ULocale;
-
-public class ULocaleTest extends ICUTestCase {
- private String sampleName;
- private String longULocaleName;
- private String longULocaleBasename;
- private String nonNormalizedName;
- private ULocale longULocale;
- private Locale sampleLocale;
-
- /**
- * @Override
- */
- protected void setUp() throws Exception {
- super.setUp();
-
- sampleName = "ll_CC_VVVV";
- longULocaleName = "ll_Ssss_CC_VVVV@collation=phonebook;key=value";
- longULocaleBasename = longULocaleName.substring(0, longULocaleName.indexOf('@'));
- nonNormalizedName = "LL_ssss_cc_VVVV@ Key = value ; Collation = phonebook ; ";
- longULocale = new ULocale(longULocaleName);
- sampleLocale = new ULocale(sampleName).toLocale();
- }
-
- /*
- * Test method for 'com.ibm.icu.x.util.ULocale.hashCode()'
- */
- public void testHashCode() {
- ULocale obj = ULocale.GERMANY;
- ULocale eq = new ULocale("de_DE");
- ULocale neq = new ULocale("de_DE_FRENCH");
-
- ICUTestCase.testEHCS(obj, eq, neq);
- }
-
- /*
- * Test method for 'com.ibm.icu.x.util.ULocale.forLocale(Locale)'
- */
- public void testForLocale() {
- assertEquals(ULocale.GERMANY, ULocale.forLocale(Locale.GERMANY));
- }
-
- /*
- * Test method for 'com.ibm.icu.x.util.ULocale.ULocale(String)'
- */
- public void testULocaleString() {
- assertEquals(ULocale.GERMAN, new ULocale("de"));
- }
-
- /*
- * Test method for 'com.ibm.icu.x.util.ULocale.ULocale(String, String)'
- */
- public void testULocaleStringString() {
- assertEquals(ULocale.GERMANY, new ULocale("de", "DE"));
- }
-
- /*
- * Test method for 'com.ibm.icu.x.util.ULocale.ULocale(String, String, String)'
- */
- public void testULocaleStringStringString() {
- assertEquals(sampleLocale, new ULocale("ll", "cc", "VVVV").toLocale());
- }
-
- /*
- * Test method for 'com.ibm.icu.x.util.ULocale.createCanonical(String)'
- */
- public void testCreateCanonical() {
- ULocale result = ULocale.createCanonical("de__PHONEBOOK");
- assertEquals(new ULocale("de@collation=phonebook"), result);
- }
-
- /*
- * Test method for 'com.ibm.icu.x.util.ULocale.toLocale()'
- */
- public void testToLocale() {
- assertEquals(sampleLocale, new ULocale("ll", "cc", "VVVV").toLocale());
- }
-
- /*
- * Test method for 'com.ibm.icu.x.util.ULocale.getDefault()'
- */
- public void testGetDefault() {
- assertEquals(Locale.getDefault(), ULocale.getDefault().toLocale());
- }
-
- /*
- * Test method for 'com.ibm.icu.x.util.ULocale.setDefault(ULocale)'
- */
- public void testSetDefault() {
- Locale oldLocale = Locale.getDefault();
- ULocale oldULocale = ULocale.getDefault();
- try {
- ULocale.setDefault(longULocale);
- ICUTestCase.assertNotEqual(Locale.getDefault(), oldLocale);
- ICUTestCase.assertNotEqual(ULocale.getDefault(), oldULocale);
- assertEquals(longULocale, ULocale.getDefault());
- assertEquals(sampleLocale, Locale.getDefault());
- }
- finally {
- ULocale.setDefault(oldULocale);
- Locale.setDefault(oldLocale); // in case of some error
- }
- }
-
- /*
- * Test method for 'com.ibm.icu.x.util.ULocale.clone()'
- */
- public void testClone() {
- // see testHashcode
- }
-
- /*
- * Test method for 'com.ibm.icu.x.util.ULocale.equals(Object)'
- */
- public void testEqualsObject() {
- // see testHashcode
- }
-
- /*
- * Test method for 'com.ibm.icu.x.util.ULocale.getAvailableLocales()'
- */
- public void testGetAvailableLocales() {
- ULocale[] ulocales = ULocale.getAvailableLocales();
- if (ICUTestCase.testingWrapper) {
- Locale[] locales = Locale.getAvailableLocales();
- for (int i = 0; i < ulocales.length; ++i) {
- assertEquals(ulocales[i].toLocale(), locales[i]);
- }
- }
- // else nothing to test except that the function returned.
- }
-
- /*
- * Test method for 'com.ibm.icu.x.util.ULocale.getISOCountries()'
- */
- public void testGetISOCountries() {
- String[] ucountries = ULocale.getISOCountries();
- assertNotNull(ucountries);
- if (ICUTestCase.testingWrapper) {
- // keep our own data for now
- // our data doesn't match java's so this test would fail
- // TODO: enable if we decide to use java's data
- // String[] countries = Locale.getISOCountries();
- // TestBoilerplate.assertArraysEqual(ucountries, countries);
- }
- // else nothing to test except that the function returned.
- }
-
- /*
- * Test method for 'com.ibm.icu.x.util.ULocale.getISOLanguages()'
- */
- public void testGetISOLanguages() {
- String[] ulanguages = ULocale.getISOLanguages();
- assertNotNull(ulanguages);
- if (ICUTestCase.testingWrapper) {
- // keep our own data for now
- // our data doesn't match java's so this test would fail
- // TODO: enable if we decide to use java's data
- // String[] languages = Locale.getISOLanguages();
- // TestBoilerplate.assertArraysEqual(ulanguages, languages);
- }
- // else nothing to test except that the function returned.
- }
-
- /*
- * Test method for 'com.ibm.icu.x.util.ULocale.getLanguage()'
- */
- public void testGetLanguage() {
- assertEquals("ll", longULocale.getLanguage());
- assertEquals("ll", longULocale.toLocale().getLanguage());
- }
-
- /*
- * Test method for 'com.ibm.icu.x.util.ULocale.getLanguage(String)'
- */
- public void testGetLanguageString() {
- assertEquals("ll", ULocale.getLanguage(longULocale.getName()));
- }
-
- /*
- * Test method for 'com.ibm.icu.x.util.ULocale.getScript()'
- */
- public void testGetScript() {
- assertEquals("Ssss", longULocale.getScript());
- }
-
- /*
- * Test method for 'com.ibm.icu.x.util.ULocale.getScript(String)'
- */
- public void testGetScriptString() {
- assertEquals("Ssss", ULocale.getScript(longULocale.getName()));
- }
-
- /*
- * Test method for 'com.ibm.icu.x.util.ULocale.getCountry()'
- */
- public void testGetCountry() {
- assertEquals("CC", longULocale.getCountry());
- assertEquals("CC", longULocale.toLocale().getCountry());
- }
-
- /*
- * Test method for 'com.ibm.icu.x.util.ULocale.getCountry(String)'
- */
- public void testGetCountryString() {
- assertEquals("CC", ULocale.getCountry(longULocale.getName()));
- }
-
- /*
- * Test method for 'com.ibm.icu.x.util.ULocale.getVariant()'
- */
- public void testGetVariant() {
- assertEquals("VVVV", longULocale.getVariant());
- assertEquals("VVVV", longULocale.toLocale().getVariant());
- }
-
- /*
- * Test method for 'com.ibm.icu.x.util.ULocale.getVariant(String)'
- */
- public void testGetVariantString() {
- assertEquals("VVVV", ULocale.getVariant(longULocale.getName()));
- }
-
- /*
- * Test method for 'com.ibm.icu.x.util.ULocale.getFallback(String)'
- */
- public void testGetFallbackString() {
- assertEquals(ULocale.GERMAN, ULocale.getFallback(ULocale.GERMANY.getName()));
- }
-
- /*
- * Test method for 'com.ibm.icu.x.util.ULocale.getFallback()'
- */
- public void testGetFallback() {
- assertEquals(ULocale.GERMAN, ULocale.GERMANY.getFallback());
- }
-
- /*
- * Test method for 'com.ibm.icu.x.util.ULocale.getBaseName()'
- */
- public void testGetBaseName() {
- assertEquals(longULocaleBasename, longULocale.getBaseName());
- }
-
- /*
- * Test method for 'com.ibm.icu.x.util.ULocale.getBaseName(String)'
- */
- public void testGetBaseNameString() {
- assertEquals(longULocaleBasename, longULocale.getBaseName());
- }
-
- /*
- * Test method for 'com.ibm.icu.x.util.ULocale.getName()'
- */
- public void testGetName() {
- assertEquals(longULocaleName, longULocale.getName());
- }
-
- /*
- * Test method for 'com.ibm.icu.x.util.ULocale.getName(String)'
- */
- public void testGetNameString() {
- assertEquals(longULocaleName, ULocale.getName(nonNormalizedName));
- }
-
- /*
- * Test method for 'com.ibm.icu.x.util.ULocale.toString()'
- */
- public void testToString() {
- assertEquals(longULocaleName, longULocale.toString());
- }
-
- /*
- * Test method for 'com.ibm.icu.x.util.ULocale.getKeywords()'
- */
- public void testGetKeywords() {
- Iterator iter = longULocale.getKeywords();
- assertEquals(iter.next(), "collation");
- assertEquals(iter.next(), "key");
- assertFalse(iter.hasNext());
- }
-
- /*
- * Test method for 'com.ibm.icu.x.util.ULocale.getKeywords(String)'
- */
- public void testGetKeywordsString() {
- Iterator iter = ULocale.getKeywords(nonNormalizedName);
- assertEquals(iter.next(), "collation");
- assertEquals(iter.next(), "key");
- assertFalse(iter.hasNext());
- }
-
- /*
- * Test method for 'com.ibm.icu.x.util.ULocale.getKeywordValue(String)'
- */
- public void testGetKeywordValueString() {
- assertEquals("value", longULocale.getKeywordValue("key"));
- assertEquals("phonebook", longULocale.getKeywordValue("collation"));
- assertNull(longULocale.getKeywordValue("zzyzx"));
- }
-
- /*
- * Test method for 'com.ibm.icu.x.util.ULocale.getKeywordValue(String, String)'
- */
- public void testGetKeywordValueStringString() {
- assertEquals("value", ULocale.getKeywordValue(longULocaleName, "key"));
- assertEquals("phonebook", ULocale.getKeywordValue(longULocaleName, "collation"));
- assertNull(ULocale.getKeywordValue(longULocaleName, "zzyzx"));
-
- }
-
- /*
- * Test method for 'com.ibm.icu.x.util.ULocale.canonicalize(String)'
- */
- public void testCanonicalize() {
- assertEquals("de@collation=phonebook", ULocale.canonicalize("de__PHONEBOOK"));
- }
-
- /*
- * Test method for 'com.ibm.icu.x.util.ULocale.setKeywordValue(String, String)'
- */
- public void testSetKeywordValueStringString() {
- ULocale munged = longULocale.setKeywordValue("key", "C#");
- assertEquals("C#", munged.getKeywordValue("key"));
- munged = munged.setKeywordValue("zzyzx", "grue");
- assertEquals("grue", munged.getKeywordValue("zzyzx"));
- }
-
- /*
- * Test method for 'com.ibm.icu.x.util.ULocale.setKeywordValue(String, String, String)'
- */
- public void testSetKeywordValueStringStringString() {
- String munged = ULocale.setKeywordValue(longULocaleName, "key", "C#");
- assertEquals("C#", ULocale.getKeywordValue(munged, "key"));
- munged = ULocale.setKeywordValue(munged, "zzyzx", "grue");
- assertEquals("grue", ULocale.getKeywordValue(munged, "zzyzx"));
- }
-
- /*
- * Test method for 'com.ibm.icu.x.util.ULocale.getISO3Language()'
- */
- public void testGetISO3Language() {
- String il = ULocale.GERMANY.getISO3Language();
- String jl = Locale.GERMANY.getISO3Language();
- assertEquals(il, jl);
- }
-
- /*
- * Test method for 'com.ibm.icu.x.util.ULocale.getISO3Language(String)'
- */
- public void testGetISO3LanguageString() {
- String il = ULocale.getISO3Language(ULocale.GERMANY.getName());
- String jl = Locale.GERMANY.getISO3Language();
- assertEquals(il, jl);
- }
-
- /*
- * Test method for 'com.ibm.icu.x.util.ULocale.getISO3Country()'
- */
- public void testGetISO3Country() {
- String ic = ULocale.GERMANY.getISO3Country();
- String jc = Locale.GERMANY.getISO3Country();
- assertEquals(ic, jc);
- }
-
- /*
- * Test method for 'com.ibm.icu.x.util.ULocale.getISO3Country(String)'
- */
- public void testGetISO3CountryString() {
- String ic = ULocale.getISO3Country(ULocale.GERMANY.getName());
- String jc = Locale.GERMANY.getISO3Country();
- assertEquals(ic, jc);
- }
-
- /*
- * Test method for 'com.ibm.icu.x.util.ULocale.getDisplayLanguage()'
- */
- public void testGetDisplayLanguage() {
- String idl = ULocale.GERMANY.getDisplayLanguage();
- String jdl = Locale.GERMANY.getDisplayLanguage();
- assertEquals(idl, jdl);
- }
-
- /*
- * Test method for 'com.ibm.icu.x.util.ULocale.getDisplayLanguage(ULocale)'
- */
- public void testGetDisplayLanguageULocale() {
- String idl = ULocale.GERMANY.getDisplayLanguage(ULocale.GERMANY);
- String jdl = Locale.GERMANY.getDisplayLanguage(Locale.GERMANY);
- assertEquals(idl, jdl);
- }
-
- /*
- * Test method for 'com.ibm.icu.x.util.ULocale.getDisplayLanguage(String, String)'
- */
- public void testGetDisplayLanguageStringString() {
- String idl = ULocale.getDisplayLanguage(ULocale.GERMANY.getName(), "de_DE");
- String jdl = Locale.GERMANY.getDisplayLanguage(Locale.GERMANY);
- assertEquals(idl, jdl);
- }
-
- /*
- * Test method for 'com.ibm.icu.x.util.ULocale.getDisplayLanguage(String, ULocale)'
- */
- public void testGetDisplayLanguageStringULocale() {
- String idl = ULocale.getDisplayLanguage(ULocale.GERMANY.getName(), ULocale.GERMANY);
- String jdl = Locale.GERMANY.getDisplayLanguage(Locale.GERMANY);
- assertEquals(idl, jdl);
- }
-
- /*
- * Test method for 'com.ibm.icu.x.util.ULocale.getDisplayScript()'
- */
- public void testGetDisplayScript() {
- String is = ULocale.TRADITIONAL_CHINESE.getDisplayScript();
- if (ICUTestCase.testingWrapper) {
- assertEquals("Hant", is);
- } else {
- assertEquals("Traditional Chinese", is);
- }
- }
-
- /*
- * Test method for 'com.ibm.icu.x.util.ULocale.getDisplayScript(ULocale)'
- */
- public void testGetDisplayScriptULocale() {
- String is = ULocale.TRADITIONAL_CHINESE.getDisplayScript(ULocale.GERMANY);
- if (ICUTestCase.testingWrapper) {
- assertEquals("Hant", is);
- } else {
- // TODO: look up expected value
- assertEquals("Hant", is);
- }
- }
-
- /*
- * Test method for 'com.ibm.icu.x.util.ULocale.getDisplayScript(String, String)'
- */
- public void testGetDisplayScriptStringString() {
- String is = ULocale.getDisplayScript("zh_Hant", "de_DE");
- if (ICUTestCase.testingWrapper) {
- assertEquals("Hant", is);
- } else {
- // TODO: look up expected value
- assertEquals("Hant", is);
- }
- }
-
- /*
- * Test method for 'com.ibm.icu.x.util.ULocale.getDisplayScript(String, ULocale)'
- */
- public void testGetDisplayScriptStringULocale() {
- String is = ULocale.getDisplayScript("zh_Hant", ULocale.GERMANY);
- if (ICUTestCase.testingWrapper) {
- assertEquals("Hant", is);
- } else {
- // TODO: look up expected value
- assertEquals("Hant", is);
- }
- }
-
- /*
- * Test method for 'com.ibm.icu.x.util.ULocale.getDisplayCountry()'
- */
- public void testGetDisplayCountry() {
- String idc = ULocale.GERMANY.getDisplayCountry();
- String jdc = Locale.GERMANY.getDisplayCountry();
- assertEquals(idc, jdc);
- }
-
- /*
- * Test method for 'com.ibm.icu.x.util.ULocale.getDisplayCountry(ULocale)'
- */
- public void testGetDisplayCountryULocale() {
- String idc = ULocale.GERMANY.getDisplayCountry(ULocale.GERMANY);
- String jdc = Locale.GERMANY.getDisplayCountry(Locale.GERMANY);
- assertEquals(idc, jdc);
- }
-
- /*
- * Test method for 'com.ibm.icu.x.util.ULocale.getDisplayCountry(String, String)'
- */
- public void testGetDisplayCountryStringString() {
- String idc = ULocale.getDisplayCountry("de_DE", "de_DE");
- String jdc = Locale.GERMANY.getDisplayCountry(Locale.GERMANY);
- assertEquals(idc, jdc);
- }
-
- /*
- * Test method for 'com.ibm.icu.x.util.ULocale.getDisplayCountry(String, ULocale)'
- */
- public void testGetDisplayCountryStringULocale() {
- String idc = ULocale.getDisplayCountry("de_DE", ULocale.GERMANY);
- String jdc = Locale.GERMANY.getDisplayCountry(Locale.GERMANY);
- assertEquals(idc, jdc);
- }
-
- /*
- * Test method for 'com.ibm.icu.x.util.ULocale.getDisplayVariant()'
- */
- public void testGetDisplayVariant() {
- String idv = new ULocale("de_DE_PHONEBOOK").getDisplayVariant();
- String jdv = new Locale("de", "DE", "PHONEBOOK").getDisplayVariant();
- assertEquals(jdv, idv);
- }
-
- /*
- * Test method for 'com.ibm.icu.x.util.ULocale.getDisplayVariant(ULocale)'
- */
- public void testGetDisplayVariantULocale() {
- String idv = new ULocale("de_DE_PHONEBOOK").getDisplayVariant(ULocale.GERMANY);
- String jdv = new Locale("de", "DE", "PHONEBOOK").getDisplayVariant(Locale.GERMANY);
- assertEquals(jdv, idv);
- }
-
- /*
- * Test method for 'com.ibm.icu.x.util.ULocale.getDisplayVariant(String, String)'
- */
- public void testGetDisplayVariantStringString() {
- String idv = ULocale.getDisplayVariant("de_DE_PHONEBOOK", "de_DE");
- String jdv = new Locale("de", "DE", "PHONEBOOK").getDisplayVariant(Locale.GERMANY);
- assertEquals(jdv, idv);
- }
-
- /*
- * Test method for 'com.ibm.icu.x.util.ULocale.getDisplayVariant(String, ULocale)'
- */
- public void testGetDisplayVariantStringULocale() {
- String idv = ULocale.getDisplayVariant("de_DE_PHONEBOOK", ULocale.GERMANY);
- String jdv = new Locale("de", "DE", "PHONEBOOK").getDisplayVariant(Locale.GERMANY);
- assertEquals(jdv, idv);
- }
-
- /*
- * Test method for 'com.ibm.icu.x.util.ULocale.getDisplayKeyword(String)'
- */
- public void testGetDisplayKeywordString() {
- String idk = ULocale.getDisplayKeyword("collation");
- assertEquals("collation", idk);
- }
-
- /*
- * Test method for 'com.ibm.icu.x.util.ULocale.getDisplayKeyword(String, String)'
- */
- public void testGetDisplayKeywordStringString() {
- String idk = ULocale.getDisplayKeyword("collation", "de_DE");
- if (ICUTestCase.testingWrapper) {
- assertEquals("collation", idk);
- } else {
- // TODO: find real value
- assertEquals("collation", idk);
- }
- }
-
- /*
- * Test method for 'com.ibm.icu.x.util.ULocale.getDisplayKeyword(String, ULocale)'
- */
- public void testGetDisplayKeywordStringULocale() {
- String idk = ULocale.getDisplayKeyword("collation", ULocale.GERMANY);
- if (ICUTestCase.testingWrapper) {
- assertEquals("collation", idk);
- } else {
- // TODO: find real value
- assertEquals("collation", idk);
- }
- }
-
- /*
- * Test method for 'com.ibm.icu.x.util.ULocale.getDisplayKeywordValue(String)'
- */
- public void testGetDisplayKeywordValueString() {
- ULocale ul = new ULocale("de_DE@collation=phonebook");
- String idk = ul.getDisplayKeywordValue("collation");
- if (ICUTestCase.testingWrapper) {
- assertEquals("phonebook", idk);
- } else {
- // TODO: find real value
- assertEquals("phonebook", idk);
- }
- }
-
- /*
- * Test method for 'com.ibm.icu.x.util.ULocale.getDisplayKeywordValue(String, ULocale)'
- */
- public void testGetDisplayKeywordValueStringULocale() {
- ULocale ul = new ULocale("de_DE@collation=phonebook");
- String idk = ul.getDisplayKeywordValue("collation", ULocale.GERMANY);
- if (ICUTestCase.testingWrapper) {
- assertEquals("phonebook", idk);
- } else {
- // TODO: find real value
- assertEquals("phonebook", idk);
- }
- }
-
- /*
- * Test method for 'com.ibm.icu.x.util.ULocale.getDisplayKeywordValue(String, String, String)'
- */
- public void testGetDisplayKeywordValueStringStringString() {
- String idk = ULocale.getDisplayKeywordValue("de_DE@collation=phonebook", "collation", "de_DE");
- if (ICUTestCase.testingWrapper) {
- assertEquals("phonebook", idk);
- } else {
- // TODO: find real value
- assertEquals("phonebook", idk);
- }
- }
-
- /*
- * Test method for 'com.ibm.icu.x.util.ULocale.getDisplayKeywordValue(String, String, ULocale)'
- */
- public void testGetDisplayKeywordValueStringStringULocale() {
- String idk = ULocale.getDisplayKeywordValue("de_DE@collation=phonebook", "collation", ULocale.GERMANY);
- if (ICUTestCase.testingWrapper) {
- assertEquals("phonebook", idk);
- } else {
- // TODO: find real value
- assertEquals("phonebook", idk);
- }
- }
-
- /*
- * Test method for 'com.ibm.icu.x.util.ULocale.getDisplayName()'
- */
- public void testGetDisplayName() {
- String idn = ULocale.GERMANY.getDisplayName();
- String jdn = Locale.GERMANY.getDisplayName();
- assertEquals(idn, jdn);
- }
-
- /*
- * Test method for 'com.ibm.icu.x.util.ULocale.getDisplayName(ULocale)'
- */
- public void testGetDisplayNameULocale() {
- String idn = ULocale.GERMANY.getDisplayName(ULocale.GERMANY);
- String jdn = Locale.GERMANY.getDisplayName(Locale.GERMANY);
- assertEquals(idn, jdn);
- }
-
- /*
- * Test method for 'com.ibm.icu.x.util.ULocale.getDisplayName(String, String)'
- */
- public void testGetDisplayNameStringString() {
- String idn = ULocale.getDisplayName("de_DE", "de_DE");
- String jdn = Locale.GERMANY.getDisplayName(Locale.GERMANY);
- assertEquals(idn, jdn);
- }
-
- /*
- * Test method for 'com.ibm.icu.x.util.ULocale.getDisplayName(String, ULocale)'
- */
- public void testGetDisplayNameStringULocale() {
- String idn = ULocale.getDisplayName("de_DE", ULocale.GERMANY);
- String jdn = Locale.GERMANY.getDisplayName(Locale.GERMANY);
- assertEquals(idn, jdn);
- }
-
- /*
- * Test method for 'com.ibm.icu.x.util.ULocale.acceptLanguage(String, ULocale[], boolean[])'
- */
- public void testAcceptLanguageStringULocaleArrayBooleanArray() {
- boolean[] fallback = new boolean[1];
- ULocale[] locales = {
- new ULocale("en_CA"),
- new ULocale("es_US"),
- };
- ULocale result = ULocale.acceptLanguage("en-US, en-GB, en-CA, es-US", locales, fallback);
- assertEquals(new ULocale("en_CA"), result);
- assertFalse(fallback[0]);
- result = ULocale.acceptLanguage("en-US, en-GB, es-US-NEWMEXICO", locales, fallback);
- assertEquals(new ULocale("es_US"), result);
- assertTrue(fallback[0]);
- }
-
- /*
- * Test method for 'com.ibm.icu.x.util.ULocale.acceptLanguage(ULocale[], ULocale[], boolean[])'
- */
- public void testAcceptLanguageULocaleArrayULocaleArrayBooleanArray() {
- boolean[] fallback = new boolean[1];
- ULocale[] locales = {
- new ULocale("en_CA"),
- new ULocale("es_US"),
- };
- ULocale[] accept_locales = {
- new ULocale("en_US"),
- new ULocale("en_GB"),
- new ULocale("en_CA"),
- new ULocale("es_US"),
- };
- ULocale[] accept_locales2 = {
- new ULocale("en_US"),
- new ULocale("en_GB"),
- new ULocale("es_US_NEWMEXICO"),
- };
- ULocale result = ULocale.acceptLanguage(accept_locales, locales, fallback);
- assertEquals(new ULocale("en_CA"), result);
- assertFalse(fallback[0]);
- result = ULocale.acceptLanguage(accept_locales2, locales, fallback);
- assertEquals(new ULocale("es_US"), result);
- assertTrue(fallback[0]);
- }
-
- /*
- * Test method for 'com.ibm.icu.x.util.ULocale.acceptLanguage(String, boolean[])'
- */
- public void testAcceptLanguageStringBooleanArray() {
- boolean[] fallback = new boolean[1];
- ULocale result = ULocale.acceptLanguage("en-CA, en-GB, es-US", fallback);
- assertEquals(new ULocale("en_CA"), result);
- assertFalse(fallback[0]);
- result = ULocale.acceptLanguage("es-US-NEWMEXICO", fallback);
- assertNotNull(result); // actual result depends on jdk
- assertTrue(fallback[0]);
- }
-
- /*
- * Test method for 'com.ibm.icu.x.util.ULocale.acceptLanguage(ULocale[], boolean[])'
- */
- public void testAcceptLanguageULocaleArrayBooleanArray() {
- boolean[] fallback = new boolean[1];
- ULocale[] accept_locales = {
- new ULocale("en_CA"),
- new ULocale("en_GB"),
- new ULocale("es_US"),
- };
- ULocale[] accept_locales2 = {
- new ULocale("es_US_NEWMEXICO"),
- };
- ULocale result = ULocale.acceptLanguage(accept_locales, fallback);
- assertEquals(new ULocale("en_CA"), result);
- assertFalse(fallback[0]);
- result = ULocale.acceptLanguage(accept_locales2, fallback);
- assertNotNull(result); // actual result depends on jdk
- assertTrue(fallback[0]);
- }
-}
+/*
+ *******************************************************************************
+ * Copyright (C) 2006-2011, International Business Machines Corporation and *
+ * others. All Rights Reserved. *
+ *******************************************************************************
+ */
+
+package com.ibm.icu.tests;
+
+import java.util.Iterator;
+import java.util.Locale;
+
+import com.ibm.icu.util.ULocale;
+
+public class ULocaleTest extends ICUTestCase {
+ private String sampleName;
+ private String longULocaleName;
+ private String longULocaleBasename;
+ private String nonNormalizedName;
+ private ULocale longULocale;
+ private Locale sampleLocale;
+
+ /**
+ * @Override
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ sampleName = "ll_CC_VVVV";
+ longULocaleName = "ll_Ssss_CC_VVVV@collation=phonebook;key=value";
+ longULocaleBasename = longULocaleName.substring(0, longULocaleName.indexOf('@'));
+ nonNormalizedName = "LL_ssss_cc_VVVV@ Key = value ; Collation = phonebook ; ";
+ longULocale = new ULocale(longULocaleName);
+ sampleLocale = new ULocale(sampleName).toLocale();
+ }
+
+ /*
+ * Test method for 'com.ibm.icu.x.util.ULocale.hashCode()'
+ */
+ public void testHashCode() {
+ ULocale obj = ULocale.GERMANY;
+ ULocale eq = new ULocale("de_DE");
+ ULocale neq = new ULocale("de_DE_FRENCH");
+
+ ICUTestCase.testEHCS(obj, eq, neq);
+ }
+
+ /*
+ * Test method for 'com.ibm.icu.x.util.ULocale.forLocale(Locale)'
+ */
+ public void testForLocale() {
+ assertEquals(ULocale.GERMANY, ULocale.forLocale(Locale.GERMANY));
+ }
+
+ /*
+ * Test method for 'com.ibm.icu.x.util.ULocale.ULocale(String)'
+ */
+ public void testULocaleString() {
+ assertEquals(ULocale.GERMAN, new ULocale("de"));
+ }
+
+ /*
+ * Test method for 'com.ibm.icu.x.util.ULocale.ULocale(String, String)'
+ */
+ public void testULocaleStringString() {
+ assertEquals(ULocale.GERMANY, new ULocale("de", "DE"));
+ }
+
+ /*
+ * Test method for 'com.ibm.icu.x.util.ULocale.ULocale(String, String, String)'
+ */
+ public void testULocaleStringStringString() {
+ assertEquals(sampleLocale, new ULocale("ll", "cc", "VVVV").toLocale());
+ }
+
+ /*
+ * Test method for 'com.ibm.icu.x.util.ULocale.createCanonical(String)'
+ */
+ public void testCreateCanonical() {
+ ULocale result = ULocale.createCanonical("de__PHONEBOOK");
+ assertEquals(new ULocale("de@collation=phonebook"), result);
+ }
+
+ /*
+ * Test method for 'com.ibm.icu.x.util.ULocale.toLocale()'
+ */
+ public void testToLocale() {
+ assertEquals(sampleLocale, new ULocale("ll", "cc", "VVVV").toLocale());
+ }
+
+ /*
+ * Test method for 'com.ibm.icu.x.util.ULocale.getDefault()'
+ */
+ public void testGetDefault() {
+ assertEquals(Locale.getDefault(), ULocale.getDefault().toLocale());
+ }
+
+ /*
+ * Test method for 'com.ibm.icu.x.util.ULocale.setDefault(ULocale)'
+ */
+ public void testSetDefault() {
+ Locale oldLocale = Locale.getDefault();
+ ULocale oldULocale = ULocale.getDefault();
+ try {
+ ULocale.setDefault(longULocale);
+ ICUTestCase.assertNotEqual(Locale.getDefault(), oldLocale);
+ ICUTestCase.assertNotEqual(ULocale.getDefault(), oldULocale);
+ assertEquals(longULocale, ULocale.getDefault());
+ assertEquals(sampleLocale, Locale.getDefault());
+ }
+ finally {
+ ULocale.setDefault(oldULocale);
+ Locale.setDefault(oldLocale); // in case of some error
+ }
+ }
+
+ /*
+ * Test method for 'com.ibm.icu.x.util.ULocale.clone()'
+ */
+ public void testClone() {
+ // see testHashcode
+ }
+
+ /*
+ * Test method for 'com.ibm.icu.x.util.ULocale.equals(Object)'
+ */
+ public void testEqualsObject() {
+ // see testHashcode
+ }
+
+ /*
+ * Test method for 'com.ibm.icu.x.util.ULocale.getAvailableLocales()'
+ */
+ public void testGetAvailableLocales() {
+ ULocale[] ulocales = ULocale.getAvailableLocales();
+ if (ICUTestCase.testingWrapper) {
+ Locale[] locales = Locale.getAvailableLocales();
+ for (int i = 0; i < ulocales.length; ++i) {
+ assertEquals(ulocales[i].toLocale(), locales[i]);
+ }
+ }
+ // else nothing to test except that the function returned.
+ }
+
+ /*
+ * Test method for 'com.ibm.icu.x.util.ULocale.getISOCountries()'
+ */
+ public void testGetISOCountries() {
+ String[] ucountries = ULocale.getISOCountries();
+ assertNotNull(ucountries);
+ if (ICUTestCase.testingWrapper) {
+ // keep our own data for now
+ // our data doesn't match java's so this test would fail
+ // TODO: enable if we decide to use java's data
+ // String[] countries = Locale.getISOCountries();
+ // TestBoilerplate.assertArraysEqual(ucountries, countries);
+ }
+ // else nothing to test except that the function returned.
+ }
+
+ /*
+ * Test method for 'com.ibm.icu.x.util.ULocale.getISOLanguages()'
+ */
+ public void testGetISOLanguages() {
+ String[] ulanguages = ULocale.getISOLanguages();
+ assertNotNull(ulanguages);
+ if (ICUTestCase.testingWrapper) {
+ // keep our own data for now
+ // our data doesn't match java's so this test would fail
+ // TODO: enable if we decide to use java's data
+ // String[] languages = Locale.getISOLanguages();
+ // TestBoilerplate.assertArraysEqual(ulanguages, languages);
+ }
+ // else nothing to test except that the function returned.
+ }
+
+ /*
+ * Test method for 'com.ibm.icu.x.util.ULocale.getLanguage()'
+ */
+ public void testGetLanguage() {
+ assertEquals("ll", longULocale.getLanguage());
+ assertEquals("ll", longULocale.toLocale().getLanguage());
+ }
+
+ /*
+ * Test method for 'com.ibm.icu.x.util.ULocale.getLanguage(String)'
+ */
+ public void testGetLanguageString() {
+ assertEquals("ll", ULocale.getLanguage(longULocale.getName()));
+ }
+
+ /*
+ * Test method for 'com.ibm.icu.x.util.ULocale.getScript()'
+ */
+ public void testGetScript() {
+ assertEquals("Ssss", longULocale.getScript());
+ }
+
+ /*
+ * Test method for 'com.ibm.icu.x.util.ULocale.getScript(String)'
+ */
+ public void testGetScriptString() {
+ assertEquals("Ssss", ULocale.getScript(longULocale.getName()));
+ }
+
+ /*
+ * Test method for 'com.ibm.icu.x.util.ULocale.getCountry()'
+ */
+ public void testGetCountry() {
+ assertEquals("CC", longULocale.getCountry());
+ assertEquals("CC", longULocale.toLocale().getCountry());
+ }
+
+ /*
+ * Test method for 'com.ibm.icu.x.util.ULocale.getCountry(String)'
+ */
+ public void testGetCountryString() {
+ assertEquals("CC", ULocale.getCountry(longULocale.getName()));
+ }
+
+ /*
+ * Test method for 'com.ibm.icu.x.util.ULocale.getVariant()'
+ */
+ public void testGetVariant() {
+ assertEquals("VVVV", longULocale.getVariant());
+ assertEquals("VVVV", longULocale.toLocale().getVariant());
+ }
+
+ /*
+ * Test method for 'com.ibm.icu.x.util.ULocale.getVariant(String)'
+ */
+ public void testGetVariantString() {
+ assertEquals("VVVV", ULocale.getVariant(longULocale.getName()));
+ }
+
+ /*
+ * Test method for 'com.ibm.icu.x.util.ULocale.getFallback(String)'
+ */
+ public void testGetFallbackString() {
+ assertEquals(ULocale.GERMAN, ULocale.getFallback(ULocale.GERMANY.getName()));
+ }
+
+ /*
+ * Test method for 'com.ibm.icu.x.util.ULocale.getFallback()'
+ */
+ public void testGetFallback() {
+ assertEquals(ULocale.GERMAN, ULocale.GERMANY.getFallback());
+ }
+
+ /*
+ * Test method for 'com.ibm.icu.x.util.ULocale.getBaseName()'
+ */
+ public void testGetBaseName() {
+ assertEquals(longULocaleBasename, longULocale.getBaseName());
+ }
+
+ /*
+ * Test method for 'com.ibm.icu.x.util.ULocale.getBaseName(String)'
+ */
+ public void testGetBaseNameString() {
+ assertEquals(longULocaleBasename, longULocale.getBaseName());
+ }
+
+ /*
+ * Test method for 'com.ibm.icu.x.util.ULocale.getName()'
+ */
+ public void testGetName() {
+ assertEquals(longULocaleName, longULocale.getName());
+ }
+
+ /*
+ * Test method for 'com.ibm.icu.x.util.ULocale.getName(String)'
+ */
+ public void testGetNameString() {
+ assertEquals(longULocaleName, ULocale.getName(nonNormalizedName));
+ }
+
+ /*
+ * Test method for 'com.ibm.icu.x.util.ULocale.toString()'
+ */
+ public void testToString() {
+ assertEquals(longULocaleName, longULocale.toString());
+ }
+
+ /*
+ * Test method for 'com.ibm.icu.x.util.ULocale.getKeywords()'
+ */
+ public void testGetKeywords() {
+ Iterator iter = longULocale.getKeywords();
+ assertEquals(iter.next(), "collation");
+ assertEquals(iter.next(), "key");
+ assertFalse(iter.hasNext());
+ }
+
+ /*
+ * Test method for 'com.ibm.icu.x.util.ULocale.getKeywords(String)'
+ */
+ public void testGetKeywordsString() {
+ Iterator iter = ULocale.getKeywords(nonNormalizedName);
+ assertEquals(iter.next(), "collation");
+ assertEquals(iter.next(), "key");
+ assertFalse(iter.hasNext());
+ }
+
+ /*
+ * Test method for 'com.ibm.icu.x.util.ULocale.getKeywordValue(String)'
+ */
+ public void testGetKeywordValueString() {
+ assertEquals("value", longULocale.getKeywordValue("key"));
+ assertEquals("phonebook", longULocale.getKeywordValue("collation"));
+ assertNull(longULocale.getKeywordValue("zzyzx"));
+ }
+
+ /*
+ * Test method for 'com.ibm.icu.x.util.ULocale.getKeywordValue(String, String)'
+ */
+ public void testGetKeywordValueStringString() {
+ assertEquals("value", ULocale.getKeywordValue(longULocaleName, "key"));
+ assertEquals("phonebook", ULocale.getKeywordValue(longULocaleName, "collation"));
+ assertNull(ULocale.getKeywordValue(longULocaleName, "zzyzx"));
+
+ }
+
+ /*
+ * Test method for 'com.ibm.icu.x.util.ULocale.canonicalize(String)'
+ */
+ public void testCanonicalize() {
+ assertEquals("de@collation=phonebook", ULocale.canonicalize("de__PHONEBOOK"));
+ }
+
+ /*
+ * Test method for 'com.ibm.icu.x.util.ULocale.setKeywordValue(String, String)'
+ */
+ public void testSetKeywordValueStringString() {
+ ULocale munged = longULocale.setKeywordValue("key", "C#");
+ assertEquals("C#", munged.getKeywordValue("key"));
+ munged = munged.setKeywordValue("zzyzx", "grue");
+ assertEquals("grue", munged.getKeywordValue("zzyzx"));
+ }
+
+ /*
+ * Test method for 'com.ibm.icu.x.util.ULocale.setKeywordValue(String, String, String)'
+ */
+ public void testSetKeywordValueStringStringString() {
+ String munged = ULocale.setKeywordValue(longULocaleName, "key", "C#");
+ assertEquals("C#", ULocale.getKeywordValue(munged, "key"));
+ munged = ULocale.setKeywordValue(munged, "zzyzx", "grue");
+ assertEquals("grue", ULocale.getKeywordValue(munged, "zzyzx"));
+ }
+
+ /*
+ * Test method for 'com.ibm.icu.x.util.ULocale.getISO3Language()'
+ */
+ public void testGetISO3Language() {
+ String il = ULocale.GERMANY.getISO3Language();
+ String jl = Locale.GERMANY.getISO3Language();
+ assertEquals(il, jl);
+ }
+
+ /*
+ * Test method for 'com.ibm.icu.x.util.ULocale.getISO3Language(String)'
+ */
+ public void testGetISO3LanguageString() {
+ String il = ULocale.getISO3Language(ULocale.GERMANY.getName());
+ String jl = Locale.GERMANY.getISO3Language();
+ assertEquals(il, jl);
+ }
+
+ /*
+ * Test method for 'com.ibm.icu.x.util.ULocale.getISO3Country()'
+ */
+ public void testGetISO3Country() {
+ String ic = ULocale.GERMANY.getISO3Country();
+ String jc = Locale.GERMANY.getISO3Country();
+ assertEquals(ic, jc);
+ }
+
+ /*
+ * Test method for 'com.ibm.icu.x.util.ULocale.getISO3Country(String)'
+ */
+ public void testGetISO3CountryString() {
+ String ic = ULocale.getISO3Country(ULocale.GERMANY.getName());
+ String jc = Locale.GERMANY.getISO3Country();
+ assertEquals(ic, jc);
+ }
+
+ /*
+ * Test method for 'com.ibm.icu.x.util.ULocale.getDisplayLanguage()'
+ */
+ public void testGetDisplayLanguage() {
+ String idl = ULocale.GERMANY.getDisplayLanguage();
+ String jdl = Locale.GERMANY.getDisplayLanguage();
+ assertEquals(idl, jdl);
+ }
+
+ /*
+ * Test method for 'com.ibm.icu.x.util.ULocale.getDisplayLanguage(ULocale)'
+ */
+ public void testGetDisplayLanguageULocale() {
+ String idl = ULocale.GERMANY.getDisplayLanguage(ULocale.GERMANY);
+ String jdl = Locale.GERMANY.getDisplayLanguage(Locale.GERMANY);
+ assertEquals(idl, jdl);
+ }
+
+ /*
+ * Test method for 'com.ibm.icu.x.util.ULocale.getDisplayLanguage(String, String)'
+ */
+ public void testGetDisplayLanguageStringString() {
+ String idl = ULocale.getDisplayLanguage(ULocale.GERMANY.getName(), "de_DE");
+ String jdl = Locale.GERMANY.getDisplayLanguage(Locale.GERMANY);
+ assertEquals(idl, jdl);
+ }
+
+ /*
+ * Test method for 'com.ibm.icu.x.util.ULocale.getDisplayLanguage(String, ULocale)'
+ */
+ public void testGetDisplayLanguageStringULocale() {
+ String idl = ULocale.getDisplayLanguage(ULocale.GERMANY.getName(), ULocale.GERMANY);
+ String jdl = Locale.GERMANY.getDisplayLanguage(Locale.GERMANY);
+ assertEquals(idl, jdl);
+ }
+
+ /*
+ * Test method for 'com.ibm.icu.x.util.ULocale.getDisplayScript()'
+ */
+ public void testGetDisplayScript() {
+ String is = ULocale.TRADITIONAL_CHINESE.getDisplayScript();
+ if (ICUTestCase.testingWrapper) {
+ assertEquals("Hant", is);
+ } else {
+ assertEquals("Traditional Chinese", is);
+ }
+ }
+
+ /*
+ * Test method for 'com.ibm.icu.x.util.ULocale.getDisplayScript(ULocale)'
+ */
+ public void testGetDisplayScriptULocale() {
+ String is = ULocale.TRADITIONAL_CHINESE.getDisplayScript(ULocale.GERMANY);
+ if (ICUTestCase.testingWrapper) {
+ assertEquals("Hant", is);
+ } else {
+ // TODO: look up expected value
+ assertEquals("Hant", is);
+ }
+ }
+
+ /*
+ * Test method for 'com.ibm.icu.x.util.ULocale.getDisplayScript(String, String)'
+ */
+ public void testGetDisplayScriptStringString() {
+ String is = ULocale.getDisplayScript("zh_Hant", "de_DE");
+ if (ICUTestCase.testingWrapper) {
+ assertEquals("Hant", is);
+ } else {
+ // TODO: look up expected value
+ assertEquals("Hant", is);
+ }
+ }
+
+ /*
+ * Test method for 'com.ibm.icu.x.util.ULocale.getDisplayScript(String, ULocale)'
+ */
+ public void testGetDisplayScriptStringULocale() {
+ String is = ULocale.getDisplayScript("zh_Hant", ULocale.GERMANY);
+ if (ICUTestCase.testingWrapper) {
+ assertEquals("Hant", is);
+ } else {
+ // TODO: look up expected value
+ assertEquals("Hant", is);
+ }
+ }
+
+ /*
+ * Test method for 'com.ibm.icu.x.util.ULocale.getDisplayCountry()'
+ */
+ public void testGetDisplayCountry() {
+ String idc = ULocale.GERMANY.getDisplayCountry();
+ String jdc = Locale.GERMANY.getDisplayCountry();
+ assertEquals(idc, jdc);
+ }
+
+ /*
+ * Test method for 'com.ibm.icu.x.util.ULocale.getDisplayCountry(ULocale)'
+ */
+ public void testGetDisplayCountryULocale() {
+ String idc = ULocale.GERMANY.getDisplayCountry(ULocale.GERMANY);
+ String jdc = Locale.GERMANY.getDisplayCountry(Locale.GERMANY);
+ assertEquals(idc, jdc);
+ }
+
+ /*
+ * Test method for 'com.ibm.icu.x.util.ULocale.getDisplayCountry(String, String)'
+ */
+ public void testGetDisplayCountryStringString() {
+ String idc = ULocale.getDisplayCountry("de_DE", "de_DE");
+ String jdc = Locale.GERMANY.getDisplayCountry(Locale.GERMANY);
+ assertEquals(idc, jdc);
+ }
+
+ /*
+ * Test method for 'com.ibm.icu.x.util.ULocale.getDisplayCountry(String, ULocale)'
+ */
+ public void testGetDisplayCountryStringULocale() {
+ String idc = ULocale.getDisplayCountry("de_DE", ULocale.GERMANY);
+ String jdc = Locale.GERMANY.getDisplayCountry(Locale.GERMANY);
+ assertEquals(idc, jdc);
+ }
+
+ /*
+ * Test method for 'com.ibm.icu.x.util.ULocale.getDisplayVariant()'
+ */
+ public void testGetDisplayVariant() {
+ String idv = new ULocale("de_DE_PHONEBOOK").getDisplayVariant();
+ String jdv = new Locale("de", "DE", "PHONEBOOK").getDisplayVariant();
+ assertEquals(jdv, idv);
+ }
+
+ /*
+ * Test method for 'com.ibm.icu.x.util.ULocale.getDisplayVariant(ULocale)'
+ */
+ public void testGetDisplayVariantULocale() {
+ String idv = new ULocale("de_DE_PHONEBOOK").getDisplayVariant(ULocale.GERMANY);
+ String jdv = new Locale("de", "DE", "PHONEBOOK").getDisplayVariant(Locale.GERMANY);
+ assertEquals(jdv, idv);
+ }
+
+ /*
+ * Test method for 'com.ibm.icu.x.util.ULocale.getDisplayVariant(String, String)'
+ */
+ public void testGetDisplayVariantStringString() {
+ String idv = ULocale.getDisplayVariant("de_DE_PHONEBOOK", "de_DE");
+ String jdv = new Locale("de", "DE", "PHONEBOOK").getDisplayVariant(Locale.GERMANY);
+ assertEquals(jdv, idv);
+ }
+
+ /*
+ * Test method for 'com.ibm.icu.x.util.ULocale.getDisplayVariant(String, ULocale)'
+ */
+ public void testGetDisplayVariantStringULocale() {
+ String idv = ULocale.getDisplayVariant("de_DE_PHONEBOOK", ULocale.GERMANY);
+ String jdv = new Locale("de", "DE", "PHONEBOOK").getDisplayVariant(Locale.GERMANY);
+ assertEquals(jdv, idv);
+ }
+
+ /*
+ * Test method for 'com.ibm.icu.x.util.ULocale.getDisplayKeyword(String)'
+ */
+ public void testGetDisplayKeywordString() {
+ String idk = ULocale.getDisplayKeyword("collation");
+ assertEquals("collation", idk);
+ }
+
+ /*
+ * Test method for 'com.ibm.icu.x.util.ULocale.getDisplayKeyword(String, String)'
+ */
+ public void testGetDisplayKeywordStringString() {
+ String idk = ULocale.getDisplayKeyword("collation", "de_DE");
+ if (ICUTestCase.testingWrapper) {
+ assertEquals("collation", idk);
+ } else {
+ // TODO: find real value
+ assertEquals("collation", idk);
+ }
+ }
+
+ /*
+ * Test method for 'com.ibm.icu.x.util.ULocale.getDisplayKeyword(String, ULocale)'
+ */
+ public void testGetDisplayKeywordStringULocale() {
+ String idk = ULocale.getDisplayKeyword("collation", ULocale.GERMANY);
+ if (ICUTestCase.testingWrapper) {
+ assertEquals("collation", idk);
+ } else {
+ // TODO: find real value
+ assertEquals("collation", idk);
+ }
+ }
+
+ /*
+ * Test method for 'com.ibm.icu.x.util.ULocale.getDisplayKeywordValue(String)'
+ */
+ public void testGetDisplayKeywordValueString() {
+ ULocale ul = new ULocale("de_DE@collation=phonebook");
+ String idk = ul.getDisplayKeywordValue("collation");
+ if (ICUTestCase.testingWrapper) {
+ assertEquals("phonebook", idk);
+ } else {
+ // TODO: find real value
+ assertEquals("phonebook", idk);
+ }
+ }
+
+ /*
+ * Test method for 'com.ibm.icu.x.util.ULocale.getDisplayKeywordValue(String, ULocale)'
+ */
+ public void testGetDisplayKeywordValueStringULocale() {
+ ULocale ul = new ULocale("de_DE@collation=phonebook");
+ String idk = ul.getDisplayKeywordValue("collation", ULocale.GERMANY);
+ if (ICUTestCase.testingWrapper) {
+ assertEquals("phonebook", idk);
+ } else {
+ // TODO: find real value
+ assertEquals("phonebook", idk);
+ }
+ }
+
+ /*
+ * Test method for 'com.ibm.icu.x.util.ULocale.getDisplayKeywordValue(String, String, String)'
+ */
+ public void testGetDisplayKeywordValueStringStringString() {
+ String idk = ULocale.getDisplayKeywordValue("de_DE@collation=phonebook", "collation", "de_DE");
+ if (ICUTestCase.testingWrapper) {
+ assertEquals("phonebook", idk);
+ } else {
+ // TODO: find real value
+ assertEquals("phonebook", idk);
+ }
+ }
+
+ /*
+ * Test method for 'com.ibm.icu.x.util.ULocale.getDisplayKeywordValue(String, String, ULocale)'
+ */
+ public void testGetDisplayKeywordValueStringStringULocale() {
+ String idk = ULocale.getDisplayKeywordValue("de_DE@collation=phonebook", "collation", ULocale.GERMANY);
+ if (ICUTestCase.testingWrapper) {
+ assertEquals("phonebook", idk);
+ } else {
+ // TODO: find real value
+ assertEquals("phonebook", idk);
+ }
+ }
+
+ /*
+ * Test method for 'com.ibm.icu.x.util.ULocale.getDisplayName()'
+ */
+ public void testGetDisplayName() {
+ String idn = ULocale.GERMANY.getDisplayName();
+ String jdn = Locale.GERMANY.getDisplayName();
+ assertEquals(idn, jdn);
+ }
+
+ /*
+ * Test method for 'com.ibm.icu.x.util.ULocale.getDisplayName(ULocale)'
+ */
+ public void testGetDisplayNameULocale() {
+ String idn = ULocale.GERMANY.getDisplayName(ULocale.GERMANY);
+ String jdn = Locale.GERMANY.getDisplayName(Locale.GERMANY);
+ assertEquals(idn, jdn);
+ }
+
+ /*
+ * Test method for 'com.ibm.icu.x.util.ULocale.getDisplayName(String, String)'
+ */
+ public void testGetDisplayNameStringString() {
+ String idn = ULocale.getDisplayName("de_DE", "de_DE");
+ String jdn = Locale.GERMANY.getDisplayName(Locale.GERMANY);
+ assertEquals(idn, jdn);
+ }
+
+ /*
+ * Test method for 'com.ibm.icu.x.util.ULocale.getDisplayName(String, ULocale)'
+ */
+ public void testGetDisplayNameStringULocale() {
+ String idn = ULocale.getDisplayName("de_DE", ULocale.GERMANY);
+ String jdn = Locale.GERMANY.getDisplayName(Locale.GERMANY);
+ assertEquals(idn, jdn);
+ }
+
+ /*
+ * Test method for 'com.ibm.icu.x.util.ULocale.acceptLanguage(String, ULocale[], boolean[])'
+ */
+ public void testAcceptLanguageStringULocaleArrayBooleanArray() {
+ boolean[] fallback = new boolean[1];
+ ULocale[] locales = {
+ new ULocale("en_CA"),
+ new ULocale("es_US"),
+ };
+ ULocale result = ULocale.acceptLanguage("en-US, en-GB, en-CA, es-US", locales, fallback);
+ assertEquals(new ULocale("en_CA"), result);
+ assertFalse(fallback[0]);
+ result = ULocale.acceptLanguage("en-US, en-GB, es-US-NEWMEXICO", locales, fallback);
+ assertEquals(new ULocale("es_US"), result);
+ assertTrue(fallback[0]);
+ }
+
+ /*
+ * Test method for 'com.ibm.icu.x.util.ULocale.acceptLanguage(ULocale[], ULocale[], boolean[])'
+ */
+ public void testAcceptLanguageULocaleArrayULocaleArrayBooleanArray() {
+ boolean[] fallback = new boolean[1];
+ ULocale[] locales = {
+ new ULocale("en_CA"),
+ new ULocale("es_US"),
+ };
+ ULocale[] accept_locales = {
+ new ULocale("en_US"),
+ new ULocale("en_GB"),
+ new ULocale("en_CA"),
+ new ULocale("es_US"),
+ };
+ ULocale[] accept_locales2 = {
+ new ULocale("en_US"),
+ new ULocale("en_GB"),
+ new ULocale("es_US_NEWMEXICO"),
+ };
+ ULocale result = ULocale.acceptLanguage(accept_locales, locales, fallback);
+ assertEquals(new ULocale("en_CA"), result);
+ assertFalse(fallback[0]);
+ result = ULocale.acceptLanguage(accept_locales2, locales, fallback);
+ assertEquals(new ULocale("es_US"), result);
+ assertTrue(fallback[0]);
+ }
+
+ /*
+ * Test method for 'com.ibm.icu.x.util.ULocale.acceptLanguage(String, boolean[])'
+ */
+ public void testAcceptLanguageStringBooleanArray() {
+ boolean[] fallback = new boolean[1];
+ ULocale result = ULocale.acceptLanguage("en-CA, en-GB, es-US", fallback);
+ assertEquals(new ULocale("en_CA"), result);
+ assertFalse(fallback[0]);
+ result = ULocale.acceptLanguage("es-US-NEWMEXICO", fallback);
+ assertNotNull(result); // actual result depends on jdk
+ assertTrue(fallback[0]);
+ }
+
+ /*
+ * Test method for 'com.ibm.icu.x.util.ULocale.acceptLanguage(ULocale[], boolean[])'
+ */
+ public void testAcceptLanguageULocaleArrayBooleanArray() {
+ boolean[] fallback = new boolean[1];
+ ULocale[] accept_locales = {
+ new ULocale("en_CA"),
+ new ULocale("en_GB"),
+ new ULocale("es_US"),
+ };
+ ULocale[] accept_locales2 = {
+ new ULocale("es_US_NEWMEXICO"),
+ };
+ ULocale result = ULocale.acceptLanguage(accept_locales, fallback);
+ assertEquals(new ULocale("en_CA"), result);
+ assertFalse(fallback[0]);
+ result = ULocale.acceptLanguage(accept_locales2, fallback);
+ assertNotNull(result); // actual result depends on jdk
+ assertTrue(fallback[0]);
+ }
+}
diff --git a/icu4j/eclipse-build/plugins.template/com.ibm.icu.base/src/com/ibm/icu/impl/ICUCache.java b/icu4j/eclipse-build/plugins.template/com.ibm.icu.base/src/com/ibm/icu/impl/ICUCache.java
index c3ca4b5a207..17828f7763d 100644
--- a/icu4j/eclipse-build/plugins.template/com.ibm.icu.base/src/com/ibm/icu/impl/ICUCache.java
+++ b/icu4j/eclipse-build/plugins.template/com.ibm.icu.base/src/com/ibm/icu/impl/ICUCache.java
@@ -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 {
- // 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 {
+ // 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);
+}
diff --git a/icu4j/eclipse-build/plugins.template/com.ibm.icu.base/src/com/ibm/icu/impl/LocaleIDParser.java b/icu4j/eclipse-build/plugins.template/com.ibm.icu.base/src/com/ibm/icu/impl/LocaleIDParser.java
index a9d0d306893..67690da5796 100644
--- a/icu4j/eclipse-build/plugins.template/com.ibm.icu.base/src/com/ibm/icu/impl/LocaleIDParser.java
+++ b/icu4j/eclipse-build/plugins.template/com.ibm.icu.base/src/com/ibm/icu/impl/LocaleIDParser.java
@@ -1,741 +1,741 @@
-/*
-******************************************************************************
-* Copyright (C) 2003-2011, International Business Machines Corporation and *
-* others. All Rights Reserved. *
-******************************************************************************
-*/
-
-package com.ibm.icu.impl;
-
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.TreeMap;
-
-import com.ibm.icu.impl.locale.AsciiUtil;
-
-/**
- * Utility class to parse and normalize locale ids (including POSIX style)
- */
-public final class LocaleIDParser {
- private char[] id;
- private int index;
- private char[] buffer;
- private int blen;
- // um, don't handle POSIX ids unless we request it. why not? well... because.
- private boolean canonicalize;
- private boolean hadCountry;
-
- // used when canonicalizing
- Map keywords;
- String baseName;
-
- /**
- * Parsing constants.
- */
- private static final char KEYWORD_SEPARATOR = '@';
- private static final char HYPHEN = '-';
- private static final char KEYWORD_ASSIGN = '=';
- private static final char COMMA = ',';
- private static final char ITEM_SEPARATOR = ';';
- private static final char DOT = '.';
- private static final char UNDERSCORE = '_';
-
- public LocaleIDParser(String localeID) {
- this(localeID, false);
- }
-
- public LocaleIDParser(String localeID, boolean canonicalize) {
- id = localeID.toCharArray();
- index = 0;
- buffer = new char[id.length + 5];
- blen = 0;
- this.canonicalize = canonicalize;
- }
-
- private void reset() {
- index = blen = 0;
- }
-
- // utilities for working on text in the buffer
-
- /**
- * Append c to the buffer.
- */
- private void append(char c) {
- try {
- buffer[blen] = c;
- }
- catch (IndexOutOfBoundsException e) {
- if (buffer.length > 512) {
- // something is seriously wrong, let this go
- throw e;
- }
- char[] nbuffer = new char[buffer.length * 2];
- System.arraycopy(buffer, 0, nbuffer, 0, buffer.length);
- nbuffer[blen] = c;
- buffer = nbuffer;
- }
- ++blen;
- }
-
- private void addSeparator() {
- append(UNDERSCORE);
- }
-
- /**
- * Returns the text in the buffer from start to blen as a String.
- */
- private String getString(int start) {
- if (start == blen) {
- return "";
- }
- return new String(buffer, start, blen-start);
- }
-
- /**
- * Set the length of the buffer to pos, then append the string.
- */
- private void set(int pos, String s) {
- this.blen = pos; // no safety
- append(s);
- }
-
- /**
- * Append the string to the buffer.
- */
- private void append(String s) {
- for (int i = 0; i < s.length(); ++i) {
- append(s.charAt(i));
- }
- }
-
- // utilities for parsing text out of the id
-
- /**
- * Character to indicate no more text is available in the id.
- */
- private static final char DONE = '\uffff';
-
- /**
- * Returns the character at index in the id, and advance index. The returned character
- * is DONE if index was at the limit of the buffer. The index is advanced regardless
- * so that decrementing the index will always 'unget' the last character returned.
- */
- private char next() {
- if (index == id.length) {
- index++;
- return DONE;
- }
-
- return id[index++];
- }
-
- /**
- * Advance index until the next terminator or id separator, and leave it there.
- */
- private void skipUntilTerminatorOrIDSeparator() {
- while (!isTerminatorOrIDSeparator(next())) {
- }
- --index;
- }
-
- /**
- * Returns true if the character at index in the id is a terminator.
- */
- private boolean atTerminator() {
- return index >= id.length || isTerminator(id[index]);
- }
-
- /*
- * Returns true if the character is an id separator (underscore or hyphen).
- */
- /* private boolean isIDSeparator(char c) {
- return c == UNDERSCORE || c == HYPHEN;
- }*/
-
- /**
- * Returns true if the character is a terminator (keyword separator, dot, or DONE).
- * Dot is a terminator because of the POSIX form, where dot precedes the codepage.
- */
- private boolean isTerminator(char c) {
- // always terminate at DOT, even if not handling POSIX. It's an error...
- return c == KEYWORD_SEPARATOR || c == DONE || c == DOT;
- }
-
- /**
- * Returns true if the character is a terminator or id separator.
- */
- private boolean isTerminatorOrIDSeparator(char c) {
- return c == KEYWORD_SEPARATOR || c == UNDERSCORE || c == HYPHEN ||
- c == DONE || c == DOT;
- }
-
- /**
- * Returns true if the start of the buffer has an experimental or private language
- * prefix, the pattern '[ixIX][-_].' shows the syntax checked.
- */
- private boolean haveExperimentalLanguagePrefix() {
- if (id.length > 2) {
- char c = id[1];
- if (c == HYPHEN || c == UNDERSCORE) {
- c = id[0];
- return c == 'x' || c == 'X' || c == 'i' || c == 'I';
- }
- }
- return false;
- }
-
- /**
- * Returns true if a value separator occurs at or after index.
- */
- private boolean haveKeywordAssign() {
- // assume it is safe to start from index
- for (int i = index; i < id.length; ++i) {
- if (id[i] == KEYWORD_ASSIGN) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * Advance index past language, and accumulate normalized language code in buffer.
- * Index must be at 0 when this is called. Index is left at a terminator or id
- * separator. Returns the start of the language code in the buffer.
- */
- private int parseLanguage() {
- if (haveExperimentalLanguagePrefix()) {
- append(Character.toLowerCase(id[0]));
- append(HYPHEN);
- index = 2;
- }
-
- char c;
- while(!isTerminatorOrIDSeparator(c = next())) {
- append(Character.toLowerCase(c));
- }
- --index; // unget
-
- if (blen == 3) {
- String lang = LocaleIDs.threeToTwoLetterLanguage(getString(0));
- if (lang != null) {
- set(0, lang);
- }
- }
-
- return 0;
- }
-
- /**
- * Advance index past language. Index must be at 0 when this is called. Index
- * is left at a terminator or id separator.
- */
- private void skipLanguage() {
- if (haveExperimentalLanguagePrefix()) {
- index = 2;
- }
- skipUntilTerminatorOrIDSeparator();
- }
-
- /**
- * Advance index past script, and accumulate normalized script in buffer.
- * Index must be immediately after the language.
- * If the item at this position is not a script (is not four characters
- * long) leave index and buffer unchanged. Otherwise index is left at
- * a terminator or id separator. Returns the start of the script code
- * in the buffer (this may be equal to the buffer length, if there is no
- * script).
- */
- private int parseScript() {
- if (!atTerminator()) {
- int oldIndex = index; // save original index
- ++index;
-
- int oldBlen = blen; // get before append hyphen, if we truncate everything is undone
- char c;
- while(!isTerminatorOrIDSeparator(c = next())) {
- if (blen == oldBlen) { // first pass
- addSeparator();
- append(Character.toUpperCase(c));
- } else {
- append(Character.toLowerCase(c));
- }
- }
- --index; // unget
-
- /* If it's not exactly 4 characters long, then it's not a script. */
- if (index - oldIndex != 5) { // +1 to account for separator
- index = oldIndex;
- blen = oldBlen;
- } else {
- oldBlen++; // index past hyphen, for clients who want to extract just the script
- }
-
- return oldBlen;
- }
- return blen;
- }
-
- /**
- * Advance index past script.
- * Index must be immediately after the language and IDSeparator.
- * If the item at this position is not a script (is not four characters
- * long) leave index. Otherwise index is left at a terminator or
- * id separator.
- */
- private void skipScript() {
- if (!atTerminator()) {
- int oldIndex = index;
- ++index;
-
- skipUntilTerminatorOrIDSeparator();
- if (index - oldIndex != 5) { // +1 to account for separator
- index = oldIndex;
- }
- }
- }
-
- /**
- * Advance index past country, and accumulate normalized country in buffer.
- * Index must be immediately after the script (if there is one, else language)
- * and IDSeparator. Return the start of the country code in the buffer.
- */
- private int parseCountry() {
- if (!atTerminator()) {
- int oldIndex = index;
- ++index;
-
- int oldBlen = blen;
- char c;
- while (!isTerminatorOrIDSeparator(c = next())) {
- if (oldBlen == blen) { // first, add hyphen
- hadCountry = true; // we have a country, let variant parsing know
- addSeparator();
- ++oldBlen; // increment past hyphen
- }
- append(Character.toUpperCase(c));
- }
- --index; // unget
-
- int charsAppended = blen - oldBlen;
-
- if (charsAppended == 0) {
- // Do nothing.
- }
- else if (charsAppended < 2 || charsAppended > 3) {
- // It's not a country, so return index and blen to
- // their previous values.
- index = oldIndex;
- --oldBlen;
- blen = oldBlen;
- hadCountry = false;
- }
- else if (charsAppended == 3) {
- String region = LocaleIDs.threeToTwoLetterRegion(getString(oldBlen));
- if (region != null) {
- set(oldBlen, region);
- }
- }
-
- return oldBlen;
- }
-
- return blen;
- }
-
- /**
- * Advance index past country.
- * Index must be immediately after the script (if there is one, else language)
- * and IDSeparator.
- */
- private void skipCountry() {
- if (!atTerminator()) {
- ++index;
- /*
- * Save the index point after the separator, since the format
- * requires two separators if the country is not present.
- */
- int oldIndex = index;
-
- skipUntilTerminatorOrIDSeparator();
- int charsSkipped = index - oldIndex;
- if (charsSkipped < 2 || charsSkipped > 3) {
- index = oldIndex;
- }
- }
- }
-
- /**
- * Advance index past variant, and accumulate normalized variant in buffer. This ignores
- * the codepage information from POSIX ids. Index must be immediately after the country
- * or script. Index is left at the keyword separator or at the end of the text. Return
- * the start of the variant code in the buffer.
- *
- * In standard form, we can have the following forms:
- * ll__VVVV
- * ll_CC_VVVV
- * ll_Ssss_VVVV
- * ll_Ssss_CC_VVVV
- *
- * This also handles POSIX ids, which can have the following forms (pppp is code page id):
- * ll_CC.pppp --> ll_CC
- * ll_CC.pppp@VVVV --> ll_CC_VVVV
- * ll_CC@VVVV --> ll_CC_VVVV
- *
- * We identify this use of '@' in POSIX ids by looking for an '=' following
- * the '@'. If there is one, we consider '@' to start a keyword list, instead of
- * being part of a POSIX id.
- *
- * Note: since it was decided that we want an option to not handle POSIX ids, this
- * becomes a bit more complex.
- */
- private int parseVariant() {
- int oldBlen = blen;
-
- boolean start = true;
- boolean needSeparator = true;
- boolean skipping = false;
- char c;
- while ((c = next()) != DONE) {
- if (c == DOT) {
- start = false;
- skipping = true;
- } else if (c == KEYWORD_SEPARATOR) {
- if (haveKeywordAssign()) {
- break;
- }
- skipping = false;
- start = false;
- needSeparator = true; // add another underscore if we have more text
- } else if (start) {
- start = false;
- } else if (!skipping) {
- if (needSeparator) {
- boolean incOldBlen = blen == oldBlen; // need to skip separators
- needSeparator = false;
- if (incOldBlen && !hadCountry) { // no country, we'll need two
- addSeparator();
- ++oldBlen; // for sure
- }
- addSeparator();
- if (incOldBlen) { // only for the first separator
- ++oldBlen;
- }
- }
- c = Character.toUpperCase(c);
- if (c == HYPHEN || c == COMMA) {
- c = UNDERSCORE;
- }
- append(c);
- }
- }
- --index; // unget
-
- return oldBlen;
- }
-
- // no need for skipvariant, to get the keywords we'll just scan directly for
- // the keyword separator
-
- /**
- * Returns the normalized language id, or the empty string.
- */
- public String getLanguage() {
- reset();
- return getString(parseLanguage());
- }
-
- /**
- * Returns the normalized script id, or the empty string.
- */
- public String getScript() {
- reset();
- skipLanguage();
- return getString(parseScript());
- }
-
- /**
- * return the normalized country id, or the empty string.
- */
- public String getCountry() {
- reset();
- skipLanguage();
- skipScript();
- return getString(parseCountry());
- }
-
- /**
- * Returns the normalized variant id, or the empty string.
- */
- public String getVariant() {
- reset();
- skipLanguage();
- skipScript();
- skipCountry();
- return getString(parseVariant());
- }
-
- /**
- * Returns the language, script, country, and variant as separate strings.
- */
- public String[] getLanguageScriptCountryVariant() {
- reset();
- return new String[] {
- getString(parseLanguage()),
- getString(parseScript()),
- getString(parseCountry()),
- getString(parseVariant())
- };
- }
-
- public void setBaseName(String baseName) {
- this.baseName = baseName;
- }
-
- public void parseBaseName() {
- if (baseName != null) {
- set(0, baseName);
- } else {
- reset();
- parseLanguage();
- parseScript();
- parseCountry();
- parseVariant();
-
- // catch unwanted trailing underscore after country if there was no variant
- if (blen > 1 && buffer[blen-1] == UNDERSCORE) {
- --blen;
- }
- }
- }
-
- /**
- * Returns the normalized base form of the locale id. The base
- * form does not include keywords.
- */
- public String getBaseName() {
- if (baseName != null) {
- return baseName;
- }
- parseBaseName();
- return getString(0);
- }
-
- /**
- * Returns the normalized full form of the locale id. The full
- * form includes keywords if they are present.
- */
- public String getName() {
- parseBaseName();
- parseKeywords();
- return getString(0);
- }
-
- // keyword utilities
-
- /**
- * If we have keywords, advance index to the start of the keywords and return true,
- * otherwise return false.
- */
- private boolean setToKeywordStart() {
- for (int i = index; i < id.length; ++i) {
- if (id[i] == KEYWORD_SEPARATOR) {
- if (canonicalize) {
- for (int j = ++i; j < id.length; ++j) { // increment i past separator for return
- if (id[j] == KEYWORD_ASSIGN) {
- index = i;
- return true;
- }
- }
- } else {
- if (++i < id.length) {
- index = i;
- return true;
- }
- }
- break;
- }
- }
- return false;
- }
-
- private static boolean isDoneOrKeywordAssign(char c) {
- return c == DONE || c == KEYWORD_ASSIGN;
- }
-
- private static boolean isDoneOrItemSeparator(char c) {
- return c == DONE || c == ITEM_SEPARATOR;
- }
-
- private String getKeyword() {
- int start = index;
- while (!isDoneOrKeywordAssign(next())) {
- }
- --index;
- return AsciiUtil.toLowerString(new String(id, start, index-start).trim());
- }
-
- private String getValue() {
- int start = index;
- while (!isDoneOrItemSeparator(next())) {
- }
- --index;
- return new String(id, start, index-start).trim(); // leave case alone
- }
-
- private Comparator getKeyComparator() {
- final Comparator comp = new Comparator() {
- public int compare(String lhs, String rhs) {
- return lhs.compareTo(rhs);
- }
- };
- return comp;
- }
-
- /**
- * Returns a map of the keywords and values, or null if there are none.
- */
- public Map getKeywordMap() {
- if (keywords == null) {
- TreeMap m = null;
- if (setToKeywordStart()) {
- // trim spaces and convert to lower case, both keywords and values.
- do {
- String key = getKeyword();
- if (key.length() == 0) {
- break;
- }
- char c = next();
- if (c != KEYWORD_ASSIGN) {
- // throw new IllegalArgumentException("key '" + key + "' missing a value.");
- if (c == DONE) {
- break;
- } else {
- continue;
- }
- }
- String value = getValue();
- if (value.length() == 0) {
- // throw new IllegalArgumentException("key '" + key + "' missing a value.");
- continue;
- }
- if (m == null) {
- m = new TreeMap(getKeyComparator());
- } else if (m.containsKey(key)) {
- // throw new IllegalArgumentException("key '" + key + "' already has a value.");
- continue;
- }
- m.put(key, value);
- } while (next() == ITEM_SEPARATOR);
- }
- keywords = m != null ? m : Collections.emptyMap();
- }
-
- return keywords;
- }
-
-
- /**
- * Parse the keywords and return start of the string in the buffer.
- */
- private int parseKeywords() {
- int oldBlen = blen;
- Map m = getKeywordMap();
- if (!m.isEmpty()) {
- boolean first = true;
- for (Map.Entry e : m.entrySet()) {
- append(first ? KEYWORD_SEPARATOR : ITEM_SEPARATOR);
- first = false;
- append(e.getKey());
- append(KEYWORD_ASSIGN);
- append(e.getValue());
- }
- if (blen != oldBlen) {
- ++oldBlen;
- }
- }
- return oldBlen;
- }
-
- /**
- * Returns an iterator over the keywords, or null if we have an empty map.
- */
- public Iterator getKeywords() {
- Map m = getKeywordMap();
- return m.isEmpty() ? null : m.keySet().iterator();
- }
-
- /**
- * Returns the value for the named keyword, or null if the keyword is not
- * present.
- */
- public String getKeywordValue(String keywordName) {
- Map m = getKeywordMap();
- return m.isEmpty() ? null : m.get(AsciiUtil.toLowerString(keywordName.trim()));
- }
-
- /**
- * Set the keyword value only if it is not already set to something else.
- */
- public void defaultKeywordValue(String keywordName, String value) {
- setKeywordValue(keywordName, value, false);
- }
-
- /**
- * Set the value for the named keyword, or unset it if value is null. If
- * keywordName itself is null, unset all keywords. If keywordName is not null,
- * value must not be null.
- */
- public void setKeywordValue(String keywordName, String value) {
- setKeywordValue(keywordName, value, true);
- }
-
- /**
- * Set the value for the named keyword, or unset it if value is null. If
- * keywordName itself is null, unset all keywords. If keywordName is not null,
- * value must not be null. If reset is true, ignore any previous value for
- * the keyword, otherwise do not change the keyword (including removal of
- * one or all keywords).
- */
- private void setKeywordValue(String keywordName, String value, boolean reset) {
- if (keywordName == null) {
- if (reset) {
- // force new map, ignore value
- keywords = Collections.emptyMap();
- }
- } else {
- keywordName = AsciiUtil.toLowerString(keywordName.trim());
- if (keywordName.length() == 0) {
- throw new IllegalArgumentException("keyword must not be empty");
- }
- if (value != null) {
- value = value.trim();
- if (value.length() == 0) {
- throw new IllegalArgumentException("value must not be empty");
- }
- }
- Map m = getKeywordMap();
- if (m.isEmpty()) { // it is EMPTY_MAP
- if (value != null) {
- // force new map
- keywords = new TreeMap(getKeyComparator());
- keywords.put(keywordName, value.trim());
- }
- } else {
- if (reset || !m.containsKey(keywordName)) {
- if (value != null) {
- m.put(keywordName, value);
- } else {
- m.remove(keywordName);
- if (m.isEmpty()) {
- // force new map
- keywords = Collections.emptyMap();
- }
- }
- }
- }
- }
- }
+/*
+******************************************************************************
+* Copyright (C) 2003-2011, International Business Machines Corporation and *
+* others. All Rights Reserved. *
+******************************************************************************
+*/
+
+package com.ibm.icu.impl;
+
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.TreeMap;
+
+import com.ibm.icu.impl.locale.AsciiUtil;
+
+/**
+ * Utility class to parse and normalize locale ids (including POSIX style)
+ */
+public final class LocaleIDParser {
+ private char[] id;
+ private int index;
+ private char[] buffer;
+ private int blen;
+ // um, don't handle POSIX ids unless we request it. why not? well... because.
+ private boolean canonicalize;
+ private boolean hadCountry;
+
+ // used when canonicalizing
+ Map keywords;
+ String baseName;
+
+ /**
+ * Parsing constants.
+ */
+ private static final char KEYWORD_SEPARATOR = '@';
+ private static final char HYPHEN = '-';
+ private static final char KEYWORD_ASSIGN = '=';
+ private static final char COMMA = ',';
+ private static final char ITEM_SEPARATOR = ';';
+ private static final char DOT = '.';
+ private static final char UNDERSCORE = '_';
+
+ public LocaleIDParser(String localeID) {
+ this(localeID, false);
+ }
+
+ public LocaleIDParser(String localeID, boolean canonicalize) {
+ id = localeID.toCharArray();
+ index = 0;
+ buffer = new char[id.length + 5];
+ blen = 0;
+ this.canonicalize = canonicalize;
+ }
+
+ private void reset() {
+ index = blen = 0;
+ }
+
+ // utilities for working on text in the buffer
+
+ /**
+ * Append c to the buffer.
+ */
+ private void append(char c) {
+ try {
+ buffer[blen] = c;
+ }
+ catch (IndexOutOfBoundsException e) {
+ if (buffer.length > 512) {
+ // something is seriously wrong, let this go
+ throw e;
+ }
+ char[] nbuffer = new char[buffer.length * 2];
+ System.arraycopy(buffer, 0, nbuffer, 0, buffer.length);
+ nbuffer[blen] = c;
+ buffer = nbuffer;
+ }
+ ++blen;
+ }
+
+ private void addSeparator() {
+ append(UNDERSCORE);
+ }
+
+ /**
+ * Returns the text in the buffer from start to blen as a String.
+ */
+ private String getString(int start) {
+ if (start == blen) {
+ return "";
+ }
+ return new String(buffer, start, blen-start);
+ }
+
+ /**
+ * Set the length of the buffer to pos, then append the string.
+ */
+ private void set(int pos, String s) {
+ this.blen = pos; // no safety
+ append(s);
+ }
+
+ /**
+ * Append the string to the buffer.
+ */
+ private void append(String s) {
+ for (int i = 0; i < s.length(); ++i) {
+ append(s.charAt(i));
+ }
+ }
+
+ // utilities for parsing text out of the id
+
+ /**
+ * Character to indicate no more text is available in the id.
+ */
+ private static final char DONE = '\uffff';
+
+ /**
+ * Returns the character at index in the id, and advance index. The returned character
+ * is DONE if index was at the limit of the buffer. The index is advanced regardless
+ * so that decrementing the index will always 'unget' the last character returned.
+ */
+ private char next() {
+ if (index == id.length) {
+ index++;
+ return DONE;
+ }
+
+ return id[index++];
+ }
+
+ /**
+ * Advance index until the next terminator or id separator, and leave it there.
+ */
+ private void skipUntilTerminatorOrIDSeparator() {
+ while (!isTerminatorOrIDSeparator(next())) {
+ }
+ --index;
+ }
+
+ /**
+ * Returns true if the character at index in the id is a terminator.
+ */
+ private boolean atTerminator() {
+ return index >= id.length || isTerminator(id[index]);
+ }
+
+ /*
+ * Returns true if the character is an id separator (underscore or hyphen).
+ */
+ /* private boolean isIDSeparator(char c) {
+ return c == UNDERSCORE || c == HYPHEN;
+ }*/
+
+ /**
+ * Returns true if the character is a terminator (keyword separator, dot, or DONE).
+ * Dot is a terminator because of the POSIX form, where dot precedes the codepage.
+ */
+ private boolean isTerminator(char c) {
+ // always terminate at DOT, even if not handling POSIX. It's an error...
+ return c == KEYWORD_SEPARATOR || c == DONE || c == DOT;
+ }
+
+ /**
+ * Returns true if the character is a terminator or id separator.
+ */
+ private boolean isTerminatorOrIDSeparator(char c) {
+ return c == KEYWORD_SEPARATOR || c == UNDERSCORE || c == HYPHEN ||
+ c == DONE || c == DOT;
+ }
+
+ /**
+ * Returns true if the start of the buffer has an experimental or private language
+ * prefix, the pattern '[ixIX][-_].' shows the syntax checked.
+ */
+ private boolean haveExperimentalLanguagePrefix() {
+ if (id.length > 2) {
+ char c = id[1];
+ if (c == HYPHEN || c == UNDERSCORE) {
+ c = id[0];
+ return c == 'x' || c == 'X' || c == 'i' || c == 'I';
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Returns true if a value separator occurs at or after index.
+ */
+ private boolean haveKeywordAssign() {
+ // assume it is safe to start from index
+ for (int i = index; i < id.length; ++i) {
+ if (id[i] == KEYWORD_ASSIGN) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Advance index past language, and accumulate normalized language code in buffer.
+ * Index must be at 0 when this is called. Index is left at a terminator or id
+ * separator. Returns the start of the language code in the buffer.
+ */
+ private int parseLanguage() {
+ if (haveExperimentalLanguagePrefix()) {
+ append(Character.toLowerCase(id[0]));
+ append(HYPHEN);
+ index = 2;
+ }
+
+ char c;
+ while(!isTerminatorOrIDSeparator(c = next())) {
+ append(Character.toLowerCase(c));
+ }
+ --index; // unget
+
+ if (blen == 3) {
+ String lang = LocaleIDs.threeToTwoLetterLanguage(getString(0));
+ if (lang != null) {
+ set(0, lang);
+ }
+ }
+
+ return 0;
+ }
+
+ /**
+ * Advance index past language. Index must be at 0 when this is called. Index
+ * is left at a terminator or id separator.
+ */
+ private void skipLanguage() {
+ if (haveExperimentalLanguagePrefix()) {
+ index = 2;
+ }
+ skipUntilTerminatorOrIDSeparator();
+ }
+
+ /**
+ * Advance index past script, and accumulate normalized script in buffer.
+ * Index must be immediately after the language.
+ * If the item at this position is not a script (is not four characters
+ * long) leave index and buffer unchanged. Otherwise index is left at
+ * a terminator or id separator. Returns the start of the script code
+ * in the buffer (this may be equal to the buffer length, if there is no
+ * script).
+ */
+ private int parseScript() {
+ if (!atTerminator()) {
+ int oldIndex = index; // save original index
+ ++index;
+
+ int oldBlen = blen; // get before append hyphen, if we truncate everything is undone
+ char c;
+ while(!isTerminatorOrIDSeparator(c = next())) {
+ if (blen == oldBlen) { // first pass
+ addSeparator();
+ append(Character.toUpperCase(c));
+ } else {
+ append(Character.toLowerCase(c));
+ }
+ }
+ --index; // unget
+
+ /* If it's not exactly 4 characters long, then it's not a script. */
+ if (index - oldIndex != 5) { // +1 to account for separator
+ index = oldIndex;
+ blen = oldBlen;
+ } else {
+ oldBlen++; // index past hyphen, for clients who want to extract just the script
+ }
+
+ return oldBlen;
+ }
+ return blen;
+ }
+
+ /**
+ * Advance index past script.
+ * Index must be immediately after the language and IDSeparator.
+ * If the item at this position is not a script (is not four characters
+ * long) leave index. Otherwise index is left at a terminator or
+ * id separator.
+ */
+ private void skipScript() {
+ if (!atTerminator()) {
+ int oldIndex = index;
+ ++index;
+
+ skipUntilTerminatorOrIDSeparator();
+ if (index - oldIndex != 5) { // +1 to account for separator
+ index = oldIndex;
+ }
+ }
+ }
+
+ /**
+ * Advance index past country, and accumulate normalized country in buffer.
+ * Index must be immediately after the script (if there is one, else language)
+ * and IDSeparator. Return the start of the country code in the buffer.
+ */
+ private int parseCountry() {
+ if (!atTerminator()) {
+ int oldIndex = index;
+ ++index;
+
+ int oldBlen = blen;
+ char c;
+ while (!isTerminatorOrIDSeparator(c = next())) {
+ if (oldBlen == blen) { // first, add hyphen
+ hadCountry = true; // we have a country, let variant parsing know
+ addSeparator();
+ ++oldBlen; // increment past hyphen
+ }
+ append(Character.toUpperCase(c));
+ }
+ --index; // unget
+
+ int charsAppended = blen - oldBlen;
+
+ if (charsAppended == 0) {
+ // Do nothing.
+ }
+ else if (charsAppended < 2 || charsAppended > 3) {
+ // It's not a country, so return index and blen to
+ // their previous values.
+ index = oldIndex;
+ --oldBlen;
+ blen = oldBlen;
+ hadCountry = false;
+ }
+ else if (charsAppended == 3) {
+ String region = LocaleIDs.threeToTwoLetterRegion(getString(oldBlen));
+ if (region != null) {
+ set(oldBlen, region);
+ }
+ }
+
+ return oldBlen;
+ }
+
+ return blen;
+ }
+
+ /**
+ * Advance index past country.
+ * Index must be immediately after the script (if there is one, else language)
+ * and IDSeparator.
+ */
+ private void skipCountry() {
+ if (!atTerminator()) {
+ ++index;
+ /*
+ * Save the index point after the separator, since the format
+ * requires two separators if the country is not present.
+ */
+ int oldIndex = index;
+
+ skipUntilTerminatorOrIDSeparator();
+ int charsSkipped = index - oldIndex;
+ if (charsSkipped < 2 || charsSkipped > 3) {
+ index = oldIndex;
+ }
+ }
+ }
+
+ /**
+ * Advance index past variant, and accumulate normalized variant in buffer. This ignores
+ * the codepage information from POSIX ids. Index must be immediately after the country
+ * or script. Index is left at the keyword separator or at the end of the text. Return
+ * the start of the variant code in the buffer.
+ *
+ * In standard form, we can have the following forms:
+ * ll__VVVV
+ * ll_CC_VVVV
+ * ll_Ssss_VVVV
+ * ll_Ssss_CC_VVVV
+ *
+ * This also handles POSIX ids, which can have the following forms (pppp is code page id):
+ * ll_CC.pppp --> ll_CC
+ * ll_CC.pppp@VVVV --> ll_CC_VVVV
+ * ll_CC@VVVV --> ll_CC_VVVV
+ *
+ * We identify this use of '@' in POSIX ids by looking for an '=' following
+ * the '@'. If there is one, we consider '@' to start a keyword list, instead of
+ * being part of a POSIX id.
+ *
+ * Note: since it was decided that we want an option to not handle POSIX ids, this
+ * becomes a bit more complex.
+ */
+ private int parseVariant() {
+ int oldBlen = blen;
+
+ boolean start = true;
+ boolean needSeparator = true;
+ boolean skipping = false;
+ char c;
+ while ((c = next()) != DONE) {
+ if (c == DOT) {
+ start = false;
+ skipping = true;
+ } else if (c == KEYWORD_SEPARATOR) {
+ if (haveKeywordAssign()) {
+ break;
+ }
+ skipping = false;
+ start = false;
+ needSeparator = true; // add another underscore if we have more text
+ } else if (start) {
+ start = false;
+ } else if (!skipping) {
+ if (needSeparator) {
+ boolean incOldBlen = blen == oldBlen; // need to skip separators
+ needSeparator = false;
+ if (incOldBlen && !hadCountry) { // no country, we'll need two
+ addSeparator();
+ ++oldBlen; // for sure
+ }
+ addSeparator();
+ if (incOldBlen) { // only for the first separator
+ ++oldBlen;
+ }
+ }
+ c = Character.toUpperCase(c);
+ if (c == HYPHEN || c == COMMA) {
+ c = UNDERSCORE;
+ }
+ append(c);
+ }
+ }
+ --index; // unget
+
+ return oldBlen;
+ }
+
+ // no need for skipvariant, to get the keywords we'll just scan directly for
+ // the keyword separator
+
+ /**
+ * Returns the normalized language id, or the empty string.
+ */
+ public String getLanguage() {
+ reset();
+ return getString(parseLanguage());
+ }
+
+ /**
+ * Returns the normalized script id, or the empty string.
+ */
+ public String getScript() {
+ reset();
+ skipLanguage();
+ return getString(parseScript());
+ }
+
+ /**
+ * return the normalized country id, or the empty string.
+ */
+ public String getCountry() {
+ reset();
+ skipLanguage();
+ skipScript();
+ return getString(parseCountry());
+ }
+
+ /**
+ * Returns the normalized variant id, or the empty string.
+ */
+ public String getVariant() {
+ reset();
+ skipLanguage();
+ skipScript();
+ skipCountry();
+ return getString(parseVariant());
+ }
+
+ /**
+ * Returns the language, script, country, and variant as separate strings.
+ */
+ public String[] getLanguageScriptCountryVariant() {
+ reset();
+ return new String[] {
+ getString(parseLanguage()),
+ getString(parseScript()),
+ getString(parseCountry()),
+ getString(parseVariant())
+ };
+ }
+
+ public void setBaseName(String baseName) {
+ this.baseName = baseName;
+ }
+
+ public void parseBaseName() {
+ if (baseName != null) {
+ set(0, baseName);
+ } else {
+ reset();
+ parseLanguage();
+ parseScript();
+ parseCountry();
+ parseVariant();
+
+ // catch unwanted trailing underscore after country if there was no variant
+ if (blen > 1 && buffer[blen-1] == UNDERSCORE) {
+ --blen;
+ }
+ }
+ }
+
+ /**
+ * Returns the normalized base form of the locale id. The base
+ * form does not include keywords.
+ */
+ public String getBaseName() {
+ if (baseName != null) {
+ return baseName;
+ }
+ parseBaseName();
+ return getString(0);
+ }
+
+ /**
+ * Returns the normalized full form of the locale id. The full
+ * form includes keywords if they are present.
+ */
+ public String getName() {
+ parseBaseName();
+ parseKeywords();
+ return getString(0);
+ }
+
+ // keyword utilities
+
+ /**
+ * If we have keywords, advance index to the start of the keywords and return true,
+ * otherwise return false.
+ */
+ private boolean setToKeywordStart() {
+ for (int i = index; i < id.length; ++i) {
+ if (id[i] == KEYWORD_SEPARATOR) {
+ if (canonicalize) {
+ for (int j = ++i; j < id.length; ++j) { // increment i past separator for return
+ if (id[j] == KEYWORD_ASSIGN) {
+ index = i;
+ return true;
+ }
+ }
+ } else {
+ if (++i < id.length) {
+ index = i;
+ return true;
+ }
+ }
+ break;
+ }
+ }
+ return false;
+ }
+
+ private static boolean isDoneOrKeywordAssign(char c) {
+ return c == DONE || c == KEYWORD_ASSIGN;
+ }
+
+ private static boolean isDoneOrItemSeparator(char c) {
+ return c == DONE || c == ITEM_SEPARATOR;
+ }
+
+ private String getKeyword() {
+ int start = index;
+ while (!isDoneOrKeywordAssign(next())) {
+ }
+ --index;
+ return AsciiUtil.toLowerString(new String(id, start, index-start).trim());
+ }
+
+ private String getValue() {
+ int start = index;
+ while (!isDoneOrItemSeparator(next())) {
+ }
+ --index;
+ return new String(id, start, index-start).trim(); // leave case alone
+ }
+
+ private Comparator getKeyComparator() {
+ final Comparator comp = new Comparator() {
+ public int compare(String lhs, String rhs) {
+ return lhs.compareTo(rhs);
+ }
+ };
+ return comp;
+ }
+
+ /**
+ * Returns a map of the keywords and values, or null if there are none.
+ */
+ public Map getKeywordMap() {
+ if (keywords == null) {
+ TreeMap m = null;
+ if (setToKeywordStart()) {
+ // trim spaces and convert to lower case, both keywords and values.
+ do {
+ String key = getKeyword();
+ if (key.length() == 0) {
+ break;
+ }
+ char c = next();
+ if (c != KEYWORD_ASSIGN) {
+ // throw new IllegalArgumentException("key '" + key + "' missing a value.");
+ if (c == DONE) {
+ break;
+ } else {
+ continue;
+ }
+ }
+ String value = getValue();
+ if (value.length() == 0) {
+ // throw new IllegalArgumentException("key '" + key + "' missing a value.");
+ continue;
+ }
+ if (m == null) {
+ m = new TreeMap(getKeyComparator());
+ } else if (m.containsKey(key)) {
+ // throw new IllegalArgumentException("key '" + key + "' already has a value.");
+ continue;
+ }
+ m.put(key, value);
+ } while (next() == ITEM_SEPARATOR);
+ }
+ keywords = m != null ? m : Collections.emptyMap();
+ }
+
+ return keywords;
+ }
+
+
+ /**
+ * Parse the keywords and return start of the string in the buffer.
+ */
+ private int parseKeywords() {
+ int oldBlen = blen;
+ Map m = getKeywordMap();
+ if (!m.isEmpty()) {
+ boolean first = true;
+ for (Map.Entry e : m.entrySet()) {
+ append(first ? KEYWORD_SEPARATOR : ITEM_SEPARATOR);
+ first = false;
+ append(e.getKey());
+ append(KEYWORD_ASSIGN);
+ append(e.getValue());
+ }
+ if (blen != oldBlen) {
+ ++oldBlen;
+ }
+ }
+ return oldBlen;
+ }
+
+ /**
+ * Returns an iterator over the keywords, or null if we have an empty map.
+ */
+ public Iterator getKeywords() {
+ Map m = getKeywordMap();
+ return m.isEmpty() ? null : m.keySet().iterator();
+ }
+
+ /**
+ * Returns the value for the named keyword, or null if the keyword is not
+ * present.
+ */
+ public String getKeywordValue(String keywordName) {
+ Map m = getKeywordMap();
+ return m.isEmpty() ? null : m.get(AsciiUtil.toLowerString(keywordName.trim()));
+ }
+
+ /**
+ * Set the keyword value only if it is not already set to something else.
+ */
+ public void defaultKeywordValue(String keywordName, String value) {
+ setKeywordValue(keywordName, value, false);
+ }
+
+ /**
+ * Set the value for the named keyword, or unset it if value is null. If
+ * keywordName itself is null, unset all keywords. If keywordName is not null,
+ * value must not be null.
+ */
+ public void setKeywordValue(String keywordName, String value) {
+ setKeywordValue(keywordName, value, true);
+ }
+
+ /**
+ * Set the value for the named keyword, or unset it if value is null. If
+ * keywordName itself is null, unset all keywords. If keywordName is not null,
+ * value must not be null. If reset is true, ignore any previous value for
+ * the keyword, otherwise do not change the keyword (including removal of
+ * one or all keywords).
+ */
+ private void setKeywordValue(String keywordName, String value, boolean reset) {
+ if (keywordName == null) {
+ if (reset) {
+ // force new map, ignore value
+ keywords = Collections.emptyMap();
+ }
+ } else {
+ keywordName = AsciiUtil.toLowerString(keywordName.trim());
+ if (keywordName.length() == 0) {
+ throw new IllegalArgumentException("keyword must not be empty");
+ }
+ if (value != null) {
+ value = value.trim();
+ if (value.length() == 0) {
+ throw new IllegalArgumentException("value must not be empty");
+ }
+ }
+ Map m = getKeywordMap();
+ if (m.isEmpty()) { // it is EMPTY_MAP
+ if (value != null) {
+ // force new map
+ keywords = new TreeMap(getKeyComparator());
+ keywords.put(keywordName, value.trim());
+ }
+ } else {
+ if (reset || !m.containsKey(keywordName)) {
+ if (value != null) {
+ m.put(keywordName, value);
+ } else {
+ m.remove(keywordName);
+ if (m.isEmpty()) {
+ // force new map
+ keywords = Collections.emptyMap();
+ }
+ }
+ }
+ }
+ }
+ }
}
\ No newline at end of file
diff --git a/icu4j/eclipse-build/plugins.template/com.ibm.icu.base/src/com/ibm/icu/impl/LocaleIDs.java b/icu4j/eclipse-build/plugins.template/com.ibm.icu.base/src/com/ibm/icu/impl/LocaleIDs.java
index 8edd3d48003..34c0a5b26d6 100644
--- a/icu4j/eclipse-build/plugins.template/com.ibm.icu.base/src/com/ibm/icu/impl/LocaleIDs.java
+++ b/icu4j/eclipse-build/plugins.template/com.ibm.icu.base/src/com/ibm/icu/impl/LocaleIDs.java
@@ -1,536 +1,536 @@
-/*
- *******************************************************************************
- * Copyright (C) 2009-2011, International Business Machines Corporation and *
- * others. All Rights Reserved. *
- *******************************************************************************
- */
-package com.ibm.icu.impl;
-
-import java.util.MissingResourceException;
-
-import com.ibm.icu.util.ULocale;
-
-
-/**
- * Utilities for mapping between old and new language, country, and other
- * locale ID related names.
- */
-public class LocaleIDs {
-
- /**
- * Returns a list of all 2-letter country codes defined in ISO 3166.
- * Can be used to create Locales.
- * @stable ICU 3.0
- */
- public static String[] getISOCountries() {
- initCountryTables();
- return _countries.clone();
- }
-
- /**
- * Returns a list of all 2-letter language codes defined in ISO 639.
- * Can be used to create Locales.
- * [NOTE: ISO 639 is not a stable standard-- some languages' codes have changed.
- * The list this function returns includes both the new and the old codes for the
- * languages whose codes have changed.]
- * @stable ICU 3.0
- */
- public static String[] getISOLanguages() {
- initLanguageTables();
- return _languages.clone();
- }
-
- /**
- * Returns a three-letter abbreviation for the provided country. If the provided
- * country is empty, returns the empty string. Otherwise, returns
- * an uppercase ISO 3166 3-letter country code.
- * @exception MissingResourceException Throws MissingResourceException if the
- * three-letter country abbreviation is not available for this locale.
- * @stable ICU 3.0
- */
- public static String getISO3Country(String country){
- initCountryTables();
-
- int offset = findIndex(_countries, country);
- if(offset>=0){
- return _countries3[offset];
- }else{
- offset = findIndex(_obsoleteCountries, country);
- if(offset>=0){
- return _obsoleteCountries3[offset];
- }
- }
- return "";
- }
- /**
- * Returns a three-letter abbreviation for the language. If language is
- * empty, returns the empty string. Otherwise, returns
- * a lowercase ISO 639-2/T language code.
- * The ISO 639-2 language codes can be found on-line at
- * ftp://dkuug.dk/i18n/iso-639-2.txt
- * @exception MissingResourceException Throws MissingResourceException if the
- * three-letter language abbreviation is not available for this locale.
- * @stable ICU 3.0
- */
- public static String getISO3Language(String language) {
- initLanguageTables();
-
- int offset = findIndex(_languages, language);
- if(offset>=0){
- return _languages3[offset];
- } else {
- offset = findIndex(_obsoleteLanguages, language);
- if (offset >= 0) {
- return _obsoleteLanguages3[offset];
- }
- }
- return "";
- }
-
- public static String threeToTwoLetterLanguage(String lang) {
- initLanguageTables();
-
- /* convert 3 character code to 2 character code if possible *CWB*/
- int offset = findIndex(_languages3, lang);
- if (offset >= 0) {
- return _languages[offset];
- }
-
- offset = findIndex(_obsoleteLanguages3, lang);
- if (offset >= 0) {
- return _obsoleteLanguages[offset];
- }
-
- return null;
- }
-
- public static String threeToTwoLetterRegion(String region) {
- initCountryTables();
-
- /* convert 3 character code to 2 character code if possible *CWB*/
- int offset = findIndex(_countries3, region);
- if (offset >= 0) {
- return _countries[offset];
- }
-
- offset = findIndex(_obsoleteCountries3, region);
- if (offset >= 0) {
- return _obsoleteCountries[offset];
- }
-
- return null;
- }
-
- /**
- * linear search of the string array. the arrays are unfortunately ordered by the
- * two-letter target code, not the three-letter search code, which seems backwards.
- */
- private static int findIndex(String[] array, String target){
- for (int i = 0; i < array.length; i++) {
- if (target.equals(array[i])) {
- return i;
- }
- }
- return -1;
- }
-
-
- /**
- * Tables used in normalizing portions of the id.
- */
- /* tables updated per http://lcweb.loc.gov/standards/iso639-2/
- to include the revisions up to 2001/7/27 *CWB*/
- /* The 3 character codes are the terminology codes like RFC 3066.
- This is compatible with prior ICU codes */
- /* "in" "iw" "ji" "jw" & "sh" have been withdrawn but are still in
- the table but now at the end of the table because
- 3 character codes are duplicates. This avoids bad searches
- going from 3 to 2 character codes.*/
- /* The range qaa-qtz is reserved for local use. */
-
- private static String[] _languages;
- private static String[] _replacementLanguages;
- private static String[] _obsoleteLanguages;
- private static String[] _languages3;
- private static String[] _obsoleteLanguages3;
-
- // Avoid initializing languages tables unless we have to.
- private static void initLanguageTables() {
- if (_languages == null) {
-
- /* This list MUST be in sorted order, and MUST contain the two-letter codes
- if one exists otherwise use the three letter code */
- String[] tempLanguages = {
- "aa", "ab", "ace", "ach", "ada", "ady", "ae", "af", "afa",
- "afh", "ak", "akk", "ale", "alg", "am", "an", "ang", "apa",
- "ar", "arc", "arn", "arp", "art", "arw", "as", "ast",
- "ath", "aus", "av", "awa", "ay", "az", "ba", "bad",
- "bai", "bal", "ban", "bas", "bat", "be", "bej",
- "bem", "ber", "bg", "bh", "bho", "bi", "bik", "bin",
- "bla", "bm", "bn", "bnt", "bo", "br", "bra", "bs",
- "btk", "bua", "bug", "byn", "ca", "cad", "cai", "car", "cau",
- "ce", "ceb", "cel", "ch", "chb", "chg", "chk", "chm",
- "chn", "cho", "chp", "chr", "chy", "cmc", "co", "cop",
- "cpe", "cpf", "cpp", "cr", "crh", "crp", "cs", "csb", "cu", "cus",
- "cv", "cy", "da", "dak", "dar", "day", "de", "del", "den",
- "dgr", "din", "doi", "dra", "dsb", "dua", "dum", "dv", "dyu",
- "dz", "ee", "efi", "egy", "eka", "el", "elx", "en",
- "enm", "eo", "es", "et", "eu", "ewo", "fa",
- "fan", "fat", "ff", "fi", "fiu", "fj", "fo", "fon",
- "fr", "frm", "fro", "fur", "fy", "ga", "gaa", "gay",
- "gba", "gd", "gem", "gez", "gil", "gl", "gmh", "gn",
- "goh", "gon", "gor", "got", "grb", "grc", "gu", "gv",
- "gwi", "ha", "hai", "haw", "he", "hi", "hil", "him",
- "hit", "hmn", "ho", "hr", "hsb", "ht", "hu", "hup", "hy", "hz",
- "ia", "iba", "id", "ie", "ig", "ii", "ijo", "ik",
- "ilo", "inc", "ine", "inh", "io", "ira", "iro", "is", "it",
- "iu", "ja", "jbo", "jpr", "jrb", "jv", "ka", "kaa", "kab",
- "kac", "kam", "kar", "kaw", "kbd", "kg", "kha", "khi",
- "kho", "ki", "kj", "kk", "kl", "km", "kmb", "kn",
- "ko", "kok", "kos", "kpe", "kr", "krc", "kro", "kru", "ks",
- "ku", "kum", "kut", "kv", "kw", "ky", "la", "lad",
- "lah", "lam", "lb", "lez", "lg", "li", "ln", "lo", "lol",
- "loz", "lt", "lu", "lua", "lui", "lun", "luo", "lus",
- "lv", "mad", "mag", "mai", "mak", "man", "map", "mas",
- "mdf", "mdr", "men", "mg", "mga", "mh", "mi", "mic", "min",
- "mis", "mk", "mkh", "ml", "mn", "mnc", "mni", "mno",
- "mo", "moh", "mos", "mr", "ms", "mt", "mul", "mun",
- "mus", "mwr", "my", "myn", "myv", "na", "nah", "nai", "nap",
- "nb", "nd", "nds", "ne", "new", "ng", "nia", "nic",
- "niu", "nl", "nn", "no", "nog", "non", "nr", "nso", "nub",
- "nv", "nwc", "ny", "nym", "nyn", "nyo", "nzi", "oc", "oj",
- "om", "or", "os", "osa", "ota", "oto", "pa", "paa",
- "pag", "pal", "pam", "pap", "pau", "peo", "phi", "phn",
- "pi", "pl", "pon", "pra", "pro", "ps", "pt", "qu",
- "raj", "rap", "rar", "rm", "rn", "ro", "roa", "rom",
- "ru", "rup", "rw", "sa", "sad", "sah", "sai", "sal", "sam",
- "sas", "sat", "sc", "sco", "sd", "se", "sel", "sem",
- "sg", "sga", "sgn", "shn", "si", "sid", "sio", "sit",
- "sk", "sl", "sla", "sm", "sma", "smi", "smj", "smn",
- "sms", "sn", "snk", "so", "sog", "son", "sq", "sr",
- "srr", "ss", "ssa", "st", "su", "suk", "sus", "sux",
- "sv", "sw", "syr", "ta", "tai", "te", "tem", "ter",
- "tet", "tg", "th", "ti", "tig", "tiv", "tk", "tkl",
- "tl", "tlh", "tli", "tmh", "tn", "to", "tog", "tpi", "tr",
- "ts", "tsi", "tt", "tum", "tup", "tut", "tvl", "tw",
- "ty", "tyv", "udm", "ug", "uga", "uk", "umb", "und", "ur",
- "uz", "vai", "ve", "vi", "vo", "vot", "wa", "wak",
- "wal", "war", "was", "wen", "wo", "xal", "xh", "yao", "yap",
- "yi", "yo", "ypk", "za", "zap", "zen", "zh", "znd",
- "zu", "zun",
- };
-
- String[] tempReplacementLanguages = {
- "id", "he", "yi", "jv", "sr", "nb",/* replacement language codes */
- };
-
- String[] tempObsoleteLanguages = {
- "in", "iw", "ji", "jw", "sh", "no", /* obsolete language codes */
- };
-
- /* This list MUST contain a three-letter code for every two-letter code in the
- list above, and they MUST ne in the same order (i.e., the same language must
- be in the same place in both lists)! */
- String[] tempLanguages3 = {
- /*"aa", "ab", "ace", "ach", "ada", "ady", "ae", "af", "afa", */
- "aar", "abk", "ace", "ach", "ada", "ady", "ave", "afr", "afa",
- /*"afh", "ak", "akk", "ale", "alg", "am", "an", "ang", "apa", */
- "afh", "aka", "akk", "ale", "alg", "amh", "arg", "ang", "apa",
- /*"ar", "arc", "arn", "arp", "art", "arw", "as", "ast", */
- "ara", "arc", "arn", "arp", "art", "arw", "asm", "ast",
- /*"ath", "aus", "av", "awa", "ay", "az", "ba", "bad", */
- "ath", "aus", "ava", "awa", "aym", "aze", "bak", "bad",
- /*"bai", "bal", "ban", "bas", "bat", "be", "bej", */
- "bai", "bal", "ban", "bas", "bat", "bel", "bej",
- /*"bem", "ber", "bg", "bh", "bho", "bi", "bik", "bin", */
- "bem", "ber", "bul", "bih", "bho", "bis", "bik", "bin",
- /*"bla", "bm", "bn", "bnt", "bo", "br", "bra", "bs", */
- "bla", "bam", "ben", "bnt", "bod", "bre", "bra", "bos",
- /*"btk", "bua", "bug", "byn", "ca", "cad", "cai", "car", "cau", */
- "btk", "bua", "bug", "byn", "cat", "cad", "cai", "car", "cau",
- /*"ce", "ceb", "cel", "ch", "chb", "chg", "chk", "chm", */
- "che", "ceb", "cel", "cha", "chb", "chg", "chk", "chm",
- /*"chn", "cho", "chp", "chr", "chy", "cmc", "co", "cop", */
- "chn", "cho", "chp", "chr", "chy", "cmc", "cos", "cop",
- /*"cpe", "cpf", "cpp", "cr", "crh", "crp", "cs", "csb", "cu", "cus", */
- "cpe", "cpf", "cpp", "cre", "crh", "crp", "ces", "csb", "chu", "cus",
- /*"cv", "cy", "da", "dak", "dar", "day", "de", "del", "den", */
- "chv", "cym", "dan", "dak", "dar", "day", "deu", "del", "den",
- /*"dgr", "din", "doi", "dra", "dsb", "dua", "dum", "dv", "dyu", */
- "dgr", "din", "doi", "dra", "dsb", "dua", "dum", "div", "dyu",
- /*"dz", "ee", "efi", "egy", "eka", "el", "elx", "en", */
- "dzo", "ewe", "efi", "egy", "eka", "ell", "elx", "eng",
- /*"enm", "eo", "es", "et", "eu", "ewo", "fa", */
- "enm", "epo", "spa", "est", "eus", "ewo", "fas",
- /*"fan", "fat", "ff", "fi", "fiu", "fj", "fo", "fon", */
- "fan", "fat", "ful", "fin", "fiu", "fij", "fao", "fon",
- /*"fr", "frm", "fro", "fur", "fy", "ga", "gaa", "gay", */
- "fra", "frm", "fro", "fur", "fry", "gle", "gaa", "gay",
- /*"gba", "gd", "gem", "gez", "gil", "gl", "gmh", "gn", */
- "gba", "gla", "gem", "gez", "gil", "glg", "gmh", "grn",
- /*"goh", "gon", "gor", "got", "grb", "grc", "gu", "gv", */
- "goh", "gon", "gor", "got", "grb", "grc", "guj", "glv",
- /*"gwi", "ha", "hai", "haw", "he", "hi", "hil", "him", */
- "gwi", "hau", "hai", "haw", "heb", "hin", "hil", "him",
- /*"hit", "hmn", "ho", "hr", "hsb", "ht", "hu", "hup", "hy", "hz", */
- "hit", "hmn", "hmo", "hrv", "hsb", "hat", "hun", "hup", "hye", "her",
- /*"ia", "iba", "id", "ie", "ig", "ii", "ijo", "ik", */
- "ina", "iba", "ind", "ile", "ibo", "iii", "ijo", "ipk",
- /*"ilo", "inc", "ine", "inh", "io", "ira", "iro", "is", "it", */
- "ilo", "inc", "ine", "inh", "ido", "ira", "iro", "isl", "ita",
- /*"iu", "ja", "jbo", "jpr", "jrb", "jv", "ka", "kaa", "kab", */
- "iku", "jpn", "jbo", "jpr", "jrb", "jaw", "kat", "kaa", "kab",
- /*"kac", "kam", "kar", "kaw", "kbd", "kg", "kha", "khi", */
- "kac", "kam", "kar", "kaw", "kbd", "kon", "kha", "khi",
- /*"kho", "ki", "kj", "kk", "kl", "km", "kmb", "kn", */
- "kho", "kik", "kua", "kaz", "kal", "khm", "kmb", "kan",
- /*"ko", "kok", "kos", "kpe", "kr", "krc", "kro", "kru", "ks", */
- "kor", "kok", "kos", "kpe", "kau", "krc", "kro", "kru", "kas",
- /*"ku", "kum", "kut", "kv", "kw", "ky", "la", "lad", */
- "kur", "kum", "kut", "kom", "cor", "kir", "lat", "lad",
- /*"lah", "lam", "lb", "lez", "lg", "li", "ln", "lo", "lol", */
- "lah", "lam", "ltz", "lez", "lug", "lim", "lin", "lao", "lol",
- /*"loz", "lt", "lu", "lua", "lui", "lun", "luo", "lus", */
- "loz", "lit", "lub", "lua", "lui", "lun", "luo", "lus",
- /*"lv", "mad", "mag", "mai", "mak", "man", "map", "mas", */
- "lav", "mad", "mag", "mai", "mak", "man", "map", "mas",
- /*"mdf", "mdr", "men", "mg", "mga", "mh", "mi", "mic", "min", */
- "mdf", "mdr", "men", "mlg", "mga", "mah", "mri", "mic", "min",
- /*"mis", "mk", "mkh", "ml", "mn", "mnc", "mni", "mno", */
- "mis", "mkd", "mkh", "mal", "mon", "mnc", "mni", "mno",
- /*"mo", "moh", "mos", "mr", "ms", "mt", "mul", "mun", */
- "mol", "moh", "mos", "mar", "msa", "mlt", "mul", "mun",
- /*"mus", "mwr", "my", "myn", "myv", "na", "nah", "nai", "nap", */
- "mus", "mwr", "mya", "myn", "myv", "nau", "nah", "nai", "nap",
- /*"nb", "nd", "nds", "ne", "new", "ng", "nia", "nic", */
- "nob", "nde", "nds", "nep", "new", "ndo", "nia", "nic",
- /*"niu", "nl", "nn", "no", "nog", "non", "nr", "nso", "nub", */
- "niu", "nld", "nno", "nor", "nog", "non", "nbl", "nso", "nub",
- /*"nv", "nwc", "ny", "nym", "nyn", "nyo", "nzi", "oc", "oj", */
- "nav", "nwc", "nya", "nym", "nyn", "nyo", "nzi", "oci", "oji",
- /*"om", "or", "os", "osa", "ota", "oto", "pa", "paa", */
- "orm", "ori", "oss", "osa", "ota", "oto", "pan", "paa",
- /*"pag", "pal", "pam", "pap", "pau", "peo", "phi", "phn", */
- "pag", "pal", "pam", "pap", "pau", "peo", "phi", "phn",
- /*"pi", "pl", "pon", "pra", "pro", "ps", "pt", "qu", */
- "pli", "pol", "pon", "pra", "pro", "pus", "por", "que",
- /*"raj", "rap", "rar", "rm", "rn", "ro", "roa", "rom", */
- "raj", "rap", "rar", "roh", "run", "ron", "roa", "rom",
- /*"ru", "rup", "rw", "sa", "sad", "sah", "sai", "sal", "sam", */
- "rus", "rup", "kin", "san", "sad", "sah", "sai", "sal", "sam",
- /*"sas", "sat", "sc", "sco", "sd", "se", "sel", "sem", */
- "sas", "sat", "srd", "sco", "snd", "sme", "sel", "sem",
- /*"sg", "sga", "sgn", "shn", "si", "sid", "sio", "sit", */
- "sag", "sga", "sgn", "shn", "sin", "sid", "sio", "sit",
- /*"sk", "sl", "sla", "sm", "sma", "smi", "smj", "smn", */
- "slk", "slv", "sla", "smo", "sma", "smi", "smj", "smn",
- /*"sms", "sn", "snk", "so", "sog", "son", "sq", "sr", */
- "sms", "sna", "snk", "som", "sog", "son", "sqi", "srp",
- /*"srr", "ss", "ssa", "st", "su", "suk", "sus", "sux", */
- "srr", "ssw", "ssa", "sot", "sun", "suk", "sus", "sux",
- /*"sv", "sw", "syr", "ta", "tai", "te", "tem", "ter", */
- "swe", "swa", "syr", "tam", "tai", "tel", "tem", "ter",
- /*"tet", "tg", "th", "ti", "tig", "tiv", "tk", "tkl", */
- "tet", "tgk", "tha", "tir", "tig", "tiv", "tuk", "tkl",
- /*"tl", "tlh", "tli", "tmh", "tn", "to", "tog", "tpi", "tr", */
- "tgl", "tlh", "tli", "tmh", "tsn", "ton", "tog", "tpi", "tur",
- /*"ts", "tsi", "tt", "tum", "tup", "tut", "tvl", "tw", */
- "tso", "tsi", "tat", "tum", "tup", "tut", "tvl", "twi",
- /*"ty", "tyv", "udm", "ug", "uga", "uk", "umb", "und", "ur", */
- "tah", "tyv", "udm", "uig", "uga", "ukr", "umb", "und", "urd",
- /*"uz", "vai", "ve", "vi", "vo", "vot", "wa", "wak", */
- "uzb", "vai", "ven", "vie", "vol", "vot", "wln", "wak",
- /*"wal", "war", "was", "wen", "wo", "xal", "xh", "yao", "yap", */
- "wal", "war", "was", "wen", "wol", "xal", "xho", "yao", "yap",
- /*"yi", "yo", "ypk", "za", "zap", "zen", "zh", "znd", */
- "yid", "yor", "ypk", "zha", "zap", "zen", "zho", "znd",
- /*"zu", "zun", */
- "zul", "zun",
- };
-
- String[] tempObsoleteLanguages3 = {
- /* "in", "iw", "ji", "jw", "sh", */
- "ind", "heb", "yid", "jaw", "srp",
- };
-
- synchronized (ULocale.class) {
- if (_languages == null) {
- _languages = tempLanguages;
- _replacementLanguages = tempReplacementLanguages;
- _obsoleteLanguages = tempObsoleteLanguages;
- _languages3 = tempLanguages3;
- _obsoleteLanguages3 = tempObsoleteLanguages3;
- }
- }
- }
- }
-
- private static String[] _countries;
- private static String[] _deprecatedCountries;
- private static String[] _replacementCountries;
- private static String[] _obsoleteCountries;
- private static String[] _countries3;
- private static String[] _obsoleteCountries3;
-
- // Avoid initializing country tables unless we have to.
- private static void initCountryTables() {
- if (_countries == null) {
- /* ZR(ZAR) is now CD(COD) and FX(FXX) is PS(PSE) as per
- http://www.evertype.com/standards/iso3166/iso3166-1-en.html
- added new codes keeping the old ones for compatibility
- updated to include 1999/12/03 revisions *CWB*/
-
- /* RO(ROM) is now RO(ROU) according to
- http://www.iso.org/iso/en/prods-services/iso3166ma/03updates-on-iso-3166/nlv3e-rou.html
- */
-
- /* This list MUST be in sorted order, and MUST contain only two-letter codes! */
- String[] tempCountries = {
- "AD", "AE", "AF", "AG", "AI", "AL", "AM", "AN",
- "AO", "AQ", "AR", "AS", "AT", "AU", "AW", "AX", "AZ",
- "BA", "BB", "BD", "BE", "BF", "BG", "BH", "BI",
- "BJ", "BL", "BM", "BN", "BO", "BR", "BS", "BT", "BV",
- "BW", "BY", "BZ", "CA", "CC", "CD", "CF", "CG",
- "CH", "CI", "CK", "CL", "CM", "CN", "CO", "CR",
- "CU", "CV", "CX", "CY", "CZ", "DE", "DJ", "DK",
- "DM", "DO", "DZ", "EC", "EE", "EG", "EH", "ER",
- "ES", "ET", "FI", "FJ", "FK", "FM", "FO", "FR",
- "GA", "GB", "GD", "GE", "GF", "GG", "GH", "GI", "GL",
- "GM", "GN", "GP", "GQ", "GR", "GS", "GT", "GU",
- "GW", "GY", "HK", "HM", "HN", "HR", "HT", "HU",
- "ID", "IE", "IL", "IM", "IN", "IO", "IQ", "IR", "IS",
- "IT", "JE", "JM", "JO", "JP", "KE", "KG", "KH", "KI",
- "KM", "KN", "KP", "KR", "KW", "KY", "KZ", "LA",
- "LB", "LC", "LI", "LK", "LR", "LS", "LT", "LU",
- "LV", "LY", "MA", "MC", "MD", "ME", "MF", "MG", "MH", "MK",
- "ML", "MM", "MN", "MO", "MP", "MQ", "MR", "MS",
- "MT", "MU", "MV", "MW", "MX", "MY", "MZ", "NA",
- "NC", "NE", "NF", "NG", "NI", "NL", "NO", "NP",
- "NR", "NU", "NZ", "OM", "PA", "PE", "PF", "PG",
- "PH", "PK", "PL", "PM", "PN", "PR", "PS", "PT",
- "PW", "PY", "QA", "RE", "RO", "RS", "RU", "RW", "SA",
- "SB", "SC", "SD", "SE", "SG", "SH", "SI", "SJ",
- "SK", "SL", "SM", "SN", "SO", "SR", "ST", "SV",
- "SY", "SZ", "TC", "TD", "TF", "TG", "TH", "TJ",
- "TK", "TL", "TM", "TN", "TO", "TR", "TT", "TV",
- "TW", "TZ", "UA", "UG", "UM", "US", "UY", "UZ",
- "VA", "VC", "VE", "VG", "VI", "VN", "VU", "WF",
- "WS", "YE", "YT", "ZA", "ZM", "ZW",
- };
-
- /* this table is used for 3 letter codes */
- String[] tempObsoleteCountries = {
- "FX", "CS", "RO", "TP", "YU", "ZR", /* obsolete country codes */
- };
-
- String[] tempDeprecatedCountries = {
- "BU", "CS", "DY", "FX", "HV", "NH", "RH", "TP", "YU", "ZR" /* deprecated country list */
- };
- String[] tempReplacementCountries = {
- /* "BU", "CS", "DY", "FX", "HV", "NH", "RH", "TP", "YU", "ZR" */
- "MM", "RS", "BJ", "FR", "BF", "VU", "ZW", "TL", "RS", "CD", /* replacement country codes */
- };
-
- /* This list MUST contain a three-letter code for every two-letter code in
- the above list, and they MUST be listed in the same order! */
- String[] tempCountries3 = {
- /* "AD", "AE", "AF", "AG", "AI", "AL", "AM", "AN", */
- "AND", "ARE", "AFG", "ATG", "AIA", "ALB", "ARM", "ANT",
- /* "AO", "AQ", "AR", "AS", "AT", "AU", "AW", "AX", "AZ", */
- "AGO", "ATA", "ARG", "ASM", "AUT", "AUS", "ABW", "ALA", "AZE",
- /* "BA", "BB", "BD", "BE", "BF", "BG", "BH", "BI", */
- "BIH", "BRB", "BGD", "BEL", "BFA", "BGR", "BHR", "BDI",
- /* "BJ", "BL", "BM", "BN", "BO", "BR", "BS", "BT", "BV", */
- "BEN", "BLM", "BMU", "BRN", "BOL", "BRA", "BHS", "BTN", "BVT",
- /* "BW", "BY", "BZ", "CA", "CC", "CD", "CF", "CG", */
- "BWA", "BLR", "BLZ", "CAN", "CCK", "COD", "CAF", "COG",
- /* "CH", "CI", "CK", "CL", "CM", "CN", "CO", "CR", */
- "CHE", "CIV", "COK", "CHL", "CMR", "CHN", "COL", "CRI",
- /* "CU", "CV", "CX", "CY", "CZ", "DE", "DJ", "DK", */
- "CUB", "CPV", "CXR", "CYP", "CZE", "DEU", "DJI", "DNK",
- /* "DM", "DO", "DZ", "EC", "EE", "EG", "EH", "ER", */
- "DMA", "DOM", "DZA", "ECU", "EST", "EGY", "ESH", "ERI",
- /* "ES", "ET", "FI", "FJ", "FK", "FM", "FO", "FR", */
- "ESP", "ETH", "FIN", "FJI", "FLK", "FSM", "FRO", "FRA",
- /* "GA", "GB", "GD", "GE", "GF", "GG", "GH", "GI", "GL", */
- "GAB", "GBR", "GRD", "GEO", "GUF", "GGY", "GHA", "GIB", "GRL",
- /* "GM", "GN", "GP", "GQ", "GR", "GS", "GT", "GU", */
- "GMB", "GIN", "GLP", "GNQ", "GRC", "SGS", "GTM", "GUM",
- /* "GW", "GY", "HK", "HM", "HN", "HR", "HT", "HU", */
- "GNB", "GUY", "HKG", "HMD", "HND", "HRV", "HTI", "HUN",
- /* "ID", "IE", "IL", "IM", "IN", "IO", "IQ", "IR", "IS" */
- "IDN", "IRL", "ISR", "IMN", "IND", "IOT", "IRQ", "IRN", "ISL",
- /* "IT", "JE", "JM", "JO", "JP", "KE", "KG", "KH", "KI", */
- "ITA", "JEY", "JAM", "JOR", "JPN", "KEN", "KGZ", "KHM", "KIR",
- /* "KM", "KN", "KP", "KR", "KW", "KY", "KZ", "LA", */
- "COM", "KNA", "PRK", "KOR", "KWT", "CYM", "KAZ", "LAO",
- /* "LB", "LC", "LI", "LK", "LR", "LS", "LT", "LU", */
- "LBN", "LCA", "LIE", "LKA", "LBR", "LSO", "LTU", "LUX",
- /* "LV", "LY", "MA", "MC", "MD", "ME", "MF", "MG", "MH", "MK", */
- "LVA", "LBY", "MAR", "MCO", "MDA", "MNE", "MAF", "MDG", "MHL", "MKD",
- /* "ML", "MM", "MN", "MO", "MP", "MQ", "MR", "MS", */
- "MLI", "MMR", "MNG", "MAC", "MNP", "MTQ", "MRT", "MSR",
- /* "MT", "MU", "MV", "MW", "MX", "MY", "MZ", "NA", */
- "MLT", "MUS", "MDV", "MWI", "MEX", "MYS", "MOZ", "NAM",
- /* "NC", "NE", "NF", "NG", "NI", "NL", "NO", "NP", */
- "NCL", "NER", "NFK", "NGA", "NIC", "NLD", "NOR", "NPL",
- /* "NR", "NU", "NZ", "OM", "PA", "PE", "PF", "PG", */
- "NRU", "NIU", "NZL", "OMN", "PAN", "PER", "PYF", "PNG",
- /* "PH", "PK", "PL", "PM", "PN", "PR", "PS", "PT", */
- "PHL", "PAK", "POL", "SPM", "PCN", "PRI", "PSE", "PRT",
- /* "PW", "PY", "QA", "RE", "RO", "RS", "RU", "RW", "SA", */
- "PLW", "PRY", "QAT", "REU", "ROU", "SRB", "RUS", "RWA", "SAU",
- /* "SB", "SC", "SD", "SE", "SG", "SH", "SI", "SJ", */
- "SLB", "SYC", "SDN", "SWE", "SGP", "SHN", "SVN", "SJM",
- /* "SK", "SL", "SM", "SN", "SO", "SR", "ST", "SV", */
- "SVK", "SLE", "SMR", "SEN", "SOM", "SUR", "STP", "SLV",
- /* "SY", "SZ", "TC", "TD", "TF", "TG", "TH", "TJ", */
- "SYR", "SWZ", "TCA", "TCD", "ATF", "TGO", "THA", "TJK",
- /* "TK", "TL", "TM", "TN", "TO", "TR", "TT", "TV", */
- "TKL", "TLS", "TKM", "TUN", "TON", "TUR", "TTO", "TUV",
- /* "TW", "TZ", "UA", "UG", "UM", "US", "UY", "UZ", */
- "TWN", "TZA", "UKR", "UGA", "UMI", "USA", "URY", "UZB",
- /* "VA", "VC", "VE", "VG", "VI", "VN", "VU", "WF", */
- "VAT", "VCT", "VEN", "VGB", "VIR", "VNM", "VUT", "WLF",
- /* "WS", "YE", "YT", "ZA", "ZM", "ZW" */
- "WSM", "YEM", "MYT", "ZAF", "ZMB", "ZWE",
- };
-
- String[] tempObsoleteCountries3 = {
- /*"FX", "CS", "RO", "TP", "YU", "ZR", */
- "FXX", "SCG", "ROM", "TMP", "YUG", "ZAR",
- };
-
- synchronized (ULocale.class) {
- if (_countries == null) {
- _countries = tempCountries;
- _deprecatedCountries = tempDeprecatedCountries;
- _replacementCountries = tempReplacementCountries;
- _obsoleteCountries = tempObsoleteCountries;
- _countries3 = tempCountries3;
- _obsoleteCountries3 = tempObsoleteCountries3;
- }
- }
- }
- }
-
- public static String getCurrentCountryID(String oldID){
- initCountryTables();
- int offset = findIndex(_deprecatedCountries, oldID);
- if (offset >= 0) {
- return _replacementCountries[offset];
- }
- return oldID;
- }
-
- public static String getCurrentLanguageID(String oldID){
- initLanguageTables();
- int offset = findIndex(_obsoleteLanguages, oldID);
- if (offset >= 0) {
- return _replacementLanguages[offset];
- }
- return oldID;
- }
-
-
-}
+/*
+ *******************************************************************************
+ * Copyright (C) 2009-2011, International Business Machines Corporation and *
+ * others. All Rights Reserved. *
+ *******************************************************************************
+ */
+package com.ibm.icu.impl;
+
+import java.util.MissingResourceException;
+
+import com.ibm.icu.util.ULocale;
+
+
+/**
+ * Utilities for mapping between old and new language, country, and other
+ * locale ID related names.
+ */
+public class LocaleIDs {
+
+ /**
+ * Returns a list of all 2-letter country codes defined in ISO 3166.
+ * Can be used to create Locales.
+ * @stable ICU 3.0
+ */
+ public static String[] getISOCountries() {
+ initCountryTables();
+ return _countries.clone();
+ }
+
+ /**
+ * Returns a list of all 2-letter language codes defined in ISO 639.
+ * Can be used to create Locales.
+ * [NOTE: ISO 639 is not a stable standard-- some languages' codes have changed.
+ * The list this function returns includes both the new and the old codes for the
+ * languages whose codes have changed.]
+ * @stable ICU 3.0
+ */
+ public static String[] getISOLanguages() {
+ initLanguageTables();
+ return _languages.clone();
+ }
+
+ /**
+ * Returns a three-letter abbreviation for the provided country. If the provided
+ * country is empty, returns the empty string. Otherwise, returns
+ * an uppercase ISO 3166 3-letter country code.
+ * @exception MissingResourceException Throws MissingResourceException if the
+ * three-letter country abbreviation is not available for this locale.
+ * @stable ICU 3.0
+ */
+ public static String getISO3Country(String country){
+ initCountryTables();
+
+ int offset = findIndex(_countries, country);
+ if(offset>=0){
+ return _countries3[offset];
+ }else{
+ offset = findIndex(_obsoleteCountries, country);
+ if(offset>=0){
+ return _obsoleteCountries3[offset];
+ }
+ }
+ return "";
+ }
+ /**
+ * Returns a three-letter abbreviation for the language. If language is
+ * empty, returns the empty string. Otherwise, returns
+ * a lowercase ISO 639-2/T language code.
+ * The ISO 639-2 language codes can be found on-line at
+ * ftp://dkuug.dk/i18n/iso-639-2.txt
+ * @exception MissingResourceException Throws MissingResourceException if the
+ * three-letter language abbreviation is not available for this locale.
+ * @stable ICU 3.0
+ */
+ public static String getISO3Language(String language) {
+ initLanguageTables();
+
+ int offset = findIndex(_languages, language);
+ if(offset>=0){
+ return _languages3[offset];
+ } else {
+ offset = findIndex(_obsoleteLanguages, language);
+ if (offset >= 0) {
+ return _obsoleteLanguages3[offset];
+ }
+ }
+ return "";
+ }
+
+ public static String threeToTwoLetterLanguage(String lang) {
+ initLanguageTables();
+
+ /* convert 3 character code to 2 character code if possible *CWB*/
+ int offset = findIndex(_languages3, lang);
+ if (offset >= 0) {
+ return _languages[offset];
+ }
+
+ offset = findIndex(_obsoleteLanguages3, lang);
+ if (offset >= 0) {
+ return _obsoleteLanguages[offset];
+ }
+
+ return null;
+ }
+
+ public static String threeToTwoLetterRegion(String region) {
+ initCountryTables();
+
+ /* convert 3 character code to 2 character code if possible *CWB*/
+ int offset = findIndex(_countries3, region);
+ if (offset >= 0) {
+ return _countries[offset];
+ }
+
+ offset = findIndex(_obsoleteCountries3, region);
+ if (offset >= 0) {
+ return _obsoleteCountries[offset];
+ }
+
+ return null;
+ }
+
+ /**
+ * linear search of the string array. the arrays are unfortunately ordered by the
+ * two-letter target code, not the three-letter search code, which seems backwards.
+ */
+ private static int findIndex(String[] array, String target){
+ for (int i = 0; i < array.length; i++) {
+ if (target.equals(array[i])) {
+ return i;
+ }
+ }
+ return -1;
+ }
+
+
+ /**
+ * Tables used in normalizing portions of the id.
+ */
+ /* tables updated per http://lcweb.loc.gov/standards/iso639-2/
+ to include the revisions up to 2001/7/27 *CWB*/
+ /* The 3 character codes are the terminology codes like RFC 3066.
+ This is compatible with prior ICU codes */
+ /* "in" "iw" "ji" "jw" & "sh" have been withdrawn but are still in
+ the table but now at the end of the table because
+ 3 character codes are duplicates. This avoids bad searches
+ going from 3 to 2 character codes.*/
+ /* The range qaa-qtz is reserved for local use. */
+
+ private static String[] _languages;
+ private static String[] _replacementLanguages;
+ private static String[] _obsoleteLanguages;
+ private static String[] _languages3;
+ private static String[] _obsoleteLanguages3;
+
+ // Avoid initializing languages tables unless we have to.
+ private static void initLanguageTables() {
+ if (_languages == null) {
+
+ /* This list MUST be in sorted order, and MUST contain the two-letter codes
+ if one exists otherwise use the three letter code */
+ String[] tempLanguages = {
+ "aa", "ab", "ace", "ach", "ada", "ady", "ae", "af", "afa",
+ "afh", "ak", "akk", "ale", "alg", "am", "an", "ang", "apa",
+ "ar", "arc", "arn", "arp", "art", "arw", "as", "ast",
+ "ath", "aus", "av", "awa", "ay", "az", "ba", "bad",
+ "bai", "bal", "ban", "bas", "bat", "be", "bej",
+ "bem", "ber", "bg", "bh", "bho", "bi", "bik", "bin",
+ "bla", "bm", "bn", "bnt", "bo", "br", "bra", "bs",
+ "btk", "bua", "bug", "byn", "ca", "cad", "cai", "car", "cau",
+ "ce", "ceb", "cel", "ch", "chb", "chg", "chk", "chm",
+ "chn", "cho", "chp", "chr", "chy", "cmc", "co", "cop",
+ "cpe", "cpf", "cpp", "cr", "crh", "crp", "cs", "csb", "cu", "cus",
+ "cv", "cy", "da", "dak", "dar", "day", "de", "del", "den",
+ "dgr", "din", "doi", "dra", "dsb", "dua", "dum", "dv", "dyu",
+ "dz", "ee", "efi", "egy", "eka", "el", "elx", "en",
+ "enm", "eo", "es", "et", "eu", "ewo", "fa",
+ "fan", "fat", "ff", "fi", "fiu", "fj", "fo", "fon",
+ "fr", "frm", "fro", "fur", "fy", "ga", "gaa", "gay",
+ "gba", "gd", "gem", "gez", "gil", "gl", "gmh", "gn",
+ "goh", "gon", "gor", "got", "grb", "grc", "gu", "gv",
+ "gwi", "ha", "hai", "haw", "he", "hi", "hil", "him",
+ "hit", "hmn", "ho", "hr", "hsb", "ht", "hu", "hup", "hy", "hz",
+ "ia", "iba", "id", "ie", "ig", "ii", "ijo", "ik",
+ "ilo", "inc", "ine", "inh", "io", "ira", "iro", "is", "it",
+ "iu", "ja", "jbo", "jpr", "jrb", "jv", "ka", "kaa", "kab",
+ "kac", "kam", "kar", "kaw", "kbd", "kg", "kha", "khi",
+ "kho", "ki", "kj", "kk", "kl", "km", "kmb", "kn",
+ "ko", "kok", "kos", "kpe", "kr", "krc", "kro", "kru", "ks",
+ "ku", "kum", "kut", "kv", "kw", "ky", "la", "lad",
+ "lah", "lam", "lb", "lez", "lg", "li", "ln", "lo", "lol",
+ "loz", "lt", "lu", "lua", "lui", "lun", "luo", "lus",
+ "lv", "mad", "mag", "mai", "mak", "man", "map", "mas",
+ "mdf", "mdr", "men", "mg", "mga", "mh", "mi", "mic", "min",
+ "mis", "mk", "mkh", "ml", "mn", "mnc", "mni", "mno",
+ "mo", "moh", "mos", "mr", "ms", "mt", "mul", "mun",
+ "mus", "mwr", "my", "myn", "myv", "na", "nah", "nai", "nap",
+ "nb", "nd", "nds", "ne", "new", "ng", "nia", "nic",
+ "niu", "nl", "nn", "no", "nog", "non", "nr", "nso", "nub",
+ "nv", "nwc", "ny", "nym", "nyn", "nyo", "nzi", "oc", "oj",
+ "om", "or", "os", "osa", "ota", "oto", "pa", "paa",
+ "pag", "pal", "pam", "pap", "pau", "peo", "phi", "phn",
+ "pi", "pl", "pon", "pra", "pro", "ps", "pt", "qu",
+ "raj", "rap", "rar", "rm", "rn", "ro", "roa", "rom",
+ "ru", "rup", "rw", "sa", "sad", "sah", "sai", "sal", "sam",
+ "sas", "sat", "sc", "sco", "sd", "se", "sel", "sem",
+ "sg", "sga", "sgn", "shn", "si", "sid", "sio", "sit",
+ "sk", "sl", "sla", "sm", "sma", "smi", "smj", "smn",
+ "sms", "sn", "snk", "so", "sog", "son", "sq", "sr",
+ "srr", "ss", "ssa", "st", "su", "suk", "sus", "sux",
+ "sv", "sw", "syr", "ta", "tai", "te", "tem", "ter",
+ "tet", "tg", "th", "ti", "tig", "tiv", "tk", "tkl",
+ "tl", "tlh", "tli", "tmh", "tn", "to", "tog", "tpi", "tr",
+ "ts", "tsi", "tt", "tum", "tup", "tut", "tvl", "tw",
+ "ty", "tyv", "udm", "ug", "uga", "uk", "umb", "und", "ur",
+ "uz", "vai", "ve", "vi", "vo", "vot", "wa", "wak",
+ "wal", "war", "was", "wen", "wo", "xal", "xh", "yao", "yap",
+ "yi", "yo", "ypk", "za", "zap", "zen", "zh", "znd",
+ "zu", "zun",
+ };
+
+ String[] tempReplacementLanguages = {
+ "id", "he", "yi", "jv", "sr", "nb",/* replacement language codes */
+ };
+
+ String[] tempObsoleteLanguages = {
+ "in", "iw", "ji", "jw", "sh", "no", /* obsolete language codes */
+ };
+
+ /* This list MUST contain a three-letter code for every two-letter code in the
+ list above, and they MUST ne in the same order (i.e., the same language must
+ be in the same place in both lists)! */
+ String[] tempLanguages3 = {
+ /*"aa", "ab", "ace", "ach", "ada", "ady", "ae", "af", "afa", */
+ "aar", "abk", "ace", "ach", "ada", "ady", "ave", "afr", "afa",
+ /*"afh", "ak", "akk", "ale", "alg", "am", "an", "ang", "apa", */
+ "afh", "aka", "akk", "ale", "alg", "amh", "arg", "ang", "apa",
+ /*"ar", "arc", "arn", "arp", "art", "arw", "as", "ast", */
+ "ara", "arc", "arn", "arp", "art", "arw", "asm", "ast",
+ /*"ath", "aus", "av", "awa", "ay", "az", "ba", "bad", */
+ "ath", "aus", "ava", "awa", "aym", "aze", "bak", "bad",
+ /*"bai", "bal", "ban", "bas", "bat", "be", "bej", */
+ "bai", "bal", "ban", "bas", "bat", "bel", "bej",
+ /*"bem", "ber", "bg", "bh", "bho", "bi", "bik", "bin", */
+ "bem", "ber", "bul", "bih", "bho", "bis", "bik", "bin",
+ /*"bla", "bm", "bn", "bnt", "bo", "br", "bra", "bs", */
+ "bla", "bam", "ben", "bnt", "bod", "bre", "bra", "bos",
+ /*"btk", "bua", "bug", "byn", "ca", "cad", "cai", "car", "cau", */
+ "btk", "bua", "bug", "byn", "cat", "cad", "cai", "car", "cau",
+ /*"ce", "ceb", "cel", "ch", "chb", "chg", "chk", "chm", */
+ "che", "ceb", "cel", "cha", "chb", "chg", "chk", "chm",
+ /*"chn", "cho", "chp", "chr", "chy", "cmc", "co", "cop", */
+ "chn", "cho", "chp", "chr", "chy", "cmc", "cos", "cop",
+ /*"cpe", "cpf", "cpp", "cr", "crh", "crp", "cs", "csb", "cu", "cus", */
+ "cpe", "cpf", "cpp", "cre", "crh", "crp", "ces", "csb", "chu", "cus",
+ /*"cv", "cy", "da", "dak", "dar", "day", "de", "del", "den", */
+ "chv", "cym", "dan", "dak", "dar", "day", "deu", "del", "den",
+ /*"dgr", "din", "doi", "dra", "dsb", "dua", "dum", "dv", "dyu", */
+ "dgr", "din", "doi", "dra", "dsb", "dua", "dum", "div", "dyu",
+ /*"dz", "ee", "efi", "egy", "eka", "el", "elx", "en", */
+ "dzo", "ewe", "efi", "egy", "eka", "ell", "elx", "eng",
+ /*"enm", "eo", "es", "et", "eu", "ewo", "fa", */
+ "enm", "epo", "spa", "est", "eus", "ewo", "fas",
+ /*"fan", "fat", "ff", "fi", "fiu", "fj", "fo", "fon", */
+ "fan", "fat", "ful", "fin", "fiu", "fij", "fao", "fon",
+ /*"fr", "frm", "fro", "fur", "fy", "ga", "gaa", "gay", */
+ "fra", "frm", "fro", "fur", "fry", "gle", "gaa", "gay",
+ /*"gba", "gd", "gem", "gez", "gil", "gl", "gmh", "gn", */
+ "gba", "gla", "gem", "gez", "gil", "glg", "gmh", "grn",
+ /*"goh", "gon", "gor", "got", "grb", "grc", "gu", "gv", */
+ "goh", "gon", "gor", "got", "grb", "grc", "guj", "glv",
+ /*"gwi", "ha", "hai", "haw", "he", "hi", "hil", "him", */
+ "gwi", "hau", "hai", "haw", "heb", "hin", "hil", "him",
+ /*"hit", "hmn", "ho", "hr", "hsb", "ht", "hu", "hup", "hy", "hz", */
+ "hit", "hmn", "hmo", "hrv", "hsb", "hat", "hun", "hup", "hye", "her",
+ /*"ia", "iba", "id", "ie", "ig", "ii", "ijo", "ik", */
+ "ina", "iba", "ind", "ile", "ibo", "iii", "ijo", "ipk",
+ /*"ilo", "inc", "ine", "inh", "io", "ira", "iro", "is", "it", */
+ "ilo", "inc", "ine", "inh", "ido", "ira", "iro", "isl", "ita",
+ /*"iu", "ja", "jbo", "jpr", "jrb", "jv", "ka", "kaa", "kab", */
+ "iku", "jpn", "jbo", "jpr", "jrb", "jaw", "kat", "kaa", "kab",
+ /*"kac", "kam", "kar", "kaw", "kbd", "kg", "kha", "khi", */
+ "kac", "kam", "kar", "kaw", "kbd", "kon", "kha", "khi",
+ /*"kho", "ki", "kj", "kk", "kl", "km", "kmb", "kn", */
+ "kho", "kik", "kua", "kaz", "kal", "khm", "kmb", "kan",
+ /*"ko", "kok", "kos", "kpe", "kr", "krc", "kro", "kru", "ks", */
+ "kor", "kok", "kos", "kpe", "kau", "krc", "kro", "kru", "kas",
+ /*"ku", "kum", "kut", "kv", "kw", "ky", "la", "lad", */
+ "kur", "kum", "kut", "kom", "cor", "kir", "lat", "lad",
+ /*"lah", "lam", "lb", "lez", "lg", "li", "ln", "lo", "lol", */
+ "lah", "lam", "ltz", "lez", "lug", "lim", "lin", "lao", "lol",
+ /*"loz", "lt", "lu", "lua", "lui", "lun", "luo", "lus", */
+ "loz", "lit", "lub", "lua", "lui", "lun", "luo", "lus",
+ /*"lv", "mad", "mag", "mai", "mak", "man", "map", "mas", */
+ "lav", "mad", "mag", "mai", "mak", "man", "map", "mas",
+ /*"mdf", "mdr", "men", "mg", "mga", "mh", "mi", "mic", "min", */
+ "mdf", "mdr", "men", "mlg", "mga", "mah", "mri", "mic", "min",
+ /*"mis", "mk", "mkh", "ml", "mn", "mnc", "mni", "mno", */
+ "mis", "mkd", "mkh", "mal", "mon", "mnc", "mni", "mno",
+ /*"mo", "moh", "mos", "mr", "ms", "mt", "mul", "mun", */
+ "mol", "moh", "mos", "mar", "msa", "mlt", "mul", "mun",
+ /*"mus", "mwr", "my", "myn", "myv", "na", "nah", "nai", "nap", */
+ "mus", "mwr", "mya", "myn", "myv", "nau", "nah", "nai", "nap",
+ /*"nb", "nd", "nds", "ne", "new", "ng", "nia", "nic", */
+ "nob", "nde", "nds", "nep", "new", "ndo", "nia", "nic",
+ /*"niu", "nl", "nn", "no", "nog", "non", "nr", "nso", "nub", */
+ "niu", "nld", "nno", "nor", "nog", "non", "nbl", "nso", "nub",
+ /*"nv", "nwc", "ny", "nym", "nyn", "nyo", "nzi", "oc", "oj", */
+ "nav", "nwc", "nya", "nym", "nyn", "nyo", "nzi", "oci", "oji",
+ /*"om", "or", "os", "osa", "ota", "oto", "pa", "paa", */
+ "orm", "ori", "oss", "osa", "ota", "oto", "pan", "paa",
+ /*"pag", "pal", "pam", "pap", "pau", "peo", "phi", "phn", */
+ "pag", "pal", "pam", "pap", "pau", "peo", "phi", "phn",
+ /*"pi", "pl", "pon", "pra", "pro", "ps", "pt", "qu", */
+ "pli", "pol", "pon", "pra", "pro", "pus", "por", "que",
+ /*"raj", "rap", "rar", "rm", "rn", "ro", "roa", "rom", */
+ "raj", "rap", "rar", "roh", "run", "ron", "roa", "rom",
+ /*"ru", "rup", "rw", "sa", "sad", "sah", "sai", "sal", "sam", */
+ "rus", "rup", "kin", "san", "sad", "sah", "sai", "sal", "sam",
+ /*"sas", "sat", "sc", "sco", "sd", "se", "sel", "sem", */
+ "sas", "sat", "srd", "sco", "snd", "sme", "sel", "sem",
+ /*"sg", "sga", "sgn", "shn", "si", "sid", "sio", "sit", */
+ "sag", "sga", "sgn", "shn", "sin", "sid", "sio", "sit",
+ /*"sk", "sl", "sla", "sm", "sma", "smi", "smj", "smn", */
+ "slk", "slv", "sla", "smo", "sma", "smi", "smj", "smn",
+ /*"sms", "sn", "snk", "so", "sog", "son", "sq", "sr", */
+ "sms", "sna", "snk", "som", "sog", "son", "sqi", "srp",
+ /*"srr", "ss", "ssa", "st", "su", "suk", "sus", "sux", */
+ "srr", "ssw", "ssa", "sot", "sun", "suk", "sus", "sux",
+ /*"sv", "sw", "syr", "ta", "tai", "te", "tem", "ter", */
+ "swe", "swa", "syr", "tam", "tai", "tel", "tem", "ter",
+ /*"tet", "tg", "th", "ti", "tig", "tiv", "tk", "tkl", */
+ "tet", "tgk", "tha", "tir", "tig", "tiv", "tuk", "tkl",
+ /*"tl", "tlh", "tli", "tmh", "tn", "to", "tog", "tpi", "tr", */
+ "tgl", "tlh", "tli", "tmh", "tsn", "ton", "tog", "tpi", "tur",
+ /*"ts", "tsi", "tt", "tum", "tup", "tut", "tvl", "tw", */
+ "tso", "tsi", "tat", "tum", "tup", "tut", "tvl", "twi",
+ /*"ty", "tyv", "udm", "ug", "uga", "uk", "umb", "und", "ur", */
+ "tah", "tyv", "udm", "uig", "uga", "ukr", "umb", "und", "urd",
+ /*"uz", "vai", "ve", "vi", "vo", "vot", "wa", "wak", */
+ "uzb", "vai", "ven", "vie", "vol", "vot", "wln", "wak",
+ /*"wal", "war", "was", "wen", "wo", "xal", "xh", "yao", "yap", */
+ "wal", "war", "was", "wen", "wol", "xal", "xho", "yao", "yap",
+ /*"yi", "yo", "ypk", "za", "zap", "zen", "zh", "znd", */
+ "yid", "yor", "ypk", "zha", "zap", "zen", "zho", "znd",
+ /*"zu", "zun", */
+ "zul", "zun",
+ };
+
+ String[] tempObsoleteLanguages3 = {
+ /* "in", "iw", "ji", "jw", "sh", */
+ "ind", "heb", "yid", "jaw", "srp",
+ };
+
+ synchronized (ULocale.class) {
+ if (_languages == null) {
+ _languages = tempLanguages;
+ _replacementLanguages = tempReplacementLanguages;
+ _obsoleteLanguages = tempObsoleteLanguages;
+ _languages3 = tempLanguages3;
+ _obsoleteLanguages3 = tempObsoleteLanguages3;
+ }
+ }
+ }
+ }
+
+ private static String[] _countries;
+ private static String[] _deprecatedCountries;
+ private static String[] _replacementCountries;
+ private static String[] _obsoleteCountries;
+ private static String[] _countries3;
+ private static String[] _obsoleteCountries3;
+
+ // Avoid initializing country tables unless we have to.
+ private static void initCountryTables() {
+ if (_countries == null) {
+ /* ZR(ZAR) is now CD(COD) and FX(FXX) is PS(PSE) as per
+ http://www.evertype.com/standards/iso3166/iso3166-1-en.html
+ added new codes keeping the old ones for compatibility
+ updated to include 1999/12/03 revisions *CWB*/
+
+ /* RO(ROM) is now RO(ROU) according to
+ http://www.iso.org/iso/en/prods-services/iso3166ma/03updates-on-iso-3166/nlv3e-rou.html
+ */
+
+ /* This list MUST be in sorted order, and MUST contain only two-letter codes! */
+ String[] tempCountries = {
+ "AD", "AE", "AF", "AG", "AI", "AL", "AM", "AN",
+ "AO", "AQ", "AR", "AS", "AT", "AU", "AW", "AX", "AZ",
+ "BA", "BB", "BD", "BE", "BF", "BG", "BH", "BI",
+ "BJ", "BL", "BM", "BN", "BO", "BR", "BS", "BT", "BV",
+ "BW", "BY", "BZ", "CA", "CC", "CD", "CF", "CG",
+ "CH", "CI", "CK", "CL", "CM", "CN", "CO", "CR",
+ "CU", "CV", "CX", "CY", "CZ", "DE", "DJ", "DK",
+ "DM", "DO", "DZ", "EC", "EE", "EG", "EH", "ER",
+ "ES", "ET", "FI", "FJ", "FK", "FM", "FO", "FR",
+ "GA", "GB", "GD", "GE", "GF", "GG", "GH", "GI", "GL",
+ "GM", "GN", "GP", "GQ", "GR", "GS", "GT", "GU",
+ "GW", "GY", "HK", "HM", "HN", "HR", "HT", "HU",
+ "ID", "IE", "IL", "IM", "IN", "IO", "IQ", "IR", "IS",
+ "IT", "JE", "JM", "JO", "JP", "KE", "KG", "KH", "KI",
+ "KM", "KN", "KP", "KR", "KW", "KY", "KZ", "LA",
+ "LB", "LC", "LI", "LK", "LR", "LS", "LT", "LU",
+ "LV", "LY", "MA", "MC", "MD", "ME", "MF", "MG", "MH", "MK",
+ "ML", "MM", "MN", "MO", "MP", "MQ", "MR", "MS",
+ "MT", "MU", "MV", "MW", "MX", "MY", "MZ", "NA",
+ "NC", "NE", "NF", "NG", "NI", "NL", "NO", "NP",
+ "NR", "NU", "NZ", "OM", "PA", "PE", "PF", "PG",
+ "PH", "PK", "PL", "PM", "PN", "PR", "PS", "PT",
+ "PW", "PY", "QA", "RE", "RO", "RS", "RU", "RW", "SA",
+ "SB", "SC", "SD", "SE", "SG", "SH", "SI", "SJ",
+ "SK", "SL", "SM", "SN", "SO", "SR", "ST", "SV",
+ "SY", "SZ", "TC", "TD", "TF", "TG", "TH", "TJ",
+ "TK", "TL", "TM", "TN", "TO", "TR", "TT", "TV",
+ "TW", "TZ", "UA", "UG", "UM", "US", "UY", "UZ",
+ "VA", "VC", "VE", "VG", "VI", "VN", "VU", "WF",
+ "WS", "YE", "YT", "ZA", "ZM", "ZW",
+ };
+
+ /* this table is used for 3 letter codes */
+ String[] tempObsoleteCountries = {
+ "FX", "CS", "RO", "TP", "YU", "ZR", /* obsolete country codes */
+ };
+
+ String[] tempDeprecatedCountries = {
+ "BU", "CS", "DY", "FX", "HV", "NH", "RH", "TP", "YU", "ZR" /* deprecated country list */
+ };
+ String[] tempReplacementCountries = {
+ /* "BU", "CS", "DY", "FX", "HV", "NH", "RH", "TP", "YU", "ZR" */
+ "MM", "RS", "BJ", "FR", "BF", "VU", "ZW", "TL", "RS", "CD", /* replacement country codes */
+ };
+
+ /* This list MUST contain a three-letter code for every two-letter code in
+ the above list, and they MUST be listed in the same order! */
+ String[] tempCountries3 = {
+ /* "AD", "AE", "AF", "AG", "AI", "AL", "AM", "AN", */
+ "AND", "ARE", "AFG", "ATG", "AIA", "ALB", "ARM", "ANT",
+ /* "AO", "AQ", "AR", "AS", "AT", "AU", "AW", "AX", "AZ", */
+ "AGO", "ATA", "ARG", "ASM", "AUT", "AUS", "ABW", "ALA", "AZE",
+ /* "BA", "BB", "BD", "BE", "BF", "BG", "BH", "BI", */
+ "BIH", "BRB", "BGD", "BEL", "BFA", "BGR", "BHR", "BDI",
+ /* "BJ", "BL", "BM", "BN", "BO", "BR", "BS", "BT", "BV", */
+ "BEN", "BLM", "BMU", "BRN", "BOL", "BRA", "BHS", "BTN", "BVT",
+ /* "BW", "BY", "BZ", "CA", "CC", "CD", "CF", "CG", */
+ "BWA", "BLR", "BLZ", "CAN", "CCK", "COD", "CAF", "COG",
+ /* "CH", "CI", "CK", "CL", "CM", "CN", "CO", "CR", */
+ "CHE", "CIV", "COK", "CHL", "CMR", "CHN", "COL", "CRI",
+ /* "CU", "CV", "CX", "CY", "CZ", "DE", "DJ", "DK", */
+ "CUB", "CPV", "CXR", "CYP", "CZE", "DEU", "DJI", "DNK",
+ /* "DM", "DO", "DZ", "EC", "EE", "EG", "EH", "ER", */
+ "DMA", "DOM", "DZA", "ECU", "EST", "EGY", "ESH", "ERI",
+ /* "ES", "ET", "FI", "FJ", "FK", "FM", "FO", "FR", */
+ "ESP", "ETH", "FIN", "FJI", "FLK", "FSM", "FRO", "FRA",
+ /* "GA", "GB", "GD", "GE", "GF", "GG", "GH", "GI", "GL", */
+ "GAB", "GBR", "GRD", "GEO", "GUF", "GGY", "GHA", "GIB", "GRL",
+ /* "GM", "GN", "GP", "GQ", "GR", "GS", "GT", "GU", */
+ "GMB", "GIN", "GLP", "GNQ", "GRC", "SGS", "GTM", "GUM",
+ /* "GW", "GY", "HK", "HM", "HN", "HR", "HT", "HU", */
+ "GNB", "GUY", "HKG", "HMD", "HND", "HRV", "HTI", "HUN",
+ /* "ID", "IE", "IL", "IM", "IN", "IO", "IQ", "IR", "IS" */
+ "IDN", "IRL", "ISR", "IMN", "IND", "IOT", "IRQ", "IRN", "ISL",
+ /* "IT", "JE", "JM", "JO", "JP", "KE", "KG", "KH", "KI", */
+ "ITA", "JEY", "JAM", "JOR", "JPN", "KEN", "KGZ", "KHM", "KIR",
+ /* "KM", "KN", "KP", "KR", "KW", "KY", "KZ", "LA", */
+ "COM", "KNA", "PRK", "KOR", "KWT", "CYM", "KAZ", "LAO",
+ /* "LB", "LC", "LI", "LK", "LR", "LS", "LT", "LU", */
+ "LBN", "LCA", "LIE", "LKA", "LBR", "LSO", "LTU", "LUX",
+ /* "LV", "LY", "MA", "MC", "MD", "ME", "MF", "MG", "MH", "MK", */
+ "LVA", "LBY", "MAR", "MCO", "MDA", "MNE", "MAF", "MDG", "MHL", "MKD",
+ /* "ML", "MM", "MN", "MO", "MP", "MQ", "MR", "MS", */
+ "MLI", "MMR", "MNG", "MAC", "MNP", "MTQ", "MRT", "MSR",
+ /* "MT", "MU", "MV", "MW", "MX", "MY", "MZ", "NA", */
+ "MLT", "MUS", "MDV", "MWI", "MEX", "MYS", "MOZ", "NAM",
+ /* "NC", "NE", "NF", "NG", "NI", "NL", "NO", "NP", */
+ "NCL", "NER", "NFK", "NGA", "NIC", "NLD", "NOR", "NPL",
+ /* "NR", "NU", "NZ", "OM", "PA", "PE", "PF", "PG", */
+ "NRU", "NIU", "NZL", "OMN", "PAN", "PER", "PYF", "PNG",
+ /* "PH", "PK", "PL", "PM", "PN", "PR", "PS", "PT", */
+ "PHL", "PAK", "POL", "SPM", "PCN", "PRI", "PSE", "PRT",
+ /* "PW", "PY", "QA", "RE", "RO", "RS", "RU", "RW", "SA", */
+ "PLW", "PRY", "QAT", "REU", "ROU", "SRB", "RUS", "RWA", "SAU",
+ /* "SB", "SC", "SD", "SE", "SG", "SH", "SI", "SJ", */
+ "SLB", "SYC", "SDN", "SWE", "SGP", "SHN", "SVN", "SJM",
+ /* "SK", "SL", "SM", "SN", "SO", "SR", "ST", "SV", */
+ "SVK", "SLE", "SMR", "SEN", "SOM", "SUR", "STP", "SLV",
+ /* "SY", "SZ", "TC", "TD", "TF", "TG", "TH", "TJ", */
+ "SYR", "SWZ", "TCA", "TCD", "ATF", "TGO", "THA", "TJK",
+ /* "TK", "TL", "TM", "TN", "TO", "TR", "TT", "TV", */
+ "TKL", "TLS", "TKM", "TUN", "TON", "TUR", "TTO", "TUV",
+ /* "TW", "TZ", "UA", "UG", "UM", "US", "UY", "UZ", */
+ "TWN", "TZA", "UKR", "UGA", "UMI", "USA", "URY", "UZB",
+ /* "VA", "VC", "VE", "VG", "VI", "VN", "VU", "WF", */
+ "VAT", "VCT", "VEN", "VGB", "VIR", "VNM", "VUT", "WLF",
+ /* "WS", "YE", "YT", "ZA", "ZM", "ZW" */
+ "WSM", "YEM", "MYT", "ZAF", "ZMB", "ZWE",
+ };
+
+ String[] tempObsoleteCountries3 = {
+ /*"FX", "CS", "RO", "TP", "YU", "ZR", */
+ "FXX", "SCG", "ROM", "TMP", "YUG", "ZAR",
+ };
+
+ synchronized (ULocale.class) {
+ if (_countries == null) {
+ _countries = tempCountries;
+ _deprecatedCountries = tempDeprecatedCountries;
+ _replacementCountries = tempReplacementCountries;
+ _obsoleteCountries = tempObsoleteCountries;
+ _countries3 = tempCountries3;
+ _obsoleteCountries3 = tempObsoleteCountries3;
+ }
+ }
+ }
+ }
+
+ public static String getCurrentCountryID(String oldID){
+ initCountryTables();
+ int offset = findIndex(_deprecatedCountries, oldID);
+ if (offset >= 0) {
+ return _replacementCountries[offset];
+ }
+ return oldID;
+ }
+
+ public static String getCurrentLanguageID(String oldID){
+ initLanguageTables();
+ int offset = findIndex(_obsoleteLanguages, oldID);
+ if (offset >= 0) {
+ return _replacementLanguages[offset];
+ }
+ return oldID;
+ }
+
+
+}
diff --git a/icu4j/eclipse-build/plugins.template/com.ibm.icu.base/src/com/ibm/icu/impl/LocaleUtility.java b/icu4j/eclipse-build/plugins.template/com.ibm.icu.base/src/com/ibm/icu/impl/LocaleUtility.java
index f219f099676..143ac9d2d29 100644
--- a/icu4j/eclipse-build/plugins.template/com.ibm.icu.base/src/com/ibm/icu/impl/LocaleUtility.java
+++ b/icu4j/eclipse-build/plugins.template/com.ibm.icu.base/src/com/ibm/icu/impl/LocaleUtility.java
@@ -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]);
+ }
+}
diff --git a/icu4j/eclipse-build/plugins.template/com.ibm.icu.base/src/com/ibm/icu/impl/SimpleCache.java b/icu4j/eclipse-build/plugins.template/com.ibm.icu.base/src/com/ibm/icu/impl/SimpleCache.java
index fc431b05e19..7ee2dc50dff 100644
--- a/icu4j/eclipse-build/plugins.template/com.ibm.icu.base/src/com/ibm/icu/impl/SimpleCache.java
+++ b/icu4j/eclipse-build/plugins.template/com.ibm.icu.base/src/com/ibm/icu/impl/SimpleCache.java
@@ -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 implements ICUCache {
- private static final int DEFAULT_CAPACITY = 16;
-
- private Reference
-* @see RuleBasedCollator
-* @see CollationKey
-* @author Syn Wee Quek
-* @stable ICU 2.8
-*/
-public class Collator implements Comparator