ICU-6411 Fix compiler errors on Java 1.3/1.4 env.

X-SVN-Rev: 24734
This commit is contained in:
Yoshito Umaoka 2008-10-07 04:44:16 +00:00
parent acd74a93d1
commit b4b006c34f
5 changed files with 22 additions and 14 deletions

View file

@ -158,7 +158,7 @@ class CharsetMBCS extends CharsetICU {
super(icuCanonicalName, javaCanonicalName, aliases);
/* See if the icuCanonicalName contains certain option information. */
if (icuCanonicalName.contains(UConverterConstants.OPTION_SWAP_LFNL_STRING)) {
if (icuCanonicalName.indexOf(UConverterConstants.OPTION_SWAP_LFNL_STRING) > -1) {
options = UConverterConstants.OPTION_SWAP_LFNL;
icuCanonicalName = icuCanonicalName.substring(0, icuCanonicalName.indexOf(UConverterConstants.OPTION_SWAP_LFNL_STRING));
super.icuCanonicalName = icuCanonicalName;

View file

@ -320,7 +320,7 @@ public final class CharsetProviderICU extends CharsetProvider{
}
private static final String processOptions(String charsetName) {
if (charsetName.contains(UConverterConstants.OPTION_SWAP_LFNL_STRING)) {
if (charsetName.indexOf(UConverterConstants.OPTION_SWAP_LFNL_STRING) > -1) {
/* Remove and save the swap lfnl option string portion of the charset name. */
optionsString = UConverterConstants.OPTION_SWAP_LFNL_STRING;

View file

@ -1837,10 +1837,10 @@ public final class Utility {
return buf.lastIndexOf(s, i);
//#endif
}
// !!! 1.3 compatibility
public static String replaceAll(String src, String target, String replacement) {
//#if defined(FOUNDATION10) || defined(J2SE13)
// !!! 1.3/1.4 compatibility
public static String replace(String src, String target, String replacement) {
//#if defined(FOUNDATION10) || defined(J2SE13) || defined(J2SE14)
//## int i = src.indexOf(target);
//## if (i == -1) {
//## return src;
@ -1857,6 +1857,15 @@ public final class Utility {
//## buf.append(src.substring(n));
//## }
//## return buf.toString();
//#else
return src.replace(target, replacement);
//#endif
}
// !!! 1.3 compatibility
public static String replaceAll(String src, String target, String replacement) {
//#if defined(FOUNDATION10) || defined(J2SE13)
//## return replace(src, target, replacement);
//#else
return src.replaceAll(target, replacement);
//#endif

View file

@ -20,11 +20,6 @@ import java.util.Map;
import java.util.MissingResourceException;
import java.util.Set;
import com.ibm.icu.impl.ICUResourceBundle;
import com.ibm.icu.util.UResourceBundle;
//#if defined(FOUNDATION10)
//#else
import java.io.ObjectOutputStream;
@ -38,12 +33,15 @@ import java.text.Format;
import java.util.ArrayList;
//#endif
import com.ibm.icu.impl.ICUResourceBundle;
import com.ibm.icu.impl.UCharacterProperty;
import com.ibm.icu.impl.Utility;
import com.ibm.icu.lang.UCharacter;
import com.ibm.icu.math.BigDecimal;
import com.ibm.icu.util.Currency;
import com.ibm.icu.util.CurrencyAmount;
import com.ibm.icu.util.ULocale;
import com.ibm.icu.util.UResourceBundle;
//This is an enhanced version of DecimalFormat that is based on the standard version in the JDK.
/**
@ -806,8 +804,8 @@ public class DecimalFormat extends NumberFormat {
String pattern = currencyRes.get(index).getString();
// replace {0} with numberStylePattern
// and {1} with triple currency sign
String patternWithNumber = pattern.replace("{0}", numberStylePattern);
String patternWithCurrencySign = patternWithNumber.replace("{1}", tripleCurrencyStr);
String patternWithNumber = Utility.replace(pattern, "{0}", numberStylePattern);
String patternWithCurrencySign = Utility.replace(patternWithNumber, "{1}", tripleCurrencyStr);
pluralCountToCurrencyUnitPattern.put(pluralCount, patternWithCurrencySign);
pluralCountSet.add(pluralCount);
}

View file

@ -26,6 +26,7 @@ import java.text.Format;
//#endif
import com.ibm.icu.impl.ICUResourceBundle;
import com.ibm.icu.impl.Utility;
import com.ibm.icu.util.Currency;
import com.ibm.icu.util.CurrencyAmount;
import com.ibm.icu.util.ULocale;
@ -1316,7 +1317,7 @@ public abstract class NumberFormat extends UFormat {
// replace single currency sign in the pattern with double currency sign
// if the choice is ISOCURRENCYSTYLE.
if (choice == ISOCURRENCYSTYLE) {
pattern = pattern.replaceAll("\\xA4", doubleCurrencyStr);
pattern = Utility.replace(pattern, "\u00A4", doubleCurrencyStr);
}
DecimalFormat format = new DecimalFormat(pattern, symbols, choice);