BigDecimal
object from a
* java.math.BigDecimal
.
@@ -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 BigDecimal
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 BigDecimal
object directly from a
* int
.
@@ -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 BigDecimal
to a
* java.math.BigDecimal
.
@@ -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 BigDecimal
to a
diff --git a/icu4j/src/com/ibm/icu/text/BreakIteratorFactory.java b/icu4j/src/com/ibm/icu/text/BreakIteratorFactory.java
index af07ae3fd65..0ad804f63e0 100644
--- a/icu4j/src/com/ibm/icu/text/BreakIteratorFactory.java
+++ b/icu4j/src/com/ibm/icu/text/BreakIteratorFactory.java
@@ -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.
diff --git a/icu4j/src/com/ibm/icu/text/DateFormatSymbols.java b/icu4j/src/com/ibm/icu/text/DateFormatSymbols.java
index 3f24863f906..444978b9a0f 100755
--- a/icu4j/src/com/ibm/icu/text/DateFormatSymbols.java
+++ b/icu4j/src/com/ibm/icu/text/DateFormatSymbols.java
@@ -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; inull
or
+//## * BigDecimal(0.0)
to disable rounding.
+//## * @exception IllegalArgumentException if newValue
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
+
+ /**
* NEW
* 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 serialVersionOnStream
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
/**
* NEW
* 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
/**
* NEW
* The rounding increment as a double. If this value is <= 0, then no
* rounding is done. This value is
- * roundingIncrement.doubleValue()
. Default value 0.0.
+ * roundingIncrementICU.doubleValue()
. 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;
/**
* NEW
@@ -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
diff --git a/icu4j/src/com/ibm/icu/text/DigitList.java b/icu4j/src/com/ibm/icu/text/DigitList.java
index 9ab8120d39e..f46fb90ba3c 100755
--- a/icu4j/src/com/ibm/icu/text/DigitList.java
+++ b/icu4j/src/com/ibm/icu/text/DigitList.java
@@ -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 BigDecimal
representing the value stored in this
- * DigitList
.
- * [bnf]
- * @param isPositive determines the sign of the returned result
- * @return the value of this object as a BigDecimal
- */
- 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 BigDecimal
representing the value stored in this
+ * DigitList
.
+ * [bnf]
+ * @param isPositive determines the sign of the returned result
+ * @return the value of this object as a BigDecimal
+ */
+ 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 ICU BigDecimal
representing the value stored in this
+ * DigitList
.
+ * [bnf]
+ * @param isPositive determines the sign of the returned result
+ * @return the value of this object as a BigDecimal
+ */
+ 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.
diff --git a/icu4j/src/com/ibm/icu/text/NumberFormat.java b/icu4j/src/com/ibm/icu/text/NumberFormat.java
index b4dc0e565b8..60c09c2003e 100755
--- a/icu4j/src/com/ibm/icu/text/NumberFormat.java
+++ b/icu4j/src/com/ibm/icu/text/NumberFormat.java
@@ -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
/**
* NEW
* 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
/**
* NEW
@@ -304,7 +309,7 @@ public abstract class NumberFormat extends UFormat {
public abstract StringBuffer format(BigInteger number,
StringBuffer toAppendTo,
FieldPosition pos);
-
+//#ifndef FOUNDATION
/**
* NEW
* 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
/**
* NEW
diff --git a/icu4j/src/com/ibm/icu/text/RBNFChinesePostProcessor.java b/icu4j/src/com/ibm/icu/text/RBNFChinesePostProcessor.java
index c2c3330a268..3ec007eaeaa 100644
--- a/icu4j/src/com/ibm/icu/text/RBNFChinesePostProcessor.java
+++ b/icu4j/src/com/ibm/icu/text/RBNFChinesePostProcessor.java
@@ -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;
diff --git a/icu4j/src/com/ibm/icu/text/RuleBasedBreakIterator_New.java b/icu4j/src/com/ibm/icu/text/RuleBasedBreakIterator_New.java
index 8337c3a0ae5..62d57225ac3 100644
--- a/icu4j/src/com/ibm/icu/text/RuleBasedBreakIterator_New.java
+++ b/icu4j/src/com/ibm/icu/text/RuleBasedBreakIterator_New.java
@@ -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);
+ }
}
diff --git a/icu4j/src/com/ibm/icu/text/RuleBasedCollator.java b/icu4j/src/com/ibm/icu/text/RuleBasedCollator.java
index 015d8d52181..1127532fa40 100755
--- a/icu4j/src/com/ibm/icu/text/RuleBasedCollator.java
+++ b/icu4j/src/com/ibm/icu/text/RuleBasedCollator.java
@@ -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;
diff --git a/icu4j/src/com/ibm/icu/text/RuleBasedNumberFormat.java b/icu4j/src/com/ibm/icu/text/RuleBasedNumberFormat.java
index 1e1a8e82ba4..9594b3aa8f2 100755
--- a/icu4j/src/com/ibm/icu/text/RuleBasedNumberFormat.java
+++ b/icu4j/src/com/ibm/icu/text/RuleBasedNumberFormat.java
@@ -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
/**
* NEW
* 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
/**
* NEW
@@ -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;
diff --git a/icu4j/src/com/ibm/icu/text/Transliterator.java b/icu4j/src/com/ibm/icu/text/Transliterator.java
index 70ae13bfac5..bd48b45f3aa 100755
--- a/icu4j/src/com/ibm/icu/text/Transliterator.java
+++ b/icu4j/src/com/ibm/icu/text/Transliterator.java
@@ -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
diff --git a/icu4j/src/com/ibm/icu/text/UnicodeSet.java b/icu4j/src/com/ibm/icu/text/UnicodeSet.java
index 13a1e4d4f70..6656bf09667 100755
--- a/icu4j/src/com/ibm/icu/text/UnicodeSet.java
+++ b/icu4j/src/com/ibm/icu/text/UnicodeSet.java
@@ -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
diff --git a/icu4j/src/com/ibm/icu/util/ByteArrayWrapper.java b/icu4j/src/com/ibm/icu/util/ByteArrayWrapper.java
index 723744f0304..cc40276d344 100644
--- a/icu4j/src/com/ibm/icu/util/ByteArrayWrapper.java
+++ b/icu4j/src/com/ibm/icu/util/ByteArrayWrapper.java
@@ -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;
/**
diff --git a/icu4j/src/com/ibm/icu/util/GlobalizationPreferences.java b/icu4j/src/com/ibm/icu/util/GlobalizationPreferences.java
index ee058cc151a..5e6b574bf3c 100644
--- a/icu4j/src/com/ibm/icu/util/GlobalizationPreferences.java
+++ b/icu4j/src/com/ibm/icu/util/GlobalizationPreferences.java
@@ -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.
* 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]); } } -} \ No newline at end of file +} diff --git a/icu4j/src/com/ibm/icu/util/ULocale.java b/icu4j/src/com/ibm/icu/util/ULocale.java index f672719f21c..a8affd7d00c 100644 --- a/icu4j/src/com/ibm/icu/util/ULocale.java +++ b/icu4j/src/com/ibm/icu/util/ULocale.java @@ -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 { diff --git a/icu4j/src/com/ibm/icu/util/UniversalTimeScale.java b/icu4j/src/com/ibm/icu/util/UniversalTimeScale.java index 22a49a50e3a..0d5b2a4fce3 100644 --- a/icu4j/src/com/ibm/icu/util/UniversalTimeScale.java +++ b/icu4j/src/com/ibm/icu/util/UniversalTimeScale.java @@ -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);