ICU-4907 modifications for eclipse/1.3/foundation compatibility

X-SVN-Rev: 18819
This commit is contained in:
Doug Felt 2005-11-22 00:54:16 +00:00
parent 01ac758c92
commit 5e567205fc
43 changed files with 1177 additions and 360 deletions

1
.gitattributes vendored
View file

@ -56,6 +56,7 @@ icu4c/source/test/testdata/iscii.bin -text
icu4c/source/test/testdata/testdata_icu26_testtypes.res -text
icu4c/source/test/testdata/testdata_icu26e_testtypes.res -text
icu4c/source/test/testdata/uni-text.bin -text
icu4j/ee.foundation.jar -text
icu4j/src/com/ibm/icu/dev/data/rbbi/english.dict -text
icu4j/src/com/ibm/icu/dev/data/testdata.jar -text
icu4j/src/com/ibm/icu/dev/data/thai6.ucs -text

View file

@ -96,7 +96,9 @@ icu4j/src/com/ibm/icu/dev/data/unicode/ucdterms.txt
icu4j/src/com/ibm/icu/dev/data/unicode/UnicodeData.txt
icu4j/src/com/ibm/icu/dev/data/IDNATestInput.txt
icu4j/src/com/ibm/icu/dev/eclipse/com.ibm.icu/.classpath
icu4j/src/com/ibm/icu/dev/eclipse/com.ibm.icu/.project
icu4j/src/com/ibm/icu/dev/eclipse/com.ibm.icu.tests/.classpath
icu4j/src/com/ibm/icu/dev/eclipse/com.ibm.icu.tests/.project
icu4j/src/com/ibm/icu/dev/test/serializable/*/*.dat
icu4j/src/com/ibm/icu/dev/tool/ime/indic/services/java.awt.im.spi.InputMethodDescriptor
icu4j/src/com/ibm/icu/dev/tool/ime/translit/services/java.awt.im.spi.InputMethodDescriptor

View file

@ -87,6 +87,7 @@
<property name="jarSrc.file" value="icu4jsrc.jar"/>
<property name="zipCoreSrc.file" value="icu4jcsrc.zip"/>
<property name="zipTestSrc.file" value="icu4jtsrc.zip"/>
<property name="eclipse.dir" value="${src.dir}/com/ibm/icu/dev/eclipse"/>
<property name="jarDocs.file" value="icu4jdocs.jar"/>
<property name="icu4j.manifest" value="${src.dir}/com/ibm/icu/manifest.stub"/>
<property name="icu4j.module.manifest" value="${src.dir}/com/ibm/icu/manifest.module.stub"/>
@ -263,13 +264,12 @@
<!-- this is a hack for now, need a way to express dependency on the .jpp files
and to provide directories or trees of files to the code mangler tool. -->
<java classname="com.ibm.icu.dev.tool.docs.CodeMangler" classpath="${build.dir}" logError="true">
<arg value="-d"/>
<arg value="VERSION_${ant.java.version}"/>
<arg value="${src.dir}/com/ibm/icu/dev/tool/docs/ICUTaglet.jpp"/>
<arg value="-dVERSION_${ant.java.version}"/>
<arg value="${src.dir}/com/ibm/icu/dev/tool/docs/ICUTaglet.java"/>
</java>
</target>
<target name="indices" depends="icudata,tools">
<target name="indices" depends="icudata,build_indexgenerator">
<java classname="com.ibm.icu.dev.tool.index.IndexGenerator" classpath="${build.dir}" logError="true">
<arg value="${build.dir}/${icu4j.data.path}" />
</java>
@ -306,6 +306,16 @@
debug="on" deprecation="off"/>
</target>
<target name="build_indexgenerator" depends="core">
<javac includes="com/ibm/icu/dev/tool/index/IndexGenerator.java"
srcdir="${src.dir}"
destdir="${build.dir}"
classpathref="build.classpath"
source="${icu4j.javac.source}"
target="${icu4j.javac.target}"
debug="on" deprecation="off"/>
</target>
<!-- use excludefiles below when we move to ant 1.5 -->
<target name="docs" depends="anthack1,anthack2,tools" description="build user javadoc">
@ -442,22 +452,6 @@
manifest="${icu4j.manifest}"/>
</target>
<target name="zipCoreSrc" depends="init" description="build zip of core sources for debugging">
<!-- for eclipse -->
<zip destfile="${zipCoreSrc.file}"
compress="true"
basedir="${src.dir}"
includes="com/ibm/icu/impl/**/*,com/ibm/icu/lang/**/*,com/ibm/icu/math/**/*,com/ibm/icu/text/**/*,com/ibm/icu/util/**/*"/>
</target>
<target name="zipTestSrc" depends="init" description="build zip of test sources for debugging">
<!-- for eclipse -->
<zip destfile="${zipTestSrc.file}"
compress="true"
basedir="${src.dir}"
includes="com/ibm/icu/dev/test/**/*"/>
</target>
<target name="jarDocs" depends="docs" description="build documentation 'icu4jdocs.jar' jar file">
<jar jarfile="${jarDocs.file}"
compress="true"
@ -1175,4 +1169,90 @@
</classpath>
</java>
</target>
<!-- for building eclipse distribution -->
<target name="zipCoreSrc" depends="init" description="build zip of core sources for debugging">
<!-- for eclipse -->
<zip destfile="${zipCoreSrc.file}"
compress="true"
basedir="${src.dir}"
includes="../license.html,../Copyright_Assignment.rtf,com/ibm/icu/impl/**/*,com/ibm/icu/lang/**/*,com/ibm/icu/math/**/*,com/ibm/icu/text/**/*,com/ibm/icu/util/**/*"/>
</target>
<target name="zipTestSrc" depends="init" description="build zip of test sources for debugging">
<!-- for eclipse -->
<zip destfile="${zipTestSrc.file}"
compress="true"
basedir="${src.dir}"
includes="com/ibm/icu/dev/test/**/*"/>
</target>
<target name="undoEclipseMangle" depends="buildmangle">
<java classname="com.ibm.icu.dev.tool.docs.CodeMangler" classpath="${build.dir}" logError="true">
<arg value="-v"/>
<arg value="@eclipseCoreArgs.txt"/>
<arg value="@eclipseTestArgs.txt"/>
</java>
</target>
<target name="eclipseCoreMangle" depends="buildmangle">
<java classname="com.ibm.icu.dev.tool.docs.CodeMangler" classpath="${build.dir}" logError="true">
<arg value="-dFOUNDATION"/>
<arg value="@eclipseCoreArgs.txt"/>
</java>
</target>
<target name="eclipseTestMangle" depends="buildmangle">
<java classname="com.ibm.icu.dev.tool.docs.CodeMangler" classpath="${build.dir}" logError="true">
<arg value="-dFOUNDATION"/>
<arg value="@eclipseTestArgs.txt"/>
</java>
</target>
<target name="eclipseCore" depends="init,coreData,icudata,eclipseCoreMangle">
<javac includes="com/ibm/icu/util/**/*.java,com/ibm/icu/text/**/*.java,com/ibm/icu/math/**/*.java,com/ibm/icu/impl/**/*.java,com/ibm/icu/lang/*.java"
excludes="**/CVS/**/*"
compiler="javac1.3"
srcdir="${src.dir}"
destdir="${build.dir}"
classpathref="build.classpath"
bootclasspath="ee.foundation.jar"
source="1.3"
target="1.1"
debug="on"
deprecation="off"
encoding="ascii"/>
<antcall target="indices"/>
<jar jarfile="${jar.file}"
compress="true"
includes="com/ibm/icu/util/**/*,com/ibm/icu/text/**/*,com/ibm/icu/math/**/*,com/ibm/icu/impl/**/*,com/ibm/icu/lang/**/*"
basedir="${build.dir}"
manifest="${icu4j.manifest}"/>
</target>
<target name="eclipseCorePkg" depends="eclipseCore" description="build eclipse core package">
<!-- should do a clean build before start -->
<copy file="${jar.file}" toDir="${eclipse.dir}/com.ibm.icu"/>
<antcall target="zipCoreSrc"/>
<move file="${zipCoreSrc.file}" toDir="${eclipse.dir}/com.ibm.icu"/>
<zip destfile="eclipseICU4J_core.zip"
basedir="${eclipse.dir}"
includes="com.ibm.icu,com.ibm.icu/**/*"/>
</target>
<target name="eclipseTestPkg" depends="eclipseCore,eclipseTestMangle" description="build tests trimmed for eclipse API">
<antcall target="tests"/>
<jar jarfile="${testjar.file}" compress="true" manifest="${icu4j.tests.manifest}">
<fileset dir="${build.dir}" includes="com/ibm/icu/dev/test/**/*"/>
<fileset dir="${build.dir}" includes="com/ibm/icu/dev/data/**/*"/>
</jar>
<copy file="${testjar.file}" toDir="${eclipse.dir}/com.ibm.icu.tests"/>
<antcall target="zipTestSrc"/>
<move file="${zipTestSrc.file}" toDir="${eclipse.dir}/com.ibm.icu.tests"/>
<zip destfile="eclipseICU4J_tests.zip"
basedir="${eclipse.dir}"
includes="com.ibm.icu.tests,com.ibm.icu.tests/**/*"/>
</target>
</project>

16
icu4j/eclipseCoreArgs.txt Normal file
View file

@ -0,0 +1,16 @@
# Copyright (C) 2005, International Business Machines Corporation and
# others. All Rights Reserved.
src/com/ibm/icu/impl/CollectionUtilities.java
src/com/ibm/icu/impl/ICUResourceBundle.java
src/com/ibm/icu/impl/ICUResourceBundleImpl.java
src/com/ibm/icu/impl/ICUResourceBundleReader.java
src/com/ibm/icu/impl/Utility.java
src/com/ibm/icu/lang/UCharacter.java
src/com/ibm/icu/math/BigDecimal.java
src/com/ibm/icu/text/DecimalFormat.java
src/com/ibm/icu/text/DigitList.java
src/com/ibm/icu/text/NumberFormat.java
src/com/ibm/icu/text/RuleBasedCollator.java
src/com/ibm/icu/text/RuleBasedNumberFormat.java
src/com/ibm/icu/util/ByteArrayWrapper.java
src/com/ibm/icu/util/GlobalizationPreferences.java

10
icu4j/eclipseTestArgs.txt Normal file
View file

@ -0,0 +1,10 @@
# Copyright (C) 2005, International Business Machines Corporation and
# others. All Rights Reserved.
src/com/ibm/icu/dev/test/bigdec/DiagBigDecimal.java
src/com/ibm/icu/dev/test/format/GlobalizationPreferencesTest.java
src/com/ibm/icu/dev/test/format/NumberFormatRegressionTest.java
src/com/ibm/icu/dev/test/format/NumberFormatTest.java
src/com/ibm/icu/dev/test/util/ICUResourceBundleTest.java
src/com/ibm/icu/dev/test/util/UtilityTest.java
src/com/ibm/icu/dev/test/TestAll.java

3
icu4j/ee.foundation.jar Normal file
View file

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:7f730fd4a8ca71fcddc61a4f62490cea7805efffc7eb2b8669942f6d123f7249
size 1059077

View file

@ -0,0 +1,13 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: ICU4J Tests
Bundle-SymbolicName: com.ibm.icu.tests
Bundle-Version: 3.4.1
Bundle-Vendor: IBM
Bundle-Copyright: Licensed Materials - Property of IBM
(C) Copyright IBM Corp. 2000, 2005. All Rights Reserved.
IBM is a registered trademark of IBM Corp.
Bundle-Localization: plugin
Require-Bundle: org.junit,
com.ibm.icu
Bundle-ClassPath: icu4jtests.jar

View file

@ -0,0 +1,170 @@
/*
******************************************************************************
* Copyright (C) 2005, International Business Machines Corporation and *
* others. All Rights Reserved. *
******************************************************************************
*/
package com.ibm.icu.tests;
import junit.framework.TestCase;
import com.ibm.icu.dev.test.TestAll;
import com.ibm.icu.dev.test.TestFmwk;
import com.ibm.icu.dev.test.TestFmwk.TestParams;
import com.ibm.icu.dev.test.TestFmwk.NullWriter;
import com.ibm.icu.dev.test.TestFmwk.ASCIIWriter;
//import com.ibm.icu.text.DateFormat;
//import com.ibm.icu.util.Calendar;
//import com.ibm.icu.util.GregorianCalendar;
//import com.ibm.icu.util.TimeZone;
//import com.ibm.icu.util.ULocale;
public class UnitTest extends TestCase {
// public static void main(String[] args) throws Exception {
// String[] names = {
// "Calendar", "Collator", "Compression", "DiagBigDecimal", "Format", "Impl",
// "Normalizer", "Property", "RBBI", "SearchTest", "StringPrep", "TestCharsetDetector",
// "TestUCharacterIterator", "TimeScale", "TimeZone", "Translit", "Util",
// };
// for (int i = 0; i < names.length; ++i) {
// String name = names[i];
// System.out.println();
// System.out.println("public void test" + name + "() throws Exception {");
// System.out.println(" runUtility(\"" + name + "\");");
// System.out.println("}");
// }
// }
public void testCalendar() throws Exception {
runUtility("Calendar");
}
public void testCollator() throws Exception {
runUtility("Collator");
}
public void testCompression() throws Exception {
runUtility("Compression");
}
public void testDiagBigDecimal() throws Exception {
runUtility("DiagBigDecimal");
}
public void testFormat() throws Exception {
runUtility("Format");
}
public void testImpl() throws Exception {
runUtility("Impl");
}
public void testNormalizer() throws Exception {
runUtility("Normalizer");
}
public void testProperty() throws Exception {
runUtility("Property");
}
public void testRBBI() throws Exception {
runUtility("RBBI");
}
public void testSearchTest() throws Exception {
runUtility("SearchTest");
}
public void testStringPrep() throws Exception {
runUtility("StringPrep");
}
public void testTestCharsetDetector() throws Exception {
runUtility("TestCharsetDetector");
}
public void testTestUCharacterIterator() throws Exception {
runUtility("TestUCharacterIterator");
}
public void testTimeScale() throws Exception {
runUtility("TimeScale");
}
public void testTimeZone() throws Exception {
runUtility("TimeZone");
}
public void testTranslit() throws Exception {
runUtility("Translit");
}
public void testUtil() throws Exception {
runUtility("Util");
}
public void runUtility(String testname) throws Exception {
TestParams params = new TestParams();
params.nothrow = true;
params.log = new NullWriter();
TestFmwk test = new TestAll();
test.resolveTarget(params, testname).run();
if (params.errorCount > 0) {
fail(params.errorSummary.toString());
}
}
// sample tests from ICU4J test suite
// Calendar
// public void testCalendarSimple() throws Exception {
// TimeZone tz = TimeZone.getTimeZone("America/Los_Angeles");
// GregorianCalendar gc = new GregorianCalendar(tz);
// gc.set(2005,9,17,14,15,33);
// Date time = gc.getTime();
//
// final String[] calendars = {
// "buddhist", "chinese", "coptic", "ethiopic", "gregorian",
// "hebrew", "islamic", "islamic-civil", "japanese"
// };
// final String[] ustimes = {
// "Monday, October 17, 2548 BE 2:15:33 PM PDT",
// "Monday 22x78-9-15 2:15:33 PM PDT",
// "Monday, Baba 7, 1722 2:15:33 PM PDT",
// "Monday, Tekemt 7, 1998 2:15:33 PM PDT",
// "Monday, October 17, 2005 2:15:33 PM PDT",
// "Monday, Tishri 14, 5766 2:15:33 PM PDT",
// "Monday, Ramadan 14, 1426 2:15:33 PM PDT",
// "Monday, Ramadan 14, 1426 2:15:33 PM PDT",
// "Monday, October 17, 17 Heisei 2:15:33 PM PDT",
// };
// final String[] detimes = {
// "Montag, Oktober 17, 2548 BE 2:15:33 nachm. GMT-07:00",
// "Montag 22x78-9-15 2:15:33 nachm. GMT-07:00",
// "Montag, 7. Baba 1722 14:15 Uhr GMT-07:00",
// "Montag, 7. Tekemt 1998 14:15 Uhr GMT-07:00",
// "Montag, 17. Oktober 2005 14:15 Uhr GMT-07:00",
// "Montag, 14. Tishri 5766 14:15 Uhr GMT-07:00",
// "Montag, 14. Ramadan 1426 14:15 Uhr GMT-07:00",
// "Montag, 14. Ramadan 1426 14:15 Uhr GMT-07:00",
// "Montag, Oktober 17, 17 Heisei 2:15:33 nachm. GMT-07:00",
// };
//
// ULocale[] locales = {ULocale.US, ULocale.GERMANY };
// String[][] times = { ustimes, detimes };
// for (int j = 0; j < locales.length; ++j) {
// ULocale ul = new ULocale("en_US");
// for (int i = 0; i < calendars.length; ++i) {
// ul = ul.setKeywordValue("calendar", calendars[i]);
// Calendar cal = Calendar.getInstance(ul);
// DateFormat fmt = cal.getDateTimeFormat(DateFormat.FULL, DateFormat.FULL, locales[j]);
// String result = fmt.format(time);
// System.out.println(calendars[i] + ": " + result);
// if (!result.equals(times[j][i])) {
// fail("calendar: " + calendars[i]);
// }
// }
// }
// }
}

View file

@ -0,0 +1,19 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: International Components for Unicode for Java (ICU4J)
Bundle-SymbolicName: com.ibm.icu
Bundle-Version: 3.4.1
Bundle-Vendor: IBM
Bundle-Localization: plugin
Bundle-Copyright: Licensed Materials - Property of IBM
(C) Copyright IBM Corp. 2000, 2005. All Rights Reserved.
IBM is a registered trademark of IBM Corp.
Eclipse-AutoStart: true
Export-Package: com.ibm.icu.impl;x-friends:="com.ibm.icu.tests",
com.ibm.icu.impl.data;x-internal:=true,
com.ibm.icu.lang,
com.ibm.icu.math,
com.ibm.icu.text,
com.ibm.icu.util
Bundle-ClassPath: icu4j.jar
Eclipse-LazyStart: true

View file

@ -1,3 +1,4 @@
//##header 1132615047000
/*
*******************************************************************************
* Copyright (C) 1996-2005, International Business Machines Corporation and *
@ -38,7 +39,9 @@ public class TestAll extends TestGroup {
"com.ibm.icu.dev.test.stringprep.TestAll",
"com.ibm.icu.dev.test.timescale.TestAll",
"com.ibm.icu.dev.test.charsetdet.TestCharsetDetector",
//#ifndef FOUNDATION
"com.ibm.icu.dev.test.serializable.SerializableTest" // *is* a group
//#endif
},
"All tests in ICU");
}

View file

@ -1,3 +1,4 @@
//##header 1132615047000
/* Generated from 'DiagBigDecimal.nrx' 27 Mar 2000 22:38:44 [v1.162] */
/* Options: Binary Comments Crossref Format Java Logo Trace1 Verbose3 */
package com.ibm.icu.dev.test.bigdec;
@ -365,6 +366,7 @@ public class DiagBigDecimal extends TestFmwk{
(new Test("con006")).ok=(com.ibm.icu.math.BigDecimal.TEN.intValueExact())==10;
// [java.math.] BigDecimal
//#ifndef FOUNDATION
(new Test("cbd001")).ok=((new com.ibm.icu.math.BigDecimal(new java.math.BigDecimal("0"))).toString()).equals("0");
(new Test("cbd002")).ok=((new com.ibm.icu.math.BigDecimal(new java.math.BigDecimal("1"))).toString()).equals("1");
(new Test("cbd003")).ok=((new com.ibm.icu.math.BigDecimal(new java.math.BigDecimal("10"))).toString()).equals("10");
@ -384,6 +386,7 @@ public class DiagBigDecimal extends TestFmwk{
num="0.00000123456789";
(new Test("cbd013")).ok=((new com.ibm.icu.math.BigDecimal(new java.math.BigDecimal(num))).toString()).equals(num);
num="0.000000123456789";
// ignore format change issues with 1.5
if (!isJDK15OrLater)
(new Test("cbd014")).ok=((new com.ibm.icu.math.BigDecimal(new java.math.BigDecimal(num))).toString()).equals(num);
@ -396,6 +399,7 @@ public class DiagBigDecimal extends TestFmwk{
flag=true;
}/*checknull*/
(new Test("cbi015")).ok=flag;
//#endif
// BigInteger
bip=new BigInteger("987654321987654321987654321"); // biggie +ve
@ -550,6 +554,7 @@ public class DiagBigDecimal extends TestFmwk{
}/*checkbound3*/
(new Test("cca204")).ok=flag;
//#ifndef FOUNDATION
// double [deprecated]
// Note that many of these differ from the valueOf(double) results.
dzer=(double)0;
@ -604,7 +609,7 @@ public class DiagBigDecimal extends TestFmwk{
d=d/((double)10);
if (!isJDK15OrLater)
(new Test("cdo018")).ok=((new com.ibm.icu.math.BigDecimal(d)).toString()).equals("0.000000008999999999999997872197332322678764437995369007694534957408905029296875");
//#endif
try{checkpin:do{
new com.ibm.icu.math.BigDecimal(java.lang.Double.POSITIVE_INFINITY);
@ -4018,8 +4023,9 @@ public class DiagBigDecimal extends TestFmwk{
/* ----------------------------------------------------------------- */
/** Test the {@link com.ibm.icu.math.BigDecimal#toBigDecimal} method. */
public void diagtobigdecimal(){
//#ifndef FOUNDATION
(new Test("tbd001")).ok=((new com.ibm.icu.math.BigDecimal("0")).toBigDecimal().toString()).equals("0");
(new Test("tbd002")).ok=((new com.ibm.icu.math.BigDecimal("-1")).toBigDecimal().toString()).equals("-1");
(new Test("tbd003")).ok=((new com.ibm.icu.math.BigDecimal("+1")).toBigDecimal().toString()).equals("1");
@ -4033,7 +4039,9 @@ public class DiagBigDecimal extends TestFmwk{
(new Test("tbd009")).ok=((new com.ibm.icu.math.BigDecimal("1E10")).toBigDecimal().toString()).equals("10000000000");
(new Test("tbd010")).ok=((new com.ibm.icu.math.BigDecimal("1E12")).toBigDecimal().toString()).equals("1000000000000");
summary("toBigDecimal");
//#endif
}
/* ----------------------------------------------------------------- */
/** Test the {@link com.ibm.icu.math.BigDecimal#toBigInteger} method. */

View file

@ -2072,7 +2072,8 @@ public class DateFormatTest extends com.ibm.icu.dev.test.TestFmwk {
}
}
{
// TODO: revisit toLocalizedPattern
if (false) {
SimpleDateFormat fmt = new SimpleDateFormat("aabbcc");
try {
String pat = fmt.toLocalizedPattern();

View file

@ -1,3 +1,4 @@
//##header 1132615047000
/*
*******************************************************************************
* Copyright (C) 2004-2005, International Business Machines Corporation and *
@ -44,7 +45,7 @@ public class GlobalizationPreferencesTest {
out.println("\tWarning: some of this is just mockup -- real data will be accessed later.");
out.println();
//#ifndef FOUNDATION
out.println("Check defaulting");
String[] localeList = {"fr_BE;q=0.5,de", "fr_BE,de", "fr", "en_NZ", "en", "en-TH", "zh-Hant", "zh-MO", "zh", "it", "as", "haw", "ar-EG", "ar", "qqq"};
for (int i = 0; i < localeList.length; ++i) {
@ -59,6 +60,8 @@ public class GlobalizationPreferencesTest {
}
out.println();
//#endif
out.println("Date Formatting");
out.println("\tdate: \t" + lPreferences.getDateFormat(DateFormat.FULL, GlobalizationPreferences.NONE).format(now));
@ -142,4 +145,4 @@ public class GlobalizationPreferencesTest {
System.out.println("done");
}
}
}
}

View file

@ -1,3 +1,4 @@
//##header 1132615047000
/*
*******************************************************************************
* Copyright (C) 2001-2005, International Business Machines Corporation and *
@ -160,6 +161,7 @@ public class NumberFormatRegressionTest extends com.ibm.icu.dev.test.TestFmwk {
//Test New serialized DecimalFormat(2.0) read old serialized forms of DecimalFormat(1.3.1.1)
public void TestSerialization() throws IOException, ClassNotFoundException{
//#ifndef FOUNDATION
byte[][] contents = NumberFormatSerialTestData.getContent();
double data = 1234.56;
String[] expected = {
@ -178,5 +180,8 @@ public class NumberFormatRegressionTest extends com.ibm.icu.dev.test.TestFmwk {
warnln("FAIL: " + e.getMessage());
}
}
//#else
//## warnln("FOUNDATION");
//#endif
}
}
}

View file

@ -1,3 +1,4 @@
//##header 1132615047000
/*
*******************************************************************************
* Copyright (C) 2001-2005, International Business Machines Corporation and *
@ -847,7 +848,11 @@ public class NumberFormatTest extends com.ibm.icu.dev.test.TestFmwk {
expect2(df, 2.0, "2.00 *&' Rs. '&*");
expect2(df, -1.0, "-1.00 *&' Re. '&*");
//#ifndef FOUNDATION
java.math.BigDecimal r = df.getRoundingIncrement();
//#else
//## com.ibm.icu.math.BigDecimal r = df.getRoundingIncrement();
//#endif
if (r != null) {
errln("FAIL: rounding = " + r + ", expect null");
}

View file

@ -1,3 +1,4 @@
//##header 1132615047000
/**
*******************************************************************************
* Copyright (C) 2001-2005, International Business Machines Corporation and *
@ -14,7 +15,11 @@ import java.io.IOException;
import java.net.URL;
import java.net.URLConnection;
import java.net.JarURLConnection;
//#ifndef FOUNDATION
import java.nio.ByteBuffer;
//#else
//##import com.ibm.icu.impl.ByteBuffer;
//#endif
import java.util.MissingResourceException;
import java.util.Enumeration;
import java.util.jar.JarEntry;

View file

@ -1,3 +1,4 @@
//##header 1132615047000
/*
**********************************************************************
* Copyright (c) 2003-2005, International Business Machines
@ -112,7 +113,11 @@ public class UtilityTest extends TestFmwk {
{
byte[] ba = {0x00, 0x01, 0x02};
byte[] bb = {0x00, 0x01, 0x02, -1};
//#ifndef FOUNDATION
java.nio.ByteBuffer buffer = java.nio.ByteBuffer.wrap(ba);
//#else
//## com.ibm.icu.impl.ByteBuffer buffer = com.ibm.icu.impl.ByteBuffer.wrap(ba);
//#endif
ByteArrayWrapper x = new ByteArrayWrapper(buffer);
ByteArrayWrapper y = new ByteArrayWrapper(ba, 3);

View file

@ -17,8 +17,10 @@ import java.io.InputStreamReader;
import java.io.IOException;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.Map;
import java.util.HashMap;
import java.util.TreeMap;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@ -26,38 +28,48 @@ import java.util.regex.Pattern;
* A simple facility for adding C-like preprocessing to .java files.
* This only understands a subset of the C preprocessing syntax.
* Its used to manage files that with only small differences can be
* compiled for different JVMs. Input is generally a '.jpp' file,
* output is a '.java' file with the same name, that can then be
* compiled.
* compiled for different JVMs. This changes files in place,
* commenting out lines based on the current flag settings.
*/
public class CodeMangler {
private File indir; // root of input
private File outdir; // root of output
private String suffix; // suffix to process, default '.jpp'
private boolean recurse; // true if recurse on directories
private Map map; // defines
private boolean force; // true if force reprocess of files
private boolean clean; // true if output is to be cleaned
private HashMap map; // defines
private ArrayList names; // files/directories to process
private String header; // sorted list of defines passed in
private boolean verbose; // true if we emit debug output
private static final String IGNORE_PREFIX = "//##";
private static final String HEADER_PREFIX = "//##header";
public static void main(String[] args) {
new CodeMangler(args).run();
}
private static final String usage = "Usage:\n" +
" CodeMangler [flags] file... dir...\n" +
" CodeMangler [flags] file... dir... @argfile... \n" +
"-in[dir] path - root directory of input files, otherwise use current directory\n" +
"-out[dir] path - root directory of output files, otherwise use current directory\n" +
"-suffix string - suffix of files to process, otherwise use '.jpp' (directories only)\n" +
"-r - if present, recursively process subdirectories\n" +
"-d[efine] NAME[=VALUE] - define NAME with optional value VALUE\n" +
"-out[dir] path - root directory of output files, otherwise use input directory\n" +
"-s[uffix] string - suffix of inputfiles to process, otherwise use '.java' (directories only)\n" +
"-c[lean] - remove all control flags from code on output (does not proceed if overwriting)\n" +
"-r[ecurse] - if present, recursively process subdirectories\n" +
"-f[orce] - force reprocessing of files even if timestamp and headers match\n" +
"-dNAME[=VALUE] - define NAME with optional value VALUE\n" +
" (or -d NAME[=VALUE])\n" +
"-help - print this usage message and exit.\n" +
"\n" +
"For file arguments, output '.java' files using the same path/name under the output directory.\n" +
"For directory arguments, process all files with the defined suffix in the directory.\n" +
" (if recursing, do the same for all files recursively under each directory)\n" +
"For @argfile arguments, read the specified text file (strip the '@'), and process each line of that file as \n" +
"an argument.\n" +
"\n" +
"Directives in the file are one of the following:\n" +
"Directives are one of the following:\n" +
" #ifdef, #ifndef, #else, #endif, #if, #elif, #define, #undef\n" +
"These may optionally be preceeded by whitespace or //.\n" +
"#if, #elif args are of the form 'key == value' or 'key != value'.\n" +
@ -67,7 +79,8 @@ public class CodeMangler {
CodeMangler(String[] args) {
map = new HashMap();
names = new ArrayList();
suffix = ".jpp";
suffix = ".java";
clean = false;
String inname = null;
String outname = null;
@ -84,7 +97,10 @@ public class CodeMangler {
} else if (arg.startsWith("-out")) {
outname = args[++i];
} else if (arg.startsWith("-d")) {
String id = args[++i];
String id = arg.substring(2);
if (id.length() == 0) {
id = args[++i];
}
String val = "";
int ix = id.indexOf('=');
if (ix >= 0) {
@ -92,11 +108,15 @@ public class CodeMangler {
id = id.substring(0,ix);
}
map.put(id, val);
} else if ("-suffix".equals(arg)) {
} else if (arg.startsWith("-s")) {
suffix = args[++i];
} else if ("-r".equals(arg)) {
} else if (arg.startsWith("-r")) {
recurse = true;
} else if (arg.startsWith("-help")) {
} else if (arg.startsWith("-f")) {
force = true;
} else if (arg.startsWith("-c")) {
clean = true;
} else if (arg.startsWith("-h")) {
System.out.print(usage);
break; // stop before processing arguments, so we will do nothing
} else if (arg.startsWith("-v")) {
@ -107,7 +127,32 @@ public class CodeMangler {
throw new IllegalArgumentException(arg);
}
} else {
names.add(arg);
if (arg.charAt(0) == '@') {
File argfile = new File(arg.substring(1));
if (argfile.exists() && !argfile.isDirectory()) {
try {
BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(argfile)));
ArrayList list = new ArrayList();
for (int x = 0; x < args.length; ++x) {
list.add(args[x]);
}
String line;
while (null != (line = br.readLine())) {
line = line.trim();
if (line.length() > 0 && line.charAt(0) != '#') {
if (verbose) System.out.println("adding argument: " + line);
list.add(line);
}
}
args = (String[])list.toArray(new String[list.size()]);
}
catch (IOException e) {
System.err.println("error reading arg file: " + e);
}
}
} else {
names.add(arg);
}
}
}
} catch (IndexOutOfBoundsException e) {
@ -135,10 +180,10 @@ public class CodeMangler {
} else if (!indir.isDirectory()) {
throw new IllegalArgumentException("Input path '" + indir.getAbsolutePath() + "' is not a directory.");
}
if (verbose) System.err.println("indir: " + indir.getAbsolutePath());
if (verbose) System.out.println("indir: " + indir.getAbsolutePath());
if (outname == null) {
outname = username;
outname = inname;
} else if (!(outname.startsWith("\\") || outname.startsWith("/"))) {
outname = username + File.separator + outname;
}
@ -154,11 +199,42 @@ public class CodeMangler {
} else if (!outdir.isDirectory()) {
throw new IllegalArgumentException("Output path '" + outdir.getAbsolutePath() + "' is not a directory.");
}
if (verbose) System.err.println("outdir: " + outdir.getAbsolutePath());
if (verbose) System.out.println("outdir: " + outdir.getAbsolutePath());
if (clean && suffix.equals(".java")) {
try {
if (outdir.getCanonicalPath().equals(indir.getCanonicalPath())) {
throw new IllegalArgumentException("Cannot use 'clean' to overwrite .java files in same directory tree");
}
}
catch (IOException e) {
System.err.println("possible overwrite, error: " + e.getMessage());
throw new IllegalArgumentException("Cannot use 'clean' to overrwrite .java files");
}
}
if (names.isEmpty()) {
names.add(".");
}
TreeMap sort = new TreeMap(String.CASE_INSENSITIVE_ORDER);
sort.putAll(map);
Iterator iter = sort.entrySet().iterator();
StringBuffer buf = new StringBuffer();
while (iter.hasNext()) {
Map.Entry e = (Map.Entry)iter.next();
if (buf.length() > 0) {
buf.append(", ");
}
buf.append(e.getKey());
String v = (String)e.getValue();
if (v != null && v.length() > 0) {
buf.append('=');
buf.append(v);
}
}
header = buf.toString();
}
public int run() {
@ -166,10 +242,10 @@ public class CodeMangler {
}
public int process(String path, String[] filenames) {
if (verbose) System.err.println("path: '" + path + "'");
if (verbose) System.out.println("path: '" + path + "'");
int count = 0;
for (int i = 0; i < filenames.length; ++i) {
if (verbose) System.err.println("name " + i + " of " + filenames.length + ": '" + filenames[i] + "'");
if (verbose) System.out.println("name " + i + " of " + filenames.length + ": '" + filenames[i] + "'");
String name = path + filenames[i];
File fin = new File(indir, name);
try {
@ -182,7 +258,7 @@ public class CodeMangler {
continue;
}
if (fin.isFile()) {
if (verbose) System.err.println("processing file: '" + fin.getAbsolutePath() + "'");
if (verbose) System.out.println("processing file: '" + fin.getAbsolutePath() + "'");
String oname;
int ix = name.lastIndexOf(".");
if (ix != -1) {
@ -192,19 +268,11 @@ public class CodeMangler {
}
oname += ".java";
File fout = new File(outdir, oname);
String foutpname = fout.getParent();
if (foutpname != null) {
File foutp = new File(foutpname);
if (!(foutp.exists() || foutp.mkdirs())) {
System.err.println("could not create directory: '" + foutpname + "'");
continue;
}
}
if (processFile(fin, fout)) {
++count;
}
} else if (fin.isDirectory()) {
if (verbose) System.err.println("recursing on directory '" + fin.getAbsolutePath() + "'");
if (verbose) System.out.println("recursing on directory '" + fin.getAbsolutePath() + "'");
String npath = ".".equals(name) ? path : path + fin.getName() + File.separator;
count += process(npath, fin.list(filter)); // recursive call
}
@ -221,62 +289,121 @@ public class CodeMangler {
};
public boolean processFile(File infile, File outfile) {
Pattern pat = Pattern.compile(
"(?i)^\\s*(?://+)??\\s*#(ifdef\\s|ifndef\\s|else|endif|undef\\s|define\\s|if\\s|elif\\s)\\s*(.*)$");
Pattern pat2 = Pattern.compile("([^=!]+)\\s*([!=]=)??\\s*(\\w+)");
File backup = null;
class State {
int lc;
String line;
boolean emit = true;
boolean tripped;
private State next;
public String toString() {
return "line " + lc
+ ": '" + line
+ "' (emit: " + emit
+ " tripped: " + tripped
+ ")";
}
void trip(boolean trip) {
if (!tripped & trip) {
tripped = true;
emit = next != null ? next.emit : true;
} else {
emit = false;
}
}
State push(int lc, String line, boolean trip) {
this.lc = lc;
this.line = line;
State ret = new State();
ret.next = this;
ret.emit = this.emit & trip;
ret.tripped = trip;
return ret;
}
State pop() {
return next;
}
};
final Pattern pat = Pattern.compile(
"(?i)^(\\s*(?://+)??\\s*)#(ifdef\\s|ifndef\\s|else|endif|undef\\s|define\\s|if\\s|elif\\s)\\s*(.*)$");
final Pattern pat2 = Pattern.compile("([^=!]+)\\s*([!=]?=)??\\s*(\\w+)");
final Pattern pat3 = Pattern.compile("^(\\s*//##).*");
HashMap oldMap = null;
long outModTime = 0;
try {
PrintStream outstream = new PrintStream(new FileOutputStream(outfile));
PrintStream outstream = null;
InputStream instream = new FileInputStream(infile);
class State {
int lc;
String line;
boolean emit = true;
boolean tripped;
private State next;
BufferedReader reader = new BufferedReader(new InputStreamReader(instream));
int lc = 0;
State state = new State();
String line;
while ((line = reader.readLine()) != null) {
if (lc == 0) { // check and write header for output file if needed
boolean hasHeader = line.startsWith(HEADER_PREFIX);
if (hasHeader && !force) {
long expectLastModified = ((infile.lastModified() + 999)/1000)*1000;
String headerline = HEADER_PREFIX + ' ' + String.valueOf(expectLastModified) + ' ' + header;
if (line.equals(headerline)) {
if (verbose) System.out.println("no changes necessary to " + infile.getCanonicalPath());
instream.close();
return false; // nothing to do
}
if (verbose) {
System.out.println(" old header: " + line);
System.out.println(" != expected: " + headerline);
}
}
public String toString() {
return "line " + lc
+ ": '" + line
+ "' (emit: " + emit
+ " tripped: " + tripped
+ ")";
}
// create output file directory structure
String outpname = outfile.getParent();
if (outpname != null) {
File outp = new File(outpname);
if (!(outp.exists() || outp.mkdirs())) {
System.err.println("could not create directory: '" + outpname + "'");
return false;
}
}
void trip(boolean trip) {
if (!tripped & trip) {
tripped = true;
emit = next != null ? next.emit : true;
} else {
emit = false;
// if we're overwriting, use a temporary file
if (suffix.equals(".java")) {
backup = outfile;
try {
outfile = File.createTempFile(outfile.getName(), null, outfile.getParentFile());
}
catch (IOException ex) {
System.err.println(ex.getMessage());
return false;
}
}
outModTime = ((outfile.lastModified()+999)/1000)*1000; // round up
outstream = new PrintStream(new FileOutputStream(outfile));
String headerline = HEADER_PREFIX + ' ' + String.valueOf(outModTime) + ' ' + header;
outstream.println(headerline);
if (verbose) System.out.println("header: " + headerline);
// discard the old header if we had one, otherwise match this line like any other
if (hasHeader) {
++lc; // mark as having read a line so we never reexecute this block
continue;
}
}
State push(int lc, String line, boolean trip) {
this.lc = lc;
this.line = line;
State ret = new State();
ret.next = this;
ret.emit = this.emit & trip;
ret.tripped = trip;
return ret;
}
State pop() {
return next;
}
}
BufferedReader reader = new BufferedReader(new InputStreamReader(instream));
String line = null;
int lc = 0;
State state = new State();
while ((line = reader.readLine()) != null) {
Matcher m = pat.matcher(line);
if (m.find()) {
String key = m.group(1).toLowerCase().trim();
String val = m.group(2).trim();
if (verbose) outstream.println("directive: " + line
String lead = m.group(1);
String key = m.group(2).toLowerCase().trim();
String val = m.group(3).trim();
if (verbose) System.out.println("directive: " + line
+ " key: '" + key
+ "' val: '" + val
+ "' " + state);
@ -290,15 +417,18 @@ public class CodeMangler {
state = state.pop();
} else if (key.equals("undef")) {
if (state.emit) {
if (oldMap == null) {
oldMap = (HashMap)map.clone();
}
map.remove(val);
}
} else {
} else { // #define, #if, #elif
Matcher m2 = pat2.matcher(val);
if (m2.find()) {
String key2 = m2.group(1).trim();
boolean neq = "!=".equals(m2.group(2)); // optional
String val2 = m2.group(3).trim();
if (verbose) outstream.println("val2: '" + val2
if (verbose) System.out.println("val2: '" + val2
+ "' neq: '" + neq
+ "' key2: '" + key2
+ "'");
@ -308,32 +438,71 @@ public class CodeMangler {
state.trip(val2.equals(map.get(key2)) != neq);
} else if (key.equals("define")) {
if (state.emit) {
if (oldMap == null) {
oldMap = (HashMap)map.clone();
}
map.put(key2, val2);
}
}
}
}
if (!clean) {
lc++;
if (!lead.equals("//")) {
outstream.print("//");
line = line.substring(lead.length());
}
outstream.println(line);
}
continue;
}
lc++;
if (state.emit) {
m = pat3.matcher(line);
boolean hasIgnore = m.find();
if (state.emit == hasIgnore) {
if (state.emit) {
line = line.substring(m.group(1).length());
} else {
line = IGNORE_PREFIX + line;
}
} else if (hasIgnore && !m.group(1).equals(IGNORE_PREFIX)) {
line = IGNORE_PREFIX + line.substring(m.group(1).length());
}
if (!clean || state.emit) {
outstream.println(line);
} else {
if (verbose) outstream.println("skipping: " + line);
}
}
state = state.pop();
if (state != null) {
System.out.println("Error: unclosed directive(s):");
System.err.println("Error: unclosed directive(s):");
do {
System.err.println(state);
} while ((state = state.pop()) != null);
System.err.println(" in file: " + outfile.getCanonicalPath());
if (oldMap != null) {
map = oldMap;
}
outstream.close();
return false;
}
outstream.close();
instream.close();
if (backup != null) {
if (backup.exists()) {
backup.delete();
}
outfile.renameTo(backup);
}
outfile.setLastModified(outModTime); // synch with timestamp
if (oldMap != null) {
map = oldMap;
}
}
catch (IOException e) {
System.err.println(e);

View file

@ -1,3 +1,4 @@
//##header VERSION_1.4
/**
*******************************************************************************
* Copyright (C) 2002-2005, International Business Machines Corporation and *
@ -16,15 +17,15 @@ package com.ibm.icu.dev.tool.docs;
import com.sun.javadoc.*;
import com.sun.tools.doclets.*;
//#ifdef VERSION_1.5
import com.sun.tools.doclets.internal.toolkit.taglets.*;
import com.sun.tools.doclets.internal.toolkit.taglets.Taglet;
// jdk 1.5 contains both com.sun.tools.doclets.Taglet and
// com.sun.tools.doclets.internal.toolkit.taglets.Taglet.
// Their registration code casts to the second, not the first, and the
// second doesn't implement the first, so if you just implement the
// first, you die.
//##
//##import com.sun.tools.doclets.internal.toolkit.taglets.*;
//##import com.sun.tools.doclets.internal.toolkit.taglets.Taglet;
//##
//##// jdk 1.5 contains both com.sun.tools.doclets.Taglet and
//##// com.sun.tools.doclets.internal.toolkit.taglets.Taglet.
//##// Their registration code casts to the second, not the first, and the
//##// second doesn't implement the first, so if you just implement the
//##// first, you die.
//#endif
import java.text.BreakIterator;
@ -113,22 +114,22 @@ public abstract class ICUTaglet implements Taglet {
return null;
}
//#ifdef VERSION_1.5
public TagletOutput getTagletOutput(Tag tag, TagletWriter writer) throws IllegalArgumentException {
TagletOutput out = writer.getTagletOutputInstance();
out.setOutput(toString(tag));
return out;
}
public TagletOutput getTagletOutput(Doc holder, TagletWriter writer) throws IllegalArgumentException {
TagletOutput out = writer.getTagletOutputInstance();
Tag[] tags = holder.tags(getName());
if (tags.length == 0) {
return null;
}
out.setOutput(toString(tags[0]));
return out;
}
//##
//## public TagletOutput getTagletOutput(Tag tag, TagletWriter writer) throws IllegalArgumentException {
//## TagletOutput out = writer.getTagletOutputInstance();
//## out.setOutput(toString(tag));
//## return out;
//## }
//##
//## public TagletOutput getTagletOutput(Doc holder, TagletWriter writer) throws IllegalArgumentException {
//## TagletOutput out = writer.getTagletOutputInstance();
//## Tag[] tags = holder.tags(getName());
//## if (tags.length == 0) {
//## return null;
//## }
//## out.setOutput(toString(tags[0]));
//## return out;
//## }
//#endif
protected static final String STATUS = "<dt><b>Status:</b></dt>";

View file

@ -1,3 +1,4 @@
//##header 1132615046000
/*
*******************************************************************************
* Copyright (C) 1996-2005, International Business Machines Corporation and *
@ -12,8 +13,9 @@ import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.SortedSet;
//#ifndef FOUNDATION
import java.util.regex.Matcher;
//#endif
import com.ibm.icu.text.Transliterator;
import com.ibm.icu.text.UTF16;
import com.ibm.icu.text.UnicodeSet;
@ -378,6 +380,7 @@ public final class CollectionUtilities {
}
}
//#ifndef FOUNDATION
public static class RegexIterator extends FilteredIterator {
private Matcher matcher;
public RegexIterator set(Iterator baseIterator, Matcher matcher) {
@ -389,5 +392,5 @@ public final class CollectionUtilities {
return matcher.reset((String)item).matches();
}
}
}
//#endif
}

View file

@ -1,3 +1,4 @@
//##header 1132616027000
/*
* *****************************************************************************
* Copyright (C) 2005, International Business Machines Corporation and * others.
@ -13,7 +14,6 @@ import java.io.InputStreamReader;
import java.io.IOException;
import java.lang.ref.SoftReference;
import java.net.URL;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@ -25,8 +25,12 @@ import java.util.Map;
import java.util.MissingResourceException;
import java.util.Set;
import java.util.Vector;
import java.util.regex.Pattern;
//#ifndef FOUNDATION
import java.nio.ByteBuffer;
//#else
//##import com.ibm.icu.impl.ByteBuffer;
//#endif
import com.ibm.icu.impl.URLHandler.URLVisitor;
import com.ibm.icu.util.StringTokenizer;
import com.ibm.icu.util.ULocale;
@ -959,9 +963,8 @@ public abstract class ICUResourceBundle extends UResourceBundle {
if (handler != null) {
final ArrayList list = new ArrayList();
URLVisitor v = new URLVisitor() {
private Pattern p = Pattern.compile(".*\\.res");
public void visit(String s) {
if (p.matcher(s).matches() && !"res_index.res".equals(s)) {
if (s.endsWith(".res") && !"res_index.res".equals(s)) {
list.add(s.substring(0, s.length() - 4)); // strip '.res'
}
}

View file

@ -1,3 +1,4 @@
//##header 1132616027000
/*
******************************************************************************
* Copyright (C) 2004-2005, International Business Machines Corporation and *
@ -6,7 +7,6 @@
*/
package com.ibm.icu.impl;
import java.nio.ByteBuffer;
import java.util.HashMap;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
@ -15,6 +15,11 @@ import com.ibm.icu.util.StringTokenizer;
import com.ibm.icu.util.ULocale;
import com.ibm.icu.util.UResourceBundle;
import com.ibm.icu.util.UResourceTypeMismatchException;
//#ifndef FOUNDATION
import java.nio.ByteBuffer;
//#endif
/**
* @author ram
*/
@ -27,6 +32,8 @@ public class ICUResourceBundleImpl extends ICUResourceBundle {
private ULocale ulocale;
private ClassLoader loader;
private static final boolean ASSERT = false;
/**
*
* @param baseName
@ -500,7 +507,7 @@ public class ICUResourceBundleImpl extends ICUResourceBundle {
}
private static int getInt(byte[] data, int offset){
assert offset < data.length;
if (ASSERT) Assert.assrt("offset < data.length", offset < data.length);
return makeInt(data[offset], data[offset+1],
data[offset+2], data[offset+3]);
}
@ -515,7 +522,7 @@ public class ICUResourceBundleImpl extends ICUResourceBundle {
int length = ICUResourceBundleImpl.getInt(rawData,offset);
int byteOffset = offset + getIntOffset(1);
byte[] dst = new byte[length];
assert byteOffset+length < rawData.length;
if (ASSERT) Assert.assrt("byteOffset+length < rawData.length", byteOffset+length < rawData.length);
System.arraycopy(rawData, byteOffset, dst, 0, length);
return dst;
}
@ -551,7 +558,7 @@ public class ICUResourceBundleImpl extends ICUResourceBundle {
int[] val = new int[length];
int byteLength = getIntOffset(length);
assert (intOffset+byteLength)<rawData.length;
if (ASSERT) Assert.assrt("(intOffset+byteLength)<rawData.length", (intOffset+byteLength)<rawData.length);
for(int i=0; i<length;i++){
val[i]=ICUResourceBundleImpl.getInt(rawData, intOffset+getIntOffset(i));
@ -584,7 +591,7 @@ public class ICUResourceBundleImpl extends ICUResourceBundle {
int length = getInt(rawData,offset);
int stringOffset = offset + getIntOffset(1);
char[] dst = new char[length];
assert (stringOffset+getCharOffset(length)) < rawData.length;
if (ASSERT) Assert.assrt("(stringOffset+getCharOffset(length)) < rawData.length", (stringOffset+getCharOffset(length)) < rawData.length);
for(int i=0; i<length; i++){
dst[i]=getChar(rawData, stringOffset+getCharOffset(i));
}

View file

@ -1,3 +1,4 @@
//##header 1132615046000
/*
*******************************************************************************
* Copyright (C) 2004-2005, International Business Machines Corporation and *
@ -154,7 +155,11 @@ public final class ICUResourceBundleReader implements ICUBinary.Authenticate{
stream.close();
}catch(IOException ex){
//#ifndef FOUNDATION
throw new RuntimeException("Data file "+ resolvedName+ " is corrupt.", ex);
//#else
//## throw new RuntimeException("Data file "+ resolvedName+ " is corrupt.");
//#endif
}
}
public static ICUResourceBundleReader getReader(String baseName, String localeName, ClassLoader root){

View file

@ -8,7 +8,6 @@ package com.ibm.icu.impl;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.nio.ByteBuffer;
import java.util.Date;
import com.ibm.icu.util.Calendar;
@ -111,6 +110,8 @@ public class OlsonTimeZone extends TimeZone {
// Generated by serialver from JDK 1.4.1_01
static final long serialVersionUID = -6281977362477515376L;
private static final boolean ASSERT = false;
/* (non-Javadoc)
* @see com.ibm.icu.util.TimeZone#getOffset(int, int, int, int, int, int)
*/
@ -146,7 +147,7 @@ public class OlsonTimeZone extends TimeZone {
}
if (year > finalYear) { // [sic] >, not >=; see above
assert(finalZone != null);
if (ASSERT) Assert.assrt("(finalZone != null)", finalZone != null);
return finalZone.getOffset(era, year, month, dom, dow,
millis, monthLength);
}
@ -225,7 +226,7 @@ public class OlsonTimeZone extends TimeZone {
double remainder;
double[] ret = new double[2];
// Only designed to work for positive divisors
assert(divisor > 0);
if (ASSERT) Assert.assrt("divisor > 0", divisor > 0);
double quotient = Math.floor(dividend/divisor);
remainder = dividend - (quotient * divisor);
// N.B. For certain large dividends, on certain platforms, there
@ -252,7 +253,7 @@ public class OlsonTimeZone extends TimeZone {
remainder = dividend - (quotient * divisor);
}
}
assert(0 <= remainder && remainder < divisor);
if (ASSERT) Assert.assrt("0 <= remainder && remainder < divisor", 0 <= remainder && remainder < divisor);
ret[0]=quotient;
ret[1]=remainder;
return ret;
@ -282,7 +283,7 @@ public class OlsonTimeZone extends TimeZone {
int year=it[0], month=it[1], dom=it[2], dow=it[3];
if (year > finalYear) { // [sic] >, not >=; see above
assert(finalZone != null && finalZone.useDaylightTime());
if (ASSERT) Assert.assrt("finalZone != null && finalZone.useDaylightTime()", finalZone != null && finalZone.useDaylightTime());
return true;
}
@ -406,7 +407,7 @@ public class OlsonTimeZone extends TimeZone {
// using > rather than >=. This allows us to use
// INT32_MAX as an exclusive upper limit for all
// years, including INT32_MAX.
assert(data[1] > Integer.MIN_VALUE);
if (ASSERT) Assert.assrt("data[1] > Integer.MIN_VALUE", data[1] > Integer.MIN_VALUE);
finalYear = data[1] - 1;
// Also compute the millis for Jan 1, 0:00 GMT of the
// finalYear. This reduces runtime computations.
@ -482,17 +483,21 @@ public class OlsonTimeZone extends TimeZone {
}
}
assert(i>=0 && i<transitionCount);
if (ASSERT) Assert.assrt("i>=0 && i<transitionCount", i>=0 && i<transitionCount);
// Check invariants for GMT times; if these pass for GMT times
// the local logic should be working too.
assert(local || time < transitionTimes[0] || time >= transitionTimes[i]);
assert(local || i == transitionCount-1 || time < transitionTimes[i+1]);
if (ASSERT) {
Assert.assrt("local || time < transitionTimes[0] || time >= transitionTimes[i]",
local || time < transitionTimes[0] || time >= transitionTimes[i]);
Assert.assrt("local || i == transitionCount-1 || time < transitionTimes[i+1]",
local || i == transitionCount-1 || time < transitionTimes[i+1]);
}
i = typeData[i];
}
assert(i>=0 && i<typeCount);
if (ASSERT) Assert.assrt("i>=0 && i<typeCount", i>=0 && i<typeCount);
return i;
}
@ -508,7 +513,46 @@ public class OlsonTimeZone extends TimeZone {
return typeOffsets[(int)((index << 1) + 1)];
}
// temp
public String toString() {
StringBuffer buf = new StringBuffer();
buf.append(super.toString());
buf.append('[');
buf.append("transitionCount=" + transitionCount);
buf.append(",typeCount=" + typeCount);
buf.append(",transitionTimes=");
if (transitionTimes != null) {
buf.append('[');
for (int i = 0; i < transitionTimes.length; ++i) {
if (i > 0) {
buf.append(',');
}
buf.append(Integer.toString(transitionTimes[i]));
}
buf.append(']');
} else {
buf.append("null");
}
buf.append(",typeOffsets=");
if (typeOffsets != null) {
buf.append('[');
for (int i = 0; i < typeOffsets.length; ++i) {
if (i > 0) {
buf.append(',');
}
buf.append(Integer.toString(typeOffsets[i]));
}
buf.append(']');
} else {
buf.append("null");
}
buf.append(",finalYear=" + finalYear);
buf.append(",finalMillis=" + finalMillis);
buf.append(",finalZone=" + finalZone);
buf.append(']');
return buf.toString();
}
/**
* Number of transitions, 0..~370
*/

View file

@ -1,3 +1,4 @@
//##header 1132615046000
/*
*******************************************************************************
* Copyright (C) 1996-2005, International Business Machines Corporation and *
@ -1799,5 +1800,65 @@ public final class Utility {
}
return result.toString();
}
// !!! 1.3 compatibiliy
public static int indexOf(StringBuffer buf, String s) {
//#ifndef FOUNDATION
return buf.indexOf(s);
//#else
//## return buf.toString().indexOf(s);
//#endif
}
// !!! 1.3 compatibiliy
public static int lastIndexOf(StringBuffer buf, String s) {
//#ifndef FOUNDATION
return buf.lastIndexOf(s);
//#else
//## return buf.toString().lastIndexOf(s);
//#endif
}
// !!! 1.3 compatibiliy
public static int indexOf(StringBuffer buf, String s, int i) {
//#ifndef FOUNDATION
return buf.indexOf(s, i);
//#else
//## return buf.toString().indexOf(s, i);
//#endif
}
// !!! 1.3 compatibiliy
public static int lastIndexOf(StringBuffer buf, String s, int i) {
//#ifndef FOUNDATION
return buf.lastIndexOf(s, i);
//#else
//## return buf.toString().lastIndexOf(s, i);
//#endif
}
// !!! 1.3 compatibiliy
public static String replaceAll(String src, String target, String replacement) {
//#ifndef FOUNDATION
return src.replaceAll(target, replacement);
//#else
//## int i = src.indexOf(target);
//## if (i == -1) {
//## return src;
//## }
//## StringBuffer buf = new StringBuffer();
//## int n = 0;
//## do {
//## buf.append(src.substring(n, i));
//## buf.append(replacement);
//## n = i + target.length();
//## i = src.indexOf(target, n);
//## } while (i != -1);
//## if (n < src.length()) {
//## buf.append(src.substring(n));
//## }
//## return buf.toString();
//#endif
}
}
///CLOVER:ON

View file

@ -45,6 +45,7 @@ import com.ibm.icu.util.UResourceBundle;
* @since ICU 2.8
*/
public final class ZoneMeta {
private static final boolean ASSERT = false;
/**
* Returns a String array containing all system TimeZone IDs
@ -66,10 +67,11 @@ public final class ZoneMeta {
ICUResourceBundle names = top.get(kNAMES); // dereference Zones section
ICUResourceBundle temp = regions.get(country);
int[] vector = temp.getIntVector();
assert(vector.length>0);
if (ASSERT) Assert.assrt("vector.length>0", vector.length>0);
String[] ret = new String[vector.length];
for (int i=0; i<vector.length; ++i) {
assert(vector[i] >= 0 && vector[i] < OLSON_ZONE_COUNT);
if (ASSERT) Assert.assrt("vector[i] >= 0 && vector[i] < OLSON_ZONE_COUNT",
vector[i] >= 0 && vector[i] < OLSON_ZONE_COUNT);
ret[i] = names.getString(vector[i]);
}
return ret;

View file

@ -1,3 +1,4 @@
//##header 1132615046000
/**
*******************************************************************************
* Copyright (C) 1996-2005, International Business Machines Corporation and *
@ -2949,7 +2950,8 @@ public final class UCharacter implements ECharacterCategory, ECharacterDirection
* @deprecated (Java)
*/
public static boolean isSpace(int ch) {
return java.lang.Character.isSpace((char)(ch & 0xffff));
return ch <= 0x20 &&
(ch == 0x20 || ch == 0x09 || ch == 0x0a || ch == 0x0c || ch == 0x0d);
}
/**
@ -5266,7 +5268,11 @@ public final class UCharacter implements ECharacterCategory, ECharacterDirection
* @draft ICU 3.0
* @deprecated This is a draft API and might change in a future release of ICU.
*/
//#ifndef FOUNDATION
public static final int codePointAt(CharSequence seq, int index) {
//#else
//## public static final int codePointAt(String seq, int index) {
//#endif
char c1 = seq.charAt(index++);
if (isHighSurrogate(c1)) {
if (index < seq.length()) {
@ -5278,6 +5284,11 @@ public final class UCharacter implements ECharacterCategory, ECharacterDirection
}
return c1;
}
//#ifdef FOUNDATION
//## public static final int codePointAt(StringBuffer seq, int index) {
//## return codePointAt(seq.toString(), index);
//## }
//#endif
/**
* Cover the JDK 1.5 API, for convenience. Return the code point at index.
@ -5339,7 +5350,11 @@ public final class UCharacter implements ECharacterCategory, ECharacterDirection
* @draft ICU 3.0
* @deprecated This is a draft API and might change in a future release of ICU.
*/
//#ifndef FOUNDATION
public static final int codePointBefore(CharSequence seq, int index) {
//#else
//## public static final int codePointBefore(String seq, int index) {
//#endif
char c2 = seq.charAt(--index);
if (isLowSurrogate(c2)) {
if (index > 0) {
@ -5351,6 +5366,11 @@ public final class UCharacter implements ECharacterCategory, ECharacterDirection
}
return c2;
}
//#ifdef FOUNDATION
//## public static final int codePointBefore(StringBuffer seq, int index) {
//## return codePointBefore(seq.toString(), index);
//## }
//#endif
/**
* Cover the JDK 1.5 API, for convenience. Return the code point before index.
@ -5479,25 +5499,29 @@ public final class UCharacter implements ECharacterCategory, ECharacterDirection
* @draft ICU 3.0
* @deprecated This is a draft API and might change in a future release of ICU.
*/
//#ifndef FOUNDATION
public static int codePointCount(CharSequence text, int start, int limit) {
if (start < 0 || limit < start || limit > text.length()) {
throw new IndexOutOfBoundsException("start (" + start +
") or limit (" + limit +
") invalid or out of range 0, " + text.length());
}
//#else
//## public static int codePointCount(String text, int start, int limit) {
//#endif
if (start < 0 || limit < start || limit > text.length()) {
throw new IndexOutOfBoundsException("start (" + start +
") or limit (" + limit +
") invalid or out of range 0, " + text.length());
}
int len = limit - start;
while (limit > start) {
char ch = text.charAt(--limit);
while (ch >= MIN_LOW_SURROGATE && ch <= MAX_LOW_SURROGATE && limit > start) {
ch = text.charAt(--limit);
if (ch >= MIN_HIGH_SURROGATE && ch <= MAX_HIGH_SURROGATE) {
--len;
break;
int len = limit - start;
while (limit > start) {
char ch = text.charAt(--limit);
while (ch >= MIN_LOW_SURROGATE && ch <= MAX_LOW_SURROGATE && limit > start) {
ch = text.charAt(--limit);
if (ch >= MIN_HIGH_SURROGATE && ch <= MAX_HIGH_SURROGATE) {
--len;
break;
}
}
}
}
}
return len;
return len;
}
/**
@ -5510,24 +5534,24 @@ public final class UCharacter implements ECharacterCategory, ECharacterDirection
* @deprecated This is a draft API and might change in a future release of ICU.
*/
public static int codePointCount(char[] text, int start, int limit) {
if (start < 0 || limit < start || limit > text.length) {
throw new IndexOutOfBoundsException("start (" + start +
") or limit (" + limit +
") invalid or out of range 0, " + text.length);
}
if (start < 0 || limit < start || limit > text.length) {
throw new IndexOutOfBoundsException("start (" + start +
") or limit (" + limit +
") invalid or out of range 0, " + text.length);
}
int len = limit - start;
while (limit > start) {
char ch = text[--limit];
while (ch >= MIN_LOW_SURROGATE && ch <= MAX_LOW_SURROGATE && limit > start) {
ch = text[--limit];
if (ch >= MIN_HIGH_SURROGATE && ch <= MAX_HIGH_SURROGATE) {
--len;
break;
int len = limit - start;
while (limit > start) {
char ch = text[--limit];
while (ch >= MIN_LOW_SURROGATE && ch <= MAX_LOW_SURROGATE && limit > start) {
ch = text[--limit];
if (ch >= MIN_HIGH_SURROGATE && ch <= MAX_HIGH_SURROGATE) {
--len;
break;
}
}
}
}
}
return len;
return len;
}
/**
@ -5539,40 +5563,44 @@ public final class UCharacter implements ECharacterCategory, ECharacterDirection
* @draft ICU 3.0
* @deprecated This is a draft API and might change in a future release of ICU.
*/
//#ifndef FOUNDATION
public static int offsetByCodePoints(CharSequence text, int index, int codePointOffset) {
if (index < 0 || index > text.length()) {
throw new IndexOutOfBoundsException("index ( " + index +
") out of range 0, " + text.length());
}
//#else
//## public static int offsetByCodePoints(String text, int index, int codePointOffset) {
//#endif
if (index < 0 || index > text.length()) {
throw new IndexOutOfBoundsException("index ( " + index +
") out of range 0, " + text.length());
}
if (codePointOffset < 0) {
while (++codePointOffset <= 0) {
char ch = text.charAt(--index);
while (ch >= MIN_LOW_SURROGATE && ch <= MAX_LOW_SURROGATE && index > 0) {
ch = text.charAt(--index);
if (ch < MIN_HIGH_SURROGATE || ch > MAX_HIGH_SURROGATE) {
if (++codePointOffset > 0) {
return index+1;
if (codePointOffset < 0) {
while (++codePointOffset <= 0) {
char ch = text.charAt(--index);
while (ch >= MIN_LOW_SURROGATE && ch <= MAX_LOW_SURROGATE && index > 0) {
ch = text.charAt(--index);
if (ch < MIN_HIGH_SURROGATE || ch > MAX_HIGH_SURROGATE) {
if (++codePointOffset > 0) {
return index+1;
}
}
}
}
} else {
int limit = text.length();
while (--codePointOffset >= 0) {
char ch = text.charAt(index++);
while (ch >= MIN_HIGH_SURROGATE && ch <= MAX_HIGH_SURROGATE && index < limit) {
ch = text.charAt(index++);
if (ch < MIN_LOW_SURROGATE || ch > MAX_LOW_SURROGATE) {
if (--codePointOffset < 0) {
return index-1;
}
}
}
}
}
}
} else {
int limit = text.length();
while (--codePointOffset >= 0) {
char ch = text.charAt(index++);
while (ch >= MIN_HIGH_SURROGATE && ch <= MAX_HIGH_SURROGATE && index < limit) {
ch = text.charAt(index++);
if (ch < MIN_LOW_SURROGATE || ch > MAX_LOW_SURROGATE) {
if (--codePointOffset < 0) {
return index-1;
}
}
}
}
}
return index;
return index;
}
/**
@ -5587,51 +5615,51 @@ public final class UCharacter implements ECharacterCategory, ECharacterDirection
* @deprecated This is a draft API and might change in a future release of ICU.
*/
public static int offsetByCodePoints(char[] text, int start, int count, int index, int codePointOffset) {
int limit = start + count;
if (start < 0 || limit < start || limit > text.length || index < start || index > limit) {
throw new IndexOutOfBoundsException("index ( " + index +
") out of range " + start +
", " + limit +
" in array 0, " + text.length);
}
if (codePointOffset < 0) {
while (++codePointOffset <= 0) {
char ch = text[--index];
if (index < start) {
int limit = start + count;
if (start < 0 || limit < start || limit > text.length || index < start || index > limit) {
throw new IndexOutOfBoundsException("index ( " + index +
") < start (" + start +
")");
") out of range " + start +
", " + limit +
" in array 0, " + text.length);
}
while (ch >= MIN_LOW_SURROGATE && ch <= MAX_LOW_SURROGATE && index > start) {
ch = text[--index];
if (ch < MIN_HIGH_SURROGATE || ch > MAX_HIGH_SURROGATE) {
if (++codePointOffset > 0) {
return index+1;
}
}
}
}
} else {
while (--codePointOffset >= 0) {
char ch = text[index++];
if (index > limit) {
throw new IndexOutOfBoundsException("index ( " + index +
") > limit (" + limit +
")");
}
while (ch >= MIN_HIGH_SURROGATE && ch <= MAX_HIGH_SURROGATE && index < limit) {
ch = text[index++];
if (ch < MIN_LOW_SURROGATE || ch > MAX_LOW_SURROGATE) {
if (--codePointOffset < 0) {
return index-1;
}
}
}
}
}
return index;
if (codePointOffset < 0) {
while (++codePointOffset <= 0) {
char ch = text[--index];
if (index < start) {
throw new IndexOutOfBoundsException("index ( " + index +
") < start (" + start +
")");
}
while (ch >= MIN_LOW_SURROGATE && ch <= MAX_LOW_SURROGATE && index > start) {
ch = text[--index];
if (ch < MIN_HIGH_SURROGATE || ch > MAX_HIGH_SURROGATE) {
if (++codePointOffset > 0) {
return index+1;
}
}
}
}
} else {
while (--codePointOffset >= 0) {
char ch = text[index++];
if (index > limit) {
throw new IndexOutOfBoundsException("index ( " + index +
") > limit (" + limit +
")");
}
while (ch >= MIN_HIGH_SURROGATE && ch <= MAX_HIGH_SURROGATE && index < limit) {
ch = text[index++];
if (ch < MIN_LOW_SURROGATE || ch > MAX_LOW_SURROGATE) {
if (--codePointOffset < 0) {
return index-1;
}
}
}
}
}
return index;
}
// protected data members --------------------------------------------

View file

@ -1,3 +1,4 @@
//##header 1132615046000
/* Generated from 'BigDecimal.nrx' 8 Sep 2000 11:10:50 [v2.00] */
/* Options: Binary Comments Crossref Format Java Logo Strictargs Strictcase Trace2 Verbose3 */
package com.ibm.icu.math;
@ -449,6 +450,7 @@ public class BigDecimal extends java.lang.Number implements java.io.Serializable
/* Constructors */
/* ---------------------------------------------------------------- */
//#ifndef FOUNDATION
/**
* Constructs a <code>BigDecimal</code> object from a
* <code>java.math.BigDecimal</code>.
@ -471,6 +473,7 @@ public class BigDecimal extends java.lang.Number implements java.io.Serializable
public BigDecimal(java.math.BigDecimal bd){
this(bd.toString());
return;}
//#ENDIF
/**
* Constructs a <code>BigDecimal</code> object from a
@ -828,9 +831,12 @@ public class BigDecimal extends java.lang.Number implements java.io.Serializable
// 2000.01.01: note that this constructor does give an exact result,
// so perhaps it should not be deprecated
// 2000.06.18: no longer deprecated
//#ifndef FOUNDATION
this((new java.math.BigDecimal(num)).toString());
//#else
//## this(String.valueOf(num));
//#endif
return;}
/**
* Constructs a <code>BigDecimal</code> object directly from a
* <code>int</code>.
@ -3140,6 +3146,7 @@ public class BigDecimal extends java.lang.Number implements java.io.Serializable
return (int)this.ind; // [note this assumes values for ind.]
}
//#ifndef FOUNDATION
/**
* Converts this <code>BigDecimal</code> to a
* <code>java.math.BigDecimal</code>.
@ -3162,6 +3169,7 @@ public class BigDecimal extends java.lang.Number implements java.io.Serializable
public java.math.BigDecimal toBigDecimal(){
return new java.math.BigDecimal(this.unscaledValue(),this.scale());
}
//#ENDIF
/**
* Converts this <code>BigDecimal</code> to a

View file

@ -12,6 +12,7 @@ import java.util.Locale;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
import com.ibm.icu.impl.Assert;
import com.ibm.icu.impl.ICUData;
import com.ibm.icu.impl.ICULocaleData;
import com.ibm.icu.impl.ICULocaleService;
@ -29,6 +30,7 @@ import com.ibm.icu.util.ULocale;
* Window>Preferences>Java>Code Generation.
*/
final class BreakIteratorFactory extends BreakIterator.BreakIteratorServiceShim {
private static final boolean ASSERT = false;
public Object registerInstance(BreakIterator iter, ULocale locale, int kind) {
iter.setText(new java.text.StringCharacterIterator(""));
@ -156,10 +158,10 @@ final class BreakIteratorFactory extends BreakIterator.BreakIteratorServiceShim
iter = new DictionaryBasedBreakIterator(rules, dictionary);
}
catch(IOException e) {
assert false : e;
if (ASSERT) Assert.fail(e);
}
catch(MissingResourceException e) {
assert false : e;
if (ASSERT) Assert.fail(e);
}
// TODO: we don't have 'bad' resource data, so this should never happen
// in our current tests.

View file

@ -19,9 +19,9 @@ import com.ibm.icu.impl.ZoneMeta;
import com.ibm.icu.util.ULocale;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Locale;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
@ -675,7 +675,7 @@ public class DateFormatSymbols implements Serializable, Cloneable {
public void setZoneStrings(String[][] newZoneStrings) {
zoneStrings = duplicate(newZoneStrings);
if(zoneStringsHash==null){
zoneStringsHash = new LinkedHashMap();
zoneStringsHash = new HashMap();
}
initZoneStrings(newZoneStrings);
// reset the zone strings.
@ -966,7 +966,7 @@ public class DateFormatSymbols implements Serializable, Cloneable {
}
zoneStrings = new String[zoneStringsHash.size()][8];
int i = 0;
for (Iterator it = zoneStringsHash.keySet().iterator(); it.hasNext();) {
for (Iterator it = zoneStringsKeyList.iterator(); it.hasNext();) {
String key = (String)it.next();
String[] strings = (String[])zoneStringsHash.get(key);
zoneStrings[i][0] = key;
@ -990,13 +990,14 @@ public class DateFormatSymbols implements Serializable, Cloneable {
}
private void initZoneStringsHash(){
zoneStringsHash = new LinkedHashMap();
zoneStringsHash = new HashMap();
zoneStringsKeyList = new ArrayList();
for (ULocale tempLocale = requestedLocale; tempLocale != null; tempLocale = tempLocale.getFallback()) {
ICUResourceBundle bundle = (ICUResourceBundle)UResourceBundle.getBundleInstance(ICUResourceBundle.ICU_BASE_NAME, tempLocale);
ICUResourceBundle zoneStringsBundle = bundle.getWithFallback("zoneStrings");
for(int i=0; i<zoneStringsBundle.getSize(); i++){
ICUResourceBundle zoneTable = zoneStringsBundle.get(i);
String key = zoneTable.getKey().replaceAll(":","/");
String key = Utility.replaceAll(zoneTable.getKey(),":","/");
// hack for the root zone strings
if(key.length()==0|| zoneTable.getType()!=ICUResourceBundle.TABLE){
continue;
@ -1039,14 +1040,18 @@ public class DateFormatSymbols implements Serializable, Cloneable {
}
if(!zoneStringsHash.containsKey(key)){
zoneStringsHash.put(key, strings); // only add if we don't have already
zoneStringsKeyList.add(key);
}
}
}
}
private ArrayList zoneStringsKeyList;
private void initZoneStrings(String[][] newZoneStrings){
if(newZoneStrings==null){
return;
}
zoneStringsKeyList = new ArrayList();
for(int row=0; row<newZoneStrings.length; row++){
String key = newZoneStrings[row][0];
String[] strings = (String[])zoneStringsHash.get(key);
@ -1091,6 +1096,7 @@ public class DateFormatSymbols implements Serializable, Cloneable {
}
}
zoneStringsHash.put(key, strings);
zoneStringsKeyList.add(key);
}
}
Iterator getZoneStringIDs(){
@ -1300,7 +1306,7 @@ public class DateFormatSymbols implements Serializable, Cloneable {
dst.standaloneNarrowWeekdays = duplicate(src.standaloneNarrowWeekdays);
dst.ampms = duplicate(src.ampms);
if(src.zoneStringsHash != null){
dst.zoneStringsHash = (LinkedHashMap)src.zoneStringsHash.clone();
dst.zoneStringsHash = (HashMap)src.zoneStringsHash.clone();
}
dst.requestedLocale = new ULocale(src.requestedLocale.toString());
//dst.zoneStrings = duplicate(src.zoneStrings);
@ -1474,7 +1480,7 @@ public class DateFormatSymbols implements Serializable, Cloneable {
String fullName = calendarClass.getName();
int lastDot = fullName.lastIndexOf('.');
String className = fullName.substring(lastDot+1);
String calType = className.replaceAll("Calendar","").toLowerCase();
String calType = Utility.replaceAll(className, "Calendar", "").toLowerCase();
initializeData(locale, calType);
}

View file

@ -1,3 +1,4 @@
//##header 1132616027000
/*
*******************************************************************************
* Copyright (C) 1996-2005, International Business Machines Corporation and *
@ -18,6 +19,7 @@ import java.math.BigInteger;
import java.util.Locale;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
/**
* <code>DecimalFormat</code> is a concrete subclass of
@ -581,9 +583,9 @@ import java.io.ObjectInputStream;
* not affect parsing or change any numerical values.
*
* <li>A <em>rounding mode</em> determines how values are rounded; see the
* {@link java.math.BigDecimal} documentation for a description of the
* {@link com.ibm.icu.math.BigDecimal} documentation for a description of the
* modes. Rounding increments specified in patterns use the default mode,
* {@link java.math.BigDecimal#ROUND_HALF_EVEN}.
* {@link com.ibm.icu.math.BigDecimal#ROUND_HALF_EVEN}.
*
* <li>Some locales use rounding in their currency formats to reflect the
* smallest currency denomination.
@ -781,17 +783,17 @@ public class DecimalFormat extends NumberFormat {
int mode, boolean isNegative) {
double div = number / roundingInc;
switch (mode) {
case java.math.BigDecimal.ROUND_CEILING:
case com.ibm.icu.math.BigDecimal.ROUND_CEILING:
return (isNegative ? Math.floor(div) : Math.ceil(div))
* roundingInc;
case java.math.BigDecimal.ROUND_FLOOR:
case com.ibm.icu.math.BigDecimal.ROUND_FLOOR:
return (isNegative ? Math.ceil(div) : Math.floor(div))
* roundingInc;
case java.math.BigDecimal.ROUND_DOWN:
case com.ibm.icu.math.BigDecimal.ROUND_DOWN:
return (Math.floor(div)) * roundingInc;
case java.math.BigDecimal.ROUND_UP:
case com.ibm.icu.math.BigDecimal.ROUND_UP:
return (Math.ceil(div)) * roundingInc;
case java.math.BigDecimal.ROUND_UNNECESSARY:
case com.ibm.icu.math.BigDecimal.ROUND_UNNECESSARY:
if (div != Math.floor(div)) {
throw new ArithmeticException("Rounding necessary");
}
@ -804,7 +806,7 @@ public class DecimalFormat extends NumberFormat {
double floor = Math.floor(div);
double floordiff = number - (floor * roundingInc);
switch (mode) {
case java.math.BigDecimal.ROUND_HALF_EVEN:
case com.ibm.icu.math.BigDecimal.ROUND_HALF_EVEN:
// We should be able to just return Math.rint(a), but this
// doesn't work in some VMs.
if (ceildiff != floordiff) {
@ -814,9 +816,9 @@ public class DecimalFormat extends NumberFormat {
return (floor == Math.floor(floor) ? Math.floor(div)
: (Math.floor(div) + 1.0))
* roundingInc;
case java.math.BigDecimal.ROUND_HALF_DOWN:
case com.ibm.icu.math.BigDecimal.ROUND_HALF_DOWN:
return ((floordiff <= ceildiff) ? floor : ceil) * roundingInc;
case java.math.BigDecimal.ROUND_HALF_UP:
case com.ibm.icu.math.BigDecimal.ROUND_HALF_UP:
return ((ceildiff <= floordiff) ? ceil : floor) * roundingInc;
default:
throw new IllegalArgumentException("Invalid rounding mode: " + mode);
@ -835,8 +837,8 @@ public class DecimalFormat extends NumberFormat {
// If we are to do rounding, we need to move into the BigDecimal
// domain in order to do divide/multiply correctly.
// [NEW]
if (roundingIncrement != null) {
return format(java.math.BigDecimal.valueOf(number), result, fieldPosition);
if (roundingIncrementICU != null) {
return format(com.ibm.icu.math.BigDecimal.valueOf(number), result, fieldPosition);
}
boolean isNegative = (number < 0);
@ -880,8 +882,8 @@ public class DecimalFormat extends NumberFormat {
FieldPosition fieldPosition) {
// If we are to do rounding, we need to move into the BigDecimal
// domain in order to do divide/multiply correctly.
if (roundingIncrement != null) {
return format(new java.math.BigDecimal(number), result, fieldPosition);
if (roundingIncrementICU != null) {
return format(new com.ibm.icu.math.BigDecimal(number), result, fieldPosition);
}
if (multiplier != 1) {
@ -896,6 +898,7 @@ public class DecimalFormat extends NumberFormat {
}
}
//#ifndef FOUNDATION
/**
* <strong><font face=helvetica color=red>NEW</font></strong>
* Format a BigDecimal number.
@ -918,7 +921,8 @@ public class DecimalFormat extends NumberFormat {
return subformat(result, fieldPosition, number.signum() < 0, false);
}
}
//#endif
/**
* <strong><font face=helvetica color=red>NEW</font></strong>
* Format a BigDecimal number.
@ -936,10 +940,9 @@ public class DecimalFormat extends NumberFormat {
number = number.multiply(com.ibm.icu.math.BigDecimal.valueOf(multiplier));
}
if (roundingIncrement != null) {
com.ibm.icu.math.BigDecimal ri = new com.ibm.icu.math.BigDecimal(roundingIncrement);
number = number.divide(ri, 0, roundingMode)
.multiply(ri);
if (roundingIncrementICU != null) {
number = number.divide(roundingIncrementICU, 0, roundingMode)
.multiply(roundingIncrementICU);
}
synchronized(digitList) {
@ -1482,11 +1485,11 @@ public class DecimalFormat extends NumberFormat {
// Handle non-integral values
else {
java.math.BigDecimal big = digitList.getBigDecimal(status[STATUS_POSITIVE]);
com.ibm.icu.math.BigDecimal big = digitList.getBigDecimalICU(status[STATUS_POSITIVE]);
n = big;
if (mult != 1) {
n = big.divide(java.math.BigDecimal.valueOf(mult),
java.math.BigDecimal.ROUND_HALF_EVEN);
n = big.divide(com.ibm.icu.math.BigDecimal.valueOf(mult),
com.ibm.icu.math.BigDecimal.ROUND_HALF_EVEN);
}
}
}
@ -2222,10 +2225,19 @@ public class DecimalFormat extends NumberFormat {
* @see #setRoundingMode
* @stable ICU 2.0
*/
//#ifndef FOUNDATION
public java.math.BigDecimal getRoundingIncrement() {
return roundingIncrement;
if (roundingIncrementICU == null) return null;
return new java.math.BigDecimal(roundingIncrementICU.toString());
}
//#else
//## public com.ibm.icu.math.BigDecimal getRoundingIncrement() {
//## if (roundingIncrementICU == null) return null;
//## return new com.ibm.icu.math.BigDecimal(roundingIncrementICU.toString());
//## }
//#endif
//#ifndef FOUNDATION
/**
* <strong><font face=helvetica color=red>NEW</font></strong>
* Set the rounding increment. This method also controls whether
@ -2245,15 +2257,44 @@ public class DecimalFormat extends NumberFormat {
throw new IllegalArgumentException("Illegal rounding increment");
}
if (i == 0) {
roundingIncrement = null;
roundingIncrementICU = null;
roundingDouble = 0.0;
} else {
roundingIncrement = newValue;
roundingIncrementICU = new com.ibm.icu.math.BigDecimal(newValue);
roundingDouble = newValue.doubleValue();
}
}
/**
//#endif
//#ifdef FOUNDATION
//## /**
//## * Set the rounding increment. This method also controls whether
//## * rounding is enabled.
//## * @param newValue A positive rounding increment, or <code>null</code> or
//## * <code>BigDecimal(0.0)</code> to disable rounding.
//## * @exception IllegalArgumentException if <code>newValue</code> is < 0.0
//## * @see #getRoundingIncrement
//## * @see #getRoundingMode
//## * @see #setRoundingMode
//## * @draft ICU 3.6
//## */
//## public void setRoundingIncrement(com.ibm.icu.math.BigDecimal newValue) {
//## int i = newValue == null
//## ? 0 : newValue.compareTo(com.ibm.icu.math.BigDecimal.valueOf(0));
//## if (i < 0) {
//## throw new IllegalArgumentException("Illegal rounding increment");
//## }
//## if (i == 0) {
//## roundingIncrementICU = null;
//## roundingDouble = 0.0;
//## } else {
//## roundingIncrementICU = newValue;
//## roundingDouble = newValue.doubleValue();
//## }
//## }
//#endif
/**
* <strong><font face=helvetica color=red>NEW</font></strong>
* Set the rounding increment. This method also controls whether
* rounding is enabled.
@ -2270,8 +2311,8 @@ public class DecimalFormat extends NumberFormat {
throw new IllegalArgumentException("Illegal rounding increment");
}
roundingDouble = newValue;
roundingIncrement = (newValue > 0.0)
? new java.math.BigDecimal(String.valueOf(newValue)) : null;
roundingIncrementICU = (newValue > 0.0)
? new com.ibm.icu.math.BigDecimal(String.valueOf(newValue)) : null;
}
/**
@ -2305,8 +2346,8 @@ public class DecimalFormat extends NumberFormat {
* @stable ICU 2.0
*/
public void setRoundingMode(int roundingMode) {
if (roundingMode < java.math.BigDecimal.ROUND_UP
|| roundingMode > java.math.BigDecimal.ROUND_UNNECESSARY) {
if (roundingMode < com.ibm.icu.math.BigDecimal.ROUND_UP
|| roundingMode > com.ibm.icu.math.BigDecimal.ROUND_UNNECESSARY) {
throw new IllegalArgumentException("Invalid rounding mode: "
+ roundingMode);
}
@ -3025,9 +3066,9 @@ public class DecimalFormat extends NumberFormat {
append(localized ? symbols.getPadEscape() : PATTERN_PAD_ESCAPE).
append(pad).toString()
: null;
if (roundingIncrement != null) {
i = roundingIncrement.scale();
roundingDigits = roundingIncrement.movePointRight(i).toString();
if (roundingIncrementICU != null) {
i = roundingIncrementICU.scale();
roundingDigits = roundingIncrementICU.movePointRight(i).toString();
roundingDecimalPos = roundingDigits.length() - i;
}
for (int part=0; part<2; ++part) {
@ -3649,14 +3690,14 @@ public class DecimalFormat extends NumberFormat {
// BigDecimal scale cannot be negative (even though
// this makes perfect sense), so we need to handle this.
int scale = incrementPos - effectiveDecimalPos;
roundingIncrement =
java.math.BigDecimal.valueOf(incrementVal, scale > 0 ? scale : 0);
roundingIncrementICU =
com.ibm.icu.math.BigDecimal.valueOf(incrementVal, scale > 0 ? scale : 0);
if (scale < 0) {
roundingIncrement =
roundingIncrement.movePointRight(-scale);
roundingIncrementICU =
roundingIncrementICU.movePointRight(-scale);
}
roundingDouble = roundingIncrement.doubleValue();
roundingMode = java.math.BigDecimal.ROUND_HALF_EVEN;
roundingDouble = roundingIncrementICU.doubleValue();
roundingMode = com.ibm.icu.math.BigDecimal.ROUND_HALF_EVEN;
} else {
setRoundingIncrement(null);
}
@ -3898,6 +3939,16 @@ public class DecimalFormat extends NumberFormat {
super.setMinimumFractionDigits(Math.min(newValue, DOUBLE_FRACTION_DIGITS));
}
//#ifndef FOUNDATION
private void writeObject(ObjectOutputStream stream) throws IOException, ClassNotFoundException {
if (roundingIncrementICU != null) {
roundingIncrement = new java.math.BigDecimal(roundingIncrementICU.toString());
}
stream.defaultWriteObject();
}
//#endif
/**
* First, read the default serializable fields from the stream. Then
* if <code>serialVersionOnStream</code> is less than 1, indicating that
@ -3933,8 +3984,8 @@ public class DecimalFormat extends NumberFormat {
if (serialVersionOnStream < 2) {
exponentSignAlwaysShown = false;
roundingDouble = 0.0;
roundingIncrement = null;
roundingMode = java.math.BigDecimal.ROUND_HALF_EVEN;
roundingIncrementICU = null;
roundingMode = com.ibm.icu.math.BigDecimal.ROUND_HALF_EVEN;
formatWidth = 0;
pad = ' ';
padPosition = PAD_BEFORE_PREFIX;
@ -3950,6 +4001,11 @@ public class DecimalFormat extends NumberFormat {
}
serialVersionOnStream = currentSerialVersion;
digitList = new DigitList();
//#ifndef FOUNDATION
if (roundingIncrement != null && roundingIncrementICU == null) {
roundingIncrementICU = new com.ibm.icu.math.BigDecimal(roundingIncrement);
}
//#endif
}
//----------------------------------------------------------------------
@ -4165,6 +4221,7 @@ public class DecimalFormat extends NumberFormat {
*/
private boolean exponentSignAlwaysShown = false;
//#ifndef FOUNDATION
/**
* <strong><font face=helvetica color=red>NEW</font></strong>
* The value to which numbers are rounded during formatting. For example,
@ -4176,12 +4233,13 @@ public class DecimalFormat extends NumberFormat {
* @since AlphaWorks NumberFormat
*/
private java.math.BigDecimal roundingIncrement = null;
//#endif
/**
* <strong><font face=helvetica color=red>NEW</font></strong>
* The rounding increment as a double. If this value is <= 0, then no
* rounding is done. This value is
* <code>roundingIncrement.doubleValue()</code>. Default value 0.0.
* <code>roundingIncrementICU.doubleValue()</code>. Default value 0.0.
*/
private transient double roundingDouble = 0.0;
@ -4195,7 +4253,7 @@ public class DecimalFormat extends NumberFormat {
* @serial
* @since AlphaWorks NumberFormat
*/
private int roundingMode = java.math.BigDecimal.ROUND_HALF_EVEN;
private int roundingMode = com.ibm.icu.math.BigDecimal.ROUND_HALF_EVEN;
/**
* <strong><font face=helvetica color=red>NEW</font></strong>
@ -4359,14 +4417,16 @@ public class DecimalFormat extends NumberFormat {
*/
static final int MAX_SCIENTIFIC_INTEGER_DIGITS = 8;
//#ifdef FOUNDATION
//## // we're not compatible with other versions, since we have no java.math.BigDecimal field
//## private static final long serialVersionUID = 2;
//#else
// Proclaim JDK 1.1 serial compatibility.
private static final long serialVersionUID = 864413376551465018L;
//#endif
/**
* Cache to hold the NumberPattern of a Locale.
* [NEW] No longer needed -- share the NumberFormat cache
*/
// private static Hashtable cachedLocaleData = new Hashtable(3);
// 'foundationize' by converting to ICU's BigDecimal only
private com.ibm.icu.math.BigDecimal roundingIncrementICU;
}
//eof

View file

@ -1,6 +1,7 @@
//##header 1132615047000
/*
*******************************************************************************
* Copyright (C) 1996-2004, International Business Machines Corporation and *
* Copyright (C) 1996-2005, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
@ -200,15 +201,8 @@ final class DigitList {
}
}
/**
* Return a <code>BigDecimal</code> representing the value stored in this
* <code>DigitList</code>.
* [bnf]
* @param isPositive determines the sign of the returned result
* @return the value of this object as a <code>BigDecimal</code>
*/
public java.math.BigDecimal getBigDecimal(boolean isPositive) {
if (isZero()) return java.math.BigDecimal.valueOf(0);
private String getStringRep(boolean isPositive) {
if (isZero()) return "0";
StringBuffer stringRep = new StringBuffer(count+1);
if (!isPositive) {
stringRep.append('-');
@ -231,7 +225,33 @@ final class DigitList {
while (d-- > count) {
stringRep.append('0');
}
return new java.math.BigDecimal(stringRep.toString());
return stringRep.toString();
}
//#ifndef FOUNDATION
/**
* Return a <code>BigDecimal</code> representing the value stored in this
* <code>DigitList</code>.
* [bnf]
* @param isPositive determines the sign of the returned result
* @return the value of this object as a <code>BigDecimal</code>
*/
public java.math.BigDecimal getBigDecimal(boolean isPositive) {
if (isZero()) return java.math.BigDecimal.valueOf(0);
return new java.math.BigDecimal(getStringRep(isPositive));
}
//#endif
/**
* Return an <code>ICU BigDecimal</code> representing the value stored in this
* <code>DigitList</code>.
* [bnf]
* @param isPositive determines the sign of the returned result
* @return the value of this object as a <code>BigDecimal</code>
*/
public com.ibm.icu.math.BigDecimal getBigDecimalICU(boolean isPositive) {
if (isZero()) return com.ibm.icu.math.BigDecimal.valueOf(0);
return new com.ibm.icu.math.BigDecimal(getStringRep(isPositive));
}
/**
@ -640,6 +660,7 @@ final class DigitList {
round(fixedPoint ? (maximumDigits + decimalAt) : maximumDigits == 0 ? -1 : maximumDigits);
}
//#ifndef FOUNDATION
/**
* Set the digit list to a representation of the given BigDecimal value.
* [bnf]
@ -654,6 +675,7 @@ final class DigitList {
int maximumDigits, boolean fixedPoint) {
setBigDecimalDigits(source.toString(), maximumDigits, fixedPoint);
}
//#endif
/*
* Set the digit list to a representation of the given BigDecimal value.

View file

@ -1,3 +1,4 @@
//##header 1132615047000
/*
*******************************************************************************
* Copyright (C) 1996-2005, International Business Machines Corporation and *
@ -192,8 +193,10 @@ public abstract class NumberFormat extends UFormat {
return format(((Long)number).longValue(), toAppendTo, pos);
} else if (number instanceof BigInteger) {
return format((BigInteger) number, toAppendTo, pos);
//#ifndef FOUNDATION
} else if (number instanceof java.math.BigDecimal) {
return format((java.math.BigDecimal) number, toAppendTo, pos);
//#endif
} else if (number instanceof com.ibm.icu.math.BigDecimal) {
return format((com.ibm.icu.math.BigDecimal) number, toAppendTo, pos);
} else if (number instanceof CurrencyAmount) {
@ -246,6 +249,7 @@ public abstract class NumberFormat extends UFormat {
new FieldPosition(0)).toString();
}
//#ifndef FOUNDATION
/**
* <strong><font face=helvetica color=red>NEW</font></strong>
* Convenience method to format a BigDecimal.
@ -255,6 +259,7 @@ public abstract class NumberFormat extends UFormat {
return format(number, new StringBuffer(),
new FieldPosition(0)).toString();
}
//#endif
/**
* <strong><font face=helvetica color=red>NEW</font></strong>
@ -304,7 +309,7 @@ public abstract class NumberFormat extends UFormat {
public abstract StringBuffer format(BigInteger number,
StringBuffer toAppendTo,
FieldPosition pos);
//#ifndef FOUNDATION
/**
* <strong><font face=helvetica color=red>NEW</font></strong>
* Format a BigDecimal.
@ -314,6 +319,7 @@ public abstract class NumberFormat extends UFormat {
public abstract StringBuffer format(java.math.BigDecimal number,
StringBuffer toAppendTo,
FieldPosition pos);
//#endif
/**
* <strong><font face=helvetica color=red>NEW</font></strong>

View file

@ -7,6 +7,8 @@
package com.ibm.icu.text;
import com.ibm.icu.impl.Utility;
/**
* A post-processor for Chinese text.
*/
@ -45,7 +47,7 @@ final class RBNFChinesePostProcessor extends RBNFPostProcessor {
}
if (longForm) {
for (int i = buf.indexOf("*"); i != -1; i = buf.indexOf("*", i)) {
for (int i = Utility.indexOf(buf,"*"); i != -1; i = Utility.indexOf(buf, "*", i)) {
buf.delete(i, i+1);
}
return;
@ -79,14 +81,14 @@ final class RBNFChinesePostProcessor extends RBNFPostProcessor {
{
String[] m = markers[format];
for (int i = 0; i < m.length-1; ++i) {
int n = buf.indexOf(m[i]);
int n = Utility.indexOf(buf, m[i]);
if (n != -1) {
buf.insert(n+m[i].length(), '|');
}
}
}
int x = buf.indexOf(DIAN);
int x = Utility.indexOf(buf, DIAN);
if (x == -1) {
x = buf.length();
}
@ -94,8 +96,8 @@ final class RBNFChinesePostProcessor extends RBNFPostProcessor {
int n = -1; // previous optional ling
String ling = markers[format][3];
while (x >= 0) {
int m = buf.lastIndexOf("|", x);
int nn = buf.lastIndexOf(ling, x);
int m = Utility.lastIndexOf(buf, "|", x);
int nn = Utility.lastIndexOf(buf, ling, x);
int ns = 0;
if (nn > m) {
ns = (nn > 0 && buf.charAt(nn-1) != '*') ? 2 : 1;

View file

@ -6,9 +6,11 @@
*/
package com.ibm.icu.text;
import java.text.CharacterIterator;
import java.io.IOException;
import java.io.InputStream;
import java.text.CharacterIterator;
import com.ibm.icu.impl.Assert;
/**
@ -23,6 +25,7 @@ import java.io.InputStream;
* @internal
*/
public class RuleBasedBreakIterator_New extends RuleBasedBreakIterator {
private static final boolean ASSERT = false;
private static final int START_STATE = 1; // The state number of the starting state
private static final int STOP_STATE = 0; // The state-transition value indicating "stop"
@ -526,7 +529,7 @@ public boolean isBoundary(int offset) {
*/
public int current() {
return (fText != null) ? fText.getIndex() : BreakIterator.DONE;
}
}
@ -542,11 +545,14 @@ private void makeRuleStatusValid() {
int pa = current();
previous();
int pb = next();
assert pa == pb;
if (ASSERT) Assert.assrt("pa == pb", pa == pb);
}
}
assert fLastStatusIndexValid == true;
assert fLastRuleStatusIndex >= 0 && fLastRuleStatusIndex < fRData.fStatusTable.length;
if (ASSERT) {
Assert.assrt("fLastStatusIndexValid == true", fLastStatusIndexValid == true);
Assert.assrt("fLastRuleStatusIndex >= 0 && fLastRuleStatusIndex < fRData.fStatusTable.length",
fLastRuleStatusIndex >= 0 && fLastRuleStatusIndex < fRData.fStatusTable.length);
}
}

View file

@ -1,3 +1,4 @@
//##header 1132615671000
/**
*******************************************************************************
* Copyright (C) 1996-2005, International Business Machines Corporation and *
@ -7,12 +8,17 @@
package com.ibm.icu.text;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.text.CharacterIterator;
import java.text.ParseException;
import java.util.Arrays;
import java.util.MissingResourceException;
//#ifndef FOUNDATION
import java.nio.ByteBuffer;
//#else
//##import com.ibm.icu.impl.ByteBuffer;
//#endif
import com.ibm.icu.impl.BOCU;
import com.ibm.icu.impl.ICUDebug;
import com.ibm.icu.impl.ICUResourceBundle;

View file

@ -1,3 +1,4 @@
//##header 1132615047000
/*
*******************************************************************************
* Copyright (C) 1996-2005, International Business Machines Corporation and *
@ -11,6 +12,7 @@ package com.ibm.icu.text;
import com.ibm.icu.impl.ICUDebug;
import com.ibm.icu.impl.ICUResourceBundle;
import com.ibm.icu.impl.UCharacterProperty;
import com.ibm.icu.impl.Utility;
import com.ibm.icu.util.ULocale;
import com.ibm.icu.util.UResourceBundle;
@ -1096,6 +1098,7 @@ public class RuleBasedNumberFormat extends NumberFormat {
return format(new com.ibm.icu.math.BigDecimal(number), toAppendTo, pos);
}
//#ifndef FOUNDATION
/**
* <strong><font face=helvetica color=red>NEW</font></strong>
* Implement com.ibm.icu.text.NumberFormat:
@ -1107,6 +1110,7 @@ public class RuleBasedNumberFormat extends NumberFormat {
FieldPosition pos) {
return format(new com.ibm.icu.math.BigDecimal(number), toAppendTo, pos);
}
//#endif
/**
* <strong><font face=helvetica color=red>NEW</font></strong>
@ -1373,7 +1377,7 @@ public class RuleBasedNumberFormat extends NumberFormat {
*/
private String extractSpecial(StringBuffer description, String specialName) {
String result = null;
int lp = description.indexOf(specialName);
int lp = Utility.indexOf(description, specialName);
if (lp != -1) {
// we've got to make sure we're not in the middle of a rule
// (where specialName would actually get treated as
@ -1382,7 +1386,7 @@ public class RuleBasedNumberFormat extends NumberFormat {
// locate the beginning and end of the actual special
// rules (there may be whitespace between the name and
// the first token in the description)
int lpEnd = description.indexOf(";%", lp);
int lpEnd = Utility.indexOf(description, ";%", lp);
if (lpEnd == -1) {
lpEnd = description.length() - 1; // later we add 1 back to get the '%'
@ -1433,7 +1437,7 @@ public class RuleBasedNumberFormat extends NumberFormat {
// rule sets (";%" marks the end of one rule set and the beginning
// of the next)
int numRuleSets = 0;
for (int p = descBuf.indexOf(";%"); p != -1; p = descBuf.indexOf(";%", p)) {
for (int p = Utility.indexOf(descBuf, ";%"); p != -1; p = Utility.indexOf(descBuf, ";%", p)) {
++numRuleSets;
++p;
}
@ -1453,7 +1457,7 @@ public class RuleBasedNumberFormat extends NumberFormat {
int curRuleSet = 0;
int start = 0;
for (int p = descBuf.indexOf(";%"); p != -1; p = descBuf.indexOf(";%", start)) {
for (int p = Utility.indexOf(descBuf, ";%"); p != -1; p = Utility.indexOf(descBuf, ";%", start)) {
ruleSetDescriptions[curRuleSet] = descBuf.substring(start, p + 1);
ruleSets[curRuleSet] = new NFRuleSet(ruleSetDescriptions, curRuleSet);
++curRuleSet;

View file

@ -1358,7 +1358,7 @@ public abstract class Transliterator {
// assert(list.size() > 0);
Transliterator t = null;
if (list.size() > 1 || canonID.indexOf(";") >= 0) {
if (list.size() > 1 || Utility.indexOf(canonID, ";") >= 0) {
// [NOTE: If it's a compoundID, we instantiate a CompoundTransliterator even if it only
// has one child transliterator. This is so that toRules() will return the right thing
// (without any inactive ID), but our main ID still comes out correct. That is, if we

View file

@ -31,7 +31,6 @@ import java.util.MissingResourceException;
import java.util.TreeSet;
import java.util.Iterator;
import java.util.Collection;
import java.util.regex.Pattern;
/**
* A mutable set of Unicode characters and multicharacter strings. Objects of this class

View file

@ -1,3 +1,4 @@
//##header 1132615047000
/**
*******************************************************************************
* Copyright (C) 1996-2005, International Business Machines Corporation and *
@ -7,8 +8,11 @@
package com.ibm.icu.util;
//#ifndef FOUNDATION
import java.nio.ByteBuffer;
//#else
//##import com.ibm.icu.impl.ByteBuffer;
//#endif
import com.ibm.icu.impl.Utility;
/**

View file

@ -1,3 +1,4 @@
//##header 1132615047000
/*
*******************************************************************************
* Copyright (C) 2004-2005, International Business Machines Corporation and *
@ -14,8 +15,11 @@ import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
//#ifndef FOUNDATION
import java.util.regex.Matcher;
import java.util.regex.Pattern;
//#endif
import com.ibm.icu.impl.Utility;
import com.ibm.icu.impl.ZoneMeta;
@ -43,6 +47,9 @@ import com.ibm.icu.text.SimpleDateFormat;
* in Breton if available, otherwise in French if available, otherwise in English.
* <p><b>This is at a prototype stage, and has not incorporated all the design changes
* that we would like yet; further feedback is welcome.
*
* @internal
* @deprecated ICU 3.4.2
*/
public class GlobalizationPreferences {
/**
@ -110,6 +117,8 @@ public class GlobalizationPreferences {
public GlobalizationPreferences setULocales(ULocale uLocale) {
return setULocales(new ULocale[]{uLocale});
}
//#ifndef FOUNDATION
/**
* Convenience routine for setting the locale priority list from an Accept-Language string.
* @see #setULocales(List locales)
@ -153,7 +162,8 @@ public class GlobalizationPreferences {
}
return setULocales(result);
}
//#endif
/**
* Sets the territory, which is a valid territory according to for RFC 3066 (or successor).
* If not otherwise set, default currency and timezone values will be set from this.
@ -318,7 +328,10 @@ public class GlobalizationPreferences {
// TODO, have method that doesn't require us to create a timezone
// fix other hacks
// hack for couldn't match
// note, compiling with FOUNDATION omits this check for now
//#ifndef FOUNDATION
if (badTimezone.reset(result).matches()) continue;
//#endif
break;
default:
throw new IllegalArgumentException("Unknown type: " + type);
@ -329,8 +342,10 @@ public class GlobalizationPreferences {
}
return result;
}
//#ifndef FOUNDATION
// TODO remove need for this
private static final Matcher badTimezone = Pattern.compile("[A-Z]{2}|.*\\s\\([A-Z]{2}\\)").matcher("");
//#endif
/**
* Set an explicit date format. Overrides both the date locale, and the locale priority list
@ -378,7 +393,11 @@ public class GlobalizationPreferences {
}
return result;
} catch (RuntimeException e) {
throw (IllegalArgumentException) new IllegalArgumentException("Cannot create DateFormat").initCause(e);
IllegalArgumentException ex = new IllegalArgumentException("Cannot create DateFormat");
//#ifndef FOUNDATION
ex.initCause(e);
//#endif
throw ex;
}
}
@ -718,4 +737,4 @@ public class GlobalizationPreferences {
territory_tzid_hack_map.put(territory_tzid_hack[i][0],territory_tzid_hack[i][1]);
}
}
}
}

View file

@ -16,9 +16,10 @@ import java.util.Locale;
import java.util.Map;
import java.util.MissingResourceException;
import java.util.TreeMap;
import com.ibm.icu.impl.LocaleUtility;
import com.ibm.icu.impl.LocaleUtility;
import com.ibm.icu.impl.ICUResourceBundle;
import com.ibm.icu.lang.UCharacter;
/**
* A class analogous to {@link java.util.Locale} that provides additional
@ -2669,19 +2670,19 @@ public final class ULocale implements Serializable {
if((paramEnd != -1) && (paramEnd < itemEnd)) {
/* semicolon (;) is closer than end (,) */
int t = paramEnd + 1;
while(Character.isSpace(acceptLanguageList.charAt(t))) {
while(UCharacter.isWhitespace(acceptLanguageList.charAt(t))) {
t++;
}
if(acceptLanguageList.charAt(t)=='q') {
t++;
}
while(Character.isSpace(acceptLanguageList.charAt(t))) {
while(UCharacter.isWhitespace(acceptLanguageList.charAt(t))) {
t++;
}
if(acceptLanguageList.charAt(t)=='=') {
t++;
}
while(Character.isSpace(acceptLanguageList.charAt(t))) {
while(UCharacter.isWhitespace(acceptLanguageList.charAt(t))) {
t++;
}
try {

View file

@ -531,7 +531,7 @@ public final class UniversalTimeScale
public static BigDecimal bigDecimalFrom(double otherTime, int timeScale)
{
TimeScaleData data = getTimeScaleData(timeScale);
BigDecimal other = new BigDecimal(otherTime);
BigDecimal other = new BigDecimal(String.valueOf(otherTime));
BigDecimal units = new BigDecimal(data.units);
BigDecimal epochOffset = new BigDecimal(data.epochOffset);