ICU-7603 Migrating Hashtable to HashMap.
X-SVN-Rev: 27906
This commit is contained in:
parent
3b456d2c67
commit
8251996bb7
@ -10,9 +10,11 @@ import java.io.IOException;
|
||||
import java.text.ParseException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Enumeration;
|
||||
import java.util.Hashtable;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.ibm.icu.impl.IntTrieBuilder;
|
||||
import com.ibm.icu.impl.Norm2AllModes;
|
||||
@ -1030,7 +1032,7 @@ final class CollationParsedRuleBuilder {
|
||||
// temporary fix for jb3822, 0x100000 -> 30000
|
||||
m_mapping_ = new IntTrieBuilder(null, 0x30000, trieinitialvalue,
|
||||
trieinitialvalue, true);
|
||||
m_prefixLookup_ = new Hashtable<Elements, Elements>();
|
||||
m_prefixLookup_ = new HashMap<Elements, Elements>();
|
||||
// uhash_open(prefixLookupHash, prefixLookupComp);
|
||||
m_contractions_ = new ContractionTable(m_mapping_);
|
||||
// copy UCA's maxexpansion and merge as we go along
|
||||
@ -1087,7 +1089,7 @@ final class CollationParsedRuleBuilder {
|
||||
MaxJamoExpansionTable m_maxJamoExpansions_;
|
||||
byte m_unsafeCP_[];
|
||||
byte m_contrEndCP_[];
|
||||
Hashtable<Elements, Elements> m_prefixLookup_;
|
||||
Map<Elements, Elements> m_prefixLookup_;
|
||||
CombinClassTable cmLookup = null;
|
||||
}
|
||||
|
||||
@ -3811,7 +3813,7 @@ final class CollationParsedRuleBuilder {
|
||||
}
|
||||
|
||||
if (t.m_prefixLookup_ != null) {
|
||||
Enumeration<Elements> els = t.m_prefixLookup_.elements();
|
||||
Enumeration<Elements> els = Collections.enumeration(t.m_prefixLookup_.values());
|
||||
while (els.hasMoreElements()) {
|
||||
Elements e = els.nextElement();
|
||||
// codepoints here are in the NFD form. We need to add the
|
||||
|
@ -8,7 +8,8 @@ package com.ibm.icu.text;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Hashtable;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.ibm.icu.impl.UCharacterProperty;
|
||||
import com.ibm.icu.lang.UCharacter;
|
||||
@ -43,7 +44,7 @@ final class CollationRuleParser
|
||||
m_extraCurrent_ = m_source_.length();
|
||||
m_variableTop_ = null;
|
||||
m_parsedToken_ = new ParsedToken();
|
||||
m_hashTable_ = new Hashtable<Token, Token>();
|
||||
m_hashTable_ = new HashMap<Token, Token>();
|
||||
m_options_ = new OptionSet(RuleBasedCollator.UCA_);
|
||||
m_listHeader_ = new TokenListHeader[512];
|
||||
m_resultLength_ = 0;
|
||||
@ -264,7 +265,7 @@ final class CollationRuleParser
|
||||
/**
|
||||
* Hash table to keep all tokens
|
||||
*/
|
||||
Hashtable<Token, Token> m_hashTable_;
|
||||
Map<Token, Token> m_hashTable_;
|
||||
|
||||
// package private method ------------------------------------------------
|
||||
|
||||
|
@ -10,11 +10,12 @@ import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.Serializable;
|
||||
import java.text.ChoiceFormat;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Locale;
|
||||
|
||||
import com.ibm.icu.impl.CurrencyData;
|
||||
import com.ibm.icu.impl.ICUCache;
|
||||
import com.ibm.icu.impl.ICUResourceBundle;
|
||||
import com.ibm.icu.impl.SimpleCache;
|
||||
import com.ibm.icu.impl.CurrencyData.CurrencyDisplayInfo;
|
||||
import com.ibm.icu.impl.CurrencyData.CurrencyFormatInfo;
|
||||
import com.ibm.icu.impl.CurrencyData.CurrencySpacingInfo;
|
||||
@ -1092,8 +1093,8 @@ public class DecimalFormatSymbols implements Cloneable, Serializable {
|
||||
/**
|
||||
* cache to hold the NumberElements of a Locale.
|
||||
*/
|
||||
private static final Hashtable<ULocale, String[][]> cachedLocaleData =
|
||||
new Hashtable<ULocale, String[][]>(3);
|
||||
private static final ICUCache<ULocale, String[][]> cachedLocaleData =
|
||||
new SimpleCache<ULocale, String[][]>();
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -12,7 +12,6 @@ import java.io.Serializable;
|
||||
import java.text.StringCharacterIterator;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Locale;
|
||||
import java.util.MissingResourceException;
|
||||
import java.util.Set;
|
||||
@ -1377,7 +1376,7 @@ public abstract class Calendar implements Serializable, Cloneable, Comparable<Ca
|
||||
* Cache to hold the firstDayOfWeek and minimalDaysInFirstWeek
|
||||
* of a Locale.
|
||||
*/
|
||||
private static Hashtable<ULocale, WeekData> cachedLocaleData = new Hashtable<ULocale, WeekData>(3);
|
||||
private static ICUCache<ULocale, WeekData> cachedLocaleData = new SimpleCache<ULocale, WeekData>();
|
||||
|
||||
/**
|
||||
* Value of the time stamp <code>stamp[]</code> indicating that
|
||||
|
@ -1,13 +1,13 @@
|
||||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 1996-2009, International Business Machines Corporation and *
|
||||
* Copyright (C) 1996-2010, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
package com.ibm.icu.text;
|
||||
|
||||
import java.util.Hashtable;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <code>RuleBasedTransliterator</code> is a transliterator
|
||||
@ -370,7 +370,7 @@ public class RuleBasedTransliterator extends Transliterator {
|
||||
|
||||
static class Data {
|
||||
public Data() {
|
||||
variableNames = new Hashtable<String, char[]>();
|
||||
variableNames = new HashMap<String, char[]>();
|
||||
ruleSet = new TransliterationRuleSet();
|
||||
}
|
||||
|
||||
@ -388,7 +388,7 @@ public class RuleBasedTransliterator extends Transliterator {
|
||||
* data.variables. The stand-in also represents the UnicodeSet in
|
||||
* the stored rules.
|
||||
*/
|
||||
Hashtable<String, char[]> variableNames;
|
||||
Map<String, char[]> variableNames;
|
||||
|
||||
/**
|
||||
* Map category variable (Character) to UnicodeMatcher or UnicodeReplacer.
|
||||
|
@ -8,10 +8,12 @@ package com.ibm.icu.text;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Enumeration;
|
||||
import java.util.Hashtable;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.MissingResourceException;
|
||||
|
||||
import com.ibm.icu.impl.ICUResourceBundle;
|
||||
@ -448,7 +450,7 @@ public abstract class Transliterator implements StringTransform {
|
||||
*/
|
||||
private static TransliteratorRegistry registry;
|
||||
|
||||
private static Hashtable<CaseInsensitiveString, String> displayNameCache;
|
||||
private static Map<CaseInsensitiveString, String> displayNameCache;
|
||||
|
||||
/**
|
||||
* Prefix for resource bundle key for the display name for a
|
||||
@ -1783,7 +1785,7 @@ public abstract class Transliterator implements StringTransform {
|
||||
registry = new TransliteratorRegistry();
|
||||
|
||||
// The display name cache starts out empty
|
||||
displayNameCache = new Hashtable<CaseInsensitiveString, String>();
|
||||
displayNameCache = Collections.synchronizedMap(new HashMap<CaseInsensitiveString, String>());
|
||||
/* The following code parses the index table located in
|
||||
* icu/data/translit/root.txt. The index is an n x 4 table
|
||||
* that follows this format:
|
||||
|
@ -12,8 +12,10 @@ package com.ibm.icu.text;
|
||||
|
||||
import java.text.ParsePosition;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.ibm.icu.impl.Utility;
|
||||
import com.ibm.icu.util.CaseInsensitiveString;
|
||||
@ -58,8 +60,8 @@ class TransliteratorIDParser {
|
||||
|
||||
private static final int REVERSE = Transliterator.REVERSE;
|
||||
|
||||
private static final Hashtable<CaseInsensitiveString, String> SPECIAL_INVERSES =
|
||||
new Hashtable<CaseInsensitiveString, String>();
|
||||
private static final Map<CaseInsensitiveString, String> SPECIAL_INVERSES =
|
||||
Collections.synchronizedMap(new HashMap<CaseInsensitiveString, String>());
|
||||
|
||||
/**
|
||||
* A structure containing the parsed data of a filtered ID, that
|
||||
|
@ -8,8 +8,9 @@ package com.ibm.icu.text;
|
||||
|
||||
import java.text.ParsePosition;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Hashtable;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.ibm.icu.impl.IllegalIcuArgumentException;
|
||||
import com.ibm.icu.impl.UCharacterProperty;
|
||||
@ -65,7 +66,7 @@ class TransliteratorParser {
|
||||
* Temporary table of variable names. When parsing is complete, this is
|
||||
* copied into data.variableNames.
|
||||
*/
|
||||
private Hashtable<String, char[]> variableNames;
|
||||
private Map<String, char[]> variableNames;
|
||||
|
||||
/**
|
||||
* String of standins for segments. Used during the parsing of a single
|
||||
@ -901,7 +902,7 @@ class TransliteratorParser {
|
||||
direction = dir;
|
||||
compoundFilter = null;
|
||||
variablesVector = new ArrayList<Object>();
|
||||
variableNames = new Hashtable<String, char[]>();
|
||||
variableNames = new HashMap<String, char[]>();
|
||||
parseData = new ParseData();
|
||||
|
||||
List<RuntimeException> errors = new ArrayList<RuntimeException>();
|
||||
@ -1072,7 +1073,7 @@ class TransliteratorParser {
|
||||
Data data = dataVector.get(i);
|
||||
data.variables = new Object[variablesVector.size()];
|
||||
variablesVector.toArray(data.variables);
|
||||
data.variableNames = new Hashtable<String, char[]>();
|
||||
data.variableNames = new HashMap<String, char[]>();
|
||||
data.variableNames.putAll(variableNames);
|
||||
}
|
||||
variablesVector = null;
|
||||
|
@ -13,9 +13,10 @@ package com.ibm.icu.text;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Enumeration;
|
||||
import java.util.Hashtable;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.MissingResourceException;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
@ -46,7 +47,7 @@ class TransliteratorRegistry {
|
||||
* RuleBasedTransliterator.Data, Transliterator.Factory, or one
|
||||
* of the entry classes defined here (AliasEntry or ResourceEntry).
|
||||
*/
|
||||
private Hashtable<CaseInsensitiveString, Object[]> registry;
|
||||
private Map<CaseInsensitiveString, Object[]> registry;
|
||||
|
||||
/**
|
||||
* DAG of visible IDs by spec. Hashtable: source => (Hashtable:
|
||||
@ -59,7 +60,7 @@ class TransliteratorRegistry {
|
||||
* Values are Hashtable of (CaseInsensitiveString -> Vector of
|
||||
* CaseInsensitiveString)
|
||||
*/
|
||||
private Hashtable<CaseInsensitiveString, Hashtable<CaseInsensitiveString, List<CaseInsensitiveString>>> specDAG;
|
||||
private Map<CaseInsensitiveString, Map<CaseInsensitiveString, List<CaseInsensitiveString>>> specDAG;
|
||||
|
||||
/**
|
||||
* Vector of public full IDs (CaseInsensitiveString objects).
|
||||
@ -288,8 +289,8 @@ class TransliteratorRegistry {
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
public TransliteratorRegistry() {
|
||||
registry = new Hashtable<CaseInsensitiveString, Object[]>();
|
||||
specDAG = new Hashtable<CaseInsensitiveString, Hashtable<CaseInsensitiveString, List<CaseInsensitiveString>>>();
|
||||
registry = Collections.synchronizedMap(new HashMap<CaseInsensitiveString, Object[]>());
|
||||
specDAG = Collections.synchronizedMap(new HashMap<CaseInsensitiveString, Map<CaseInsensitiveString, List<CaseInsensitiveString>>>());
|
||||
availableIDs = new ArrayList<CaseInsensitiveString>();
|
||||
}
|
||||
|
||||
@ -423,7 +424,7 @@ class TransliteratorRegistry {
|
||||
* @return An <code>Enumeration</code> over <code>String</code> objects
|
||||
*/
|
||||
public Enumeration<String> getAvailableSources() {
|
||||
return new IDEnumeration(specDAG.keys());
|
||||
return new IDEnumeration(Collections.enumeration(specDAG.keySet()));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -434,11 +435,11 @@ class TransliteratorRegistry {
|
||||
*/
|
||||
public Enumeration<String> getAvailableTargets(String source) {
|
||||
CaseInsensitiveString cisrc = new CaseInsensitiveString(source);
|
||||
Hashtable<CaseInsensitiveString, List<CaseInsensitiveString>> targets = specDAG.get(cisrc);
|
||||
Map<CaseInsensitiveString, List<CaseInsensitiveString>> targets = specDAG.get(cisrc);
|
||||
if (targets == null) {
|
||||
return new IDEnumeration(null);
|
||||
}
|
||||
return new IDEnumeration(targets.keys());
|
||||
return new IDEnumeration(Collections.enumeration(targets.keySet()));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -450,7 +451,7 @@ class TransliteratorRegistry {
|
||||
public Enumeration<String> getAvailableVariants(String source, String target) {
|
||||
CaseInsensitiveString cisrc = new CaseInsensitiveString(source);
|
||||
CaseInsensitiveString citrg = new CaseInsensitiveString(target);
|
||||
Hashtable<CaseInsensitiveString, List<CaseInsensitiveString>> targets = specDAG.get(cisrc);
|
||||
Map<CaseInsensitiveString, List<CaseInsensitiveString>> targets = specDAG.get(cisrc);
|
||||
if (targets == null) {
|
||||
return new IDEnumeration(null);
|
||||
}
|
||||
@ -539,9 +540,9 @@ class TransliteratorRegistry {
|
||||
CaseInsensitiveString cisrc = new CaseInsensitiveString(source);
|
||||
CaseInsensitiveString citrg = new CaseInsensitiveString(target);
|
||||
CaseInsensitiveString civar = new CaseInsensitiveString(variant);
|
||||
Hashtable<CaseInsensitiveString, List<CaseInsensitiveString>> targets = specDAG.get(cisrc);
|
||||
Map<CaseInsensitiveString, List<CaseInsensitiveString>> targets = specDAG.get(cisrc);
|
||||
if (targets == null) {
|
||||
targets = new Hashtable<CaseInsensitiveString, List<CaseInsensitiveString>>();
|
||||
targets = Collections.synchronizedMap(new HashMap<CaseInsensitiveString, List<CaseInsensitiveString>>());
|
||||
specDAG.put(cisrc, targets);
|
||||
}
|
||||
List<CaseInsensitiveString> variants = targets.get(citrg);
|
||||
@ -572,7 +573,7 @@ class TransliteratorRegistry {
|
||||
CaseInsensitiveString cisrc = new CaseInsensitiveString(source);
|
||||
CaseInsensitiveString citrg = new CaseInsensitiveString(target);
|
||||
CaseInsensitiveString civar = new CaseInsensitiveString(variant);
|
||||
Hashtable<CaseInsensitiveString, List<CaseInsensitiveString>> targets = specDAG.get(cisrc);
|
||||
Map<CaseInsensitiveString, List<CaseInsensitiveString>> targets = specDAG.get(cisrc);
|
||||
if (targets == null) {
|
||||
return; // should never happen for valid s-t/v
|
||||
}
|
||||
|
@ -8,9 +8,9 @@
|
||||
package com.ibm.icu.dev.test.calendar;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Enumeration;
|
||||
import java.util.Hashtable;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import com.ibm.icu.dev.test.TestFmwk;
|
||||
import com.ibm.icu.text.DateFormat;
|
||||
@ -238,7 +238,7 @@ public class CalendarTest extends TestFmwk {
|
||||
|
||||
// Keep a record of minima and maxima that we actually see.
|
||||
// These are kept in an array of arrays of hashes.
|
||||
Hashtable[][] limits = new Hashtable[fieldsToTest.length][2];
|
||||
Map[][] limits = new Map[fieldsToTest.length][2];
|
||||
Object nub = new Object(); // Meaningless placeholder
|
||||
|
||||
// This test can run for a long time; show progress.
|
||||
@ -267,10 +267,10 @@ public class CalendarTest extends TestFmwk {
|
||||
|
||||
// Fetch the hash for this field and keep track of the
|
||||
// minima and maxima.
|
||||
Hashtable[] h = limits[j];
|
||||
Map[] h = limits[j];
|
||||
if (h[0] == null) {
|
||||
h[0] = new Hashtable();
|
||||
h[1] = new Hashtable();
|
||||
h[0] = new HashMap();
|
||||
h[1] = new HashMap();
|
||||
}
|
||||
h[0].put(new Integer(minActual), nub);
|
||||
h[1].put(new Integer(maxActual), nub);
|
||||
@ -305,7 +305,7 @@ public class CalendarTest extends TestFmwk {
|
||||
int f = fieldsToTest[j];
|
||||
buf.setLength(0);
|
||||
buf.append(FIELD_NAME[f]);
|
||||
Hashtable[] h = limits[j];
|
||||
Map[] h = limits[j];
|
||||
boolean fullRangeSeen = true;
|
||||
for (int k=0; k<2; ++k) {
|
||||
int rangeLow = (k==0) ?
|
||||
@ -319,8 +319,7 @@ public class CalendarTest extends TestFmwk {
|
||||
fullRangeSeen = false;
|
||||
}
|
||||
buf.append(k==0 ? " minima seen=(" : "; maxima seen=(");
|
||||
for (Enumeration e=h[k].keys(); e.hasMoreElements(); ) {
|
||||
int v = ((Integer) e.nextElement()).intValue();
|
||||
for (Object v : h[k].keySet()) {
|
||||
buf.append(" " + v);
|
||||
}
|
||||
buf.append(") range=" + rangeLow + ".." + rangeHigh);
|
||||
|
@ -19,7 +19,6 @@ import java.text.ParseException;
|
||||
import java.text.ParsePosition;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Iterator;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
@ -501,7 +500,7 @@ public class TestMessageFormat extends com.ibm.icu.dev.test.TestFmwk {
|
||||
fp);
|
||||
assertEquals("format", compareStr, result.toString());
|
||||
|
||||
Map<String,Object> map = new Hashtable<String,Object>();
|
||||
Map<String,Object> map = new HashMap<String,Object>();
|
||||
try{
|
||||
msg.format("", map);
|
||||
} catch(Exception e){
|
||||
|
@ -9,8 +9,8 @@ package com.ibm.icu.dev.test.lang;
|
||||
|
||||
import java.io.FileWriter;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.Enumeration;
|
||||
import java.util.Hashtable;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.ibm.icu.lang.UCharacter;
|
||||
import com.ibm.icu.lang.UCharacterCategory;
|
||||
@ -25,285 +25,229 @@ import com.ibm.icu.lang.UCharacterCategory;
|
||||
|
||||
public final class UCharacterCompare
|
||||
{
|
||||
// private variables ================================================
|
||||
|
||||
private static Hashtable m_hashtable_ = new Hashtable();
|
||||
|
||||
// public methods ======================================================
|
||||
|
||||
/**
|
||||
* Main testing method
|
||||
*/
|
||||
public static void main(String arg[])
|
||||
{
|
||||
System.out.println("Starting character compare");
|
||||
try
|
||||
{
|
||||
FileWriter f;
|
||||
if (arg.length == 0)
|
||||
f = new FileWriter("compare.txt");
|
||||
else
|
||||
f = new FileWriter(arg[0]);
|
||||
PrintWriter p = new PrintWriter(f);
|
||||
p.print("char character name ");
|
||||
p.println("method name ucharacter character");
|
||||
for (char i = Character.MIN_VALUE; i < Character.MAX_VALUE; i ++)
|
||||
{
|
||||
System.out.println("character \\u" + Integer.toHexString(i));
|
||||
if (UCharacter.isDefined(i) != Character.isDefined(i))
|
||||
trackDifference(p, i, "isDefined()", "" + UCharacter.isDefined(i),
|
||||
"" + Character.isDefined(i));
|
||||
else
|
||||
{
|
||||
if (UCharacter.digit(i, 10) != Character.digit(i, 10))
|
||||
trackDifference(p, i, "digit()", "" + UCharacter.digit(i, 10),
|
||||
"" + Character.digit(i, 10));
|
||||
if (UCharacter.getNumericValue(i) != Character.getNumericValue(i))
|
||||
trackDifference(p, i, "getNumericValue()",
|
||||
"" + UCharacter.getNumericValue(i),
|
||||
"" + Character.getNumericValue(i));
|
||||
if (!compareType(UCharacter.getType(i), Character.getType(i)))
|
||||
trackDifference(p, i, "getType()", "" + UCharacter.getType(i),
|
||||
"" + Character.getType(i));
|
||||
if (UCharacter.isDigit(i) != Character.isDigit(i))
|
||||
trackDifference(p, i, "isDigit()",
|
||||
"" + UCharacter.isDigit(i),
|
||||
"" + Character.isDigit(i));
|
||||
if (UCharacter.isISOControl(i) != Character.isISOControl(i))
|
||||
trackDifference(p, i, "isISOControl()",
|
||||
"" + UCharacter.isISOControl(i),
|
||||
"" + Character.isISOControl(i));
|
||||
if (UCharacter.isLetter(i) != Character.isLetter(i))
|
||||
trackDifference(p, i, "isLetter()", "" + UCharacter.isLetter(i),
|
||||
"" + Character.isLetter(i));
|
||||
if (UCharacter.isLetterOrDigit(i) != Character.isLetterOrDigit(i))
|
||||
trackDifference(p, i, "isLetterOrDigit()",
|
||||
"" + UCharacter.isLetterOrDigit(i),
|
||||
"" + Character.isLetterOrDigit(i));
|
||||
if (UCharacter.isLowerCase(i) != Character.isLowerCase(i))
|
||||
trackDifference(p, i, "isLowerCase()",
|
||||
"" + UCharacter.isLowerCase(i),
|
||||
"" + Character.isLowerCase(i));
|
||||
if (UCharacter.isWhitespace(i) != Character.isWhitespace(i))
|
||||
trackDifference(p, i, "isWhitespace()",
|
||||
"" + UCharacter.isWhitespace(i),
|
||||
"" + Character.isWhitespace(i));
|
||||
if (UCharacter.isSpaceChar(i) != Character.isSpaceChar(i))
|
||||
trackDifference(p, i, "isSpaceChar()",
|
||||
"" + UCharacter.isSpaceChar(i),
|
||||
"" + Character.isSpaceChar(i));
|
||||
if (UCharacter.isTitleCase(i) != Character.isTitleCase(i))
|
||||
trackDifference(p, i, "isTitleChar()",
|
||||
"" + UCharacter.isTitleCase(i),
|
||||
"" + Character.isTitleCase(i));
|
||||
if (UCharacter.isUnicodeIdentifierPart(i) !=
|
||||
Character.isUnicodeIdentifierPart(i))
|
||||
trackDifference(p, i, "isUnicodeIdentifierPart()",
|
||||
"" + UCharacter.isUnicodeIdentifierPart(i),
|
||||
"" + Character.isUnicodeIdentifierPart(i));
|
||||
if (UCharacter.isUnicodeIdentifierStart(i) !=
|
||||
Character.isUnicodeIdentifierStart(i))
|
||||
trackDifference(p, i, "isUnicodeIdentifierStart()",
|
||||
"" + UCharacter.isUnicodeIdentifierStart(i),
|
||||
"" + Character.isUnicodeIdentifierStart(i));
|
||||
if (UCharacter.isIdentifierIgnorable(i) !=
|
||||
Character.isIdentifierIgnorable(i))
|
||||
trackDifference(p, i, "isIdentifierIgnorable()",
|
||||
"" + UCharacter.isIdentifierIgnorable(i),
|
||||
"" + Character.isIdentifierIgnorable(i));
|
||||
if (UCharacter.isUpperCase(i) != Character.isUpperCase(i))
|
||||
trackDifference(p, i, "isUpperCase()",
|
||||
"" + UCharacter.isUpperCase(i),
|
||||
"" + Character.isUpperCase(i));
|
||||
if (UCharacter.toLowerCase(i) != Character.toLowerCase(i))
|
||||
trackDifference(p, i, "toLowerCase()",
|
||||
Integer.toHexString(UCharacter.toLowerCase(i)),
|
||||
Integer.toHexString(Character.toLowerCase(i)));
|
||||
if (!UCharacter.toString(i).equals(new Character(i).toString()))
|
||||
trackDifference(p, i, "toString()",
|
||||
UCharacter.toString(i),
|
||||
new Character(i).toString());
|
||||
if (UCharacter.toTitleCase(i) != Character.toTitleCase(i))
|
||||
trackDifference(p, i, "toTitleCase()",
|
||||
Integer.toHexString(UCharacter.toTitleCase(i)),
|
||||
Integer.toHexString(Character.toTitleCase(i)));
|
||||
if (UCharacter.toUpperCase(i) != Character.toUpperCase(i))
|
||||
trackDifference(p, i, "toUpperCase()",
|
||||
Integer.toHexString(UCharacter.toUpperCase(i)),
|
||||
Integer.toHexString(Character.toUpperCase(i)));
|
||||
// private variables ================================================
|
||||
|
||||
private static Map<String, Integer> m_hashtable_ = new HashMap<String, Integer>();
|
||||
|
||||
// public methods ======================================================
|
||||
|
||||
/**
|
||||
* Main testing method
|
||||
*/
|
||||
public static void main(String arg[]) {
|
||||
System.out.println("Starting character compare");
|
||||
try {
|
||||
FileWriter f;
|
||||
if (arg.length == 0)
|
||||
f = new FileWriter("compare.txt");
|
||||
else
|
||||
f = new FileWriter(arg[0]);
|
||||
PrintWriter p = new PrintWriter(f);
|
||||
p.print("char character name ");
|
||||
p.println("method name ucharacter character");
|
||||
for (char i = Character.MIN_VALUE; i < Character.MAX_VALUE; i++) {
|
||||
System.out.println("character \\u" + Integer.toHexString(i));
|
||||
if (UCharacter.isDefined(i) != Character.isDefined(i))
|
||||
trackDifference(p, i, "isDefined()", "" + UCharacter.isDefined(i), "" + Character.isDefined(i));
|
||||
else {
|
||||
if (UCharacter.digit(i, 10) != Character.digit(i, 10))
|
||||
trackDifference(p, i, "digit()", "" + UCharacter.digit(i, 10), "" + Character.digit(i, 10));
|
||||
if (UCharacter.getNumericValue(i) != Character.getNumericValue(i))
|
||||
trackDifference(p, i, "getNumericValue()", "" + UCharacter.getNumericValue(i), ""
|
||||
+ Character.getNumericValue(i));
|
||||
if (!compareType(UCharacter.getType(i), Character.getType(i)))
|
||||
trackDifference(p, i, "getType()", "" + UCharacter.getType(i), "" + Character.getType(i));
|
||||
if (UCharacter.isDigit(i) != Character.isDigit(i))
|
||||
trackDifference(p, i, "isDigit()", "" + UCharacter.isDigit(i), "" + Character.isDigit(i));
|
||||
if (UCharacter.isISOControl(i) != Character.isISOControl(i))
|
||||
trackDifference(p, i, "isISOControl()", "" + UCharacter.isISOControl(i), ""
|
||||
+ Character.isISOControl(i));
|
||||
if (UCharacter.isLetter(i) != Character.isLetter(i))
|
||||
trackDifference(p, i, "isLetter()", "" + UCharacter.isLetter(i), "" + Character.isLetter(i));
|
||||
if (UCharacter.isLetterOrDigit(i) != Character.isLetterOrDigit(i))
|
||||
trackDifference(p, i, "isLetterOrDigit()", "" + UCharacter.isLetterOrDigit(i), ""
|
||||
+ Character.isLetterOrDigit(i));
|
||||
if (UCharacter.isLowerCase(i) != Character.isLowerCase(i))
|
||||
trackDifference(p, i, "isLowerCase()", "" + UCharacter.isLowerCase(i), ""
|
||||
+ Character.isLowerCase(i));
|
||||
if (UCharacter.isWhitespace(i) != Character.isWhitespace(i))
|
||||
trackDifference(p, i, "isWhitespace()", "" + UCharacter.isWhitespace(i), ""
|
||||
+ Character.isWhitespace(i));
|
||||
if (UCharacter.isSpaceChar(i) != Character.isSpaceChar(i))
|
||||
trackDifference(p, i, "isSpaceChar()", "" + UCharacter.isSpaceChar(i), ""
|
||||
+ Character.isSpaceChar(i));
|
||||
if (UCharacter.isTitleCase(i) != Character.isTitleCase(i))
|
||||
trackDifference(p, i, "isTitleChar()", "" + UCharacter.isTitleCase(i), ""
|
||||
+ Character.isTitleCase(i));
|
||||
if (UCharacter.isUnicodeIdentifierPart(i) != Character.isUnicodeIdentifierPart(i))
|
||||
trackDifference(p, i, "isUnicodeIdentifierPart()", "" + UCharacter.isUnicodeIdentifierPart(i),
|
||||
"" + Character.isUnicodeIdentifierPart(i));
|
||||
if (UCharacter.isUnicodeIdentifierStart(i) != Character.isUnicodeIdentifierStart(i))
|
||||
trackDifference(p, i, "isUnicodeIdentifierStart()",
|
||||
"" + UCharacter.isUnicodeIdentifierStart(i), "" + Character.isUnicodeIdentifierStart(i));
|
||||
if (UCharacter.isIdentifierIgnorable(i) != Character.isIdentifierIgnorable(i))
|
||||
trackDifference(p, i, "isIdentifierIgnorable()", "" + UCharacter.isIdentifierIgnorable(i), ""
|
||||
+ Character.isIdentifierIgnorable(i));
|
||||
if (UCharacter.isUpperCase(i) != Character.isUpperCase(i))
|
||||
trackDifference(p, i, "isUpperCase()", "" + UCharacter.isUpperCase(i), ""
|
||||
+ Character.isUpperCase(i));
|
||||
if (UCharacter.toLowerCase(i) != Character.toLowerCase(i))
|
||||
trackDifference(p, i, "toLowerCase()", Integer.toHexString(UCharacter.toLowerCase(i)), Integer
|
||||
.toHexString(Character.toLowerCase(i)));
|
||||
if (!UCharacter.toString(i).equals(new Character(i).toString()))
|
||||
trackDifference(p, i, "toString()", UCharacter.toString(i), new Character(i).toString());
|
||||
if (UCharacter.toTitleCase(i) != Character.toTitleCase(i))
|
||||
trackDifference(p, i, "toTitleCase()", Integer.toHexString(UCharacter.toTitleCase(i)), Integer
|
||||
.toHexString(Character.toTitleCase(i)));
|
||||
if (UCharacter.toUpperCase(i) != Character.toUpperCase(i))
|
||||
trackDifference(p, i, "toUpperCase()", Integer.toHexString(UCharacter.toUpperCase(i)), Integer
|
||||
.toHexString(Character.toUpperCase(i)));
|
||||
}
|
||||
}
|
||||
summary(p);
|
||||
p.close();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
summary(p);
|
||||
p.close();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
// private methods ===================================================
|
||||
|
||||
/**
|
||||
* Comparing types
|
||||
* @param uchartype UCharacter type
|
||||
* @param jchartype java.lang.Character type
|
||||
*/
|
||||
private static boolean compareType(int uchartype, int jchartype)
|
||||
{
|
||||
if (uchartype == UCharacterCategory.UNASSIGNED &&
|
||||
jchartype == Character.UNASSIGNED)
|
||||
return true;
|
||||
if (uchartype == UCharacterCategory.UPPERCASE_LETTER &&
|
||||
jchartype == Character.UPPERCASE_LETTER)
|
||||
return true;
|
||||
if (uchartype == UCharacterCategory.LOWERCASE_LETTER &&
|
||||
jchartype == Character.LOWERCASE_LETTER)
|
||||
return true;
|
||||
if (uchartype == UCharacterCategory.TITLECASE_LETTER &&
|
||||
jchartype == Character.TITLECASE_LETTER)
|
||||
return true;
|
||||
if (uchartype == UCharacterCategory.MODIFIER_LETTER &&
|
||||
jchartype == Character.MODIFIER_LETTER)
|
||||
return true;
|
||||
if (uchartype == UCharacterCategory.OTHER_LETTER &&
|
||||
jchartype == Character.OTHER_LETTER)
|
||||
return true;
|
||||
if (uchartype == UCharacterCategory.NON_SPACING_MARK &&
|
||||
jchartype == Character.NON_SPACING_MARK)
|
||||
return true;
|
||||
if (uchartype == UCharacterCategory.ENCLOSING_MARK &&
|
||||
jchartype == Character.ENCLOSING_MARK)
|
||||
return true;
|
||||
if (uchartype == UCharacterCategory.COMBINING_SPACING_MARK &&
|
||||
jchartype == Character.COMBINING_SPACING_MARK)
|
||||
return true;
|
||||
if (uchartype == UCharacterCategory.DECIMAL_DIGIT_NUMBER &&
|
||||
jchartype == Character.DECIMAL_DIGIT_NUMBER)
|
||||
return true;
|
||||
if (uchartype == UCharacterCategory.LETTER_NUMBER &&
|
||||
jchartype == Character.LETTER_NUMBER)
|
||||
return true;
|
||||
if (uchartype == UCharacterCategory.OTHER_NUMBER &&
|
||||
jchartype == Character.OTHER_NUMBER)
|
||||
return true;
|
||||
if (uchartype == UCharacterCategory.SPACE_SEPARATOR &&
|
||||
jchartype == Character.SPACE_SEPARATOR)
|
||||
return true;
|
||||
if (uchartype == UCharacterCategory.LINE_SEPARATOR &&
|
||||
jchartype == Character.LINE_SEPARATOR)
|
||||
return true;
|
||||
if (uchartype == UCharacterCategory.PARAGRAPH_SEPARATOR &&
|
||||
jchartype == Character.PARAGRAPH_SEPARATOR)
|
||||
return true;
|
||||
if (uchartype == UCharacterCategory.CONTROL &&
|
||||
jchartype == Character.CONTROL)
|
||||
return true;
|
||||
if (uchartype == UCharacterCategory.FORMAT &&
|
||||
jchartype == Character.FORMAT)
|
||||
return true;
|
||||
if (uchartype == UCharacterCategory.PRIVATE_USE &&
|
||||
jchartype == Character.PRIVATE_USE)
|
||||
return true;
|
||||
if (uchartype == UCharacterCategory.SURROGATE &&
|
||||
jchartype == Character.SURROGATE)
|
||||
return true;
|
||||
if (uchartype == UCharacterCategory.DASH_PUNCTUATION &&
|
||||
jchartype == Character.DASH_PUNCTUATION)
|
||||
return true;
|
||||
if (uchartype == UCharacterCategory.START_PUNCTUATION &&
|
||||
jchartype == Character.START_PUNCTUATION)
|
||||
return true;
|
||||
if (uchartype == UCharacterCategory.END_PUNCTUATION &&
|
||||
jchartype == Character.END_PUNCTUATION)
|
||||
return true;
|
||||
if (uchartype == UCharacterCategory.CONNECTOR_PUNCTUATION &&
|
||||
jchartype == Character.CONNECTOR_PUNCTUATION)
|
||||
return true;
|
||||
if (uchartype == UCharacterCategory.OTHER_PUNCTUATION &&
|
||||
jchartype == Character.OTHER_PUNCTUATION)
|
||||
return true;
|
||||
if (uchartype == UCharacterCategory.MATH_SYMBOL &&
|
||||
jchartype == Character.MATH_SYMBOL)
|
||||
return true;
|
||||
if (uchartype == UCharacterCategory.CURRENCY_SYMBOL &&
|
||||
jchartype == Character.CURRENCY_SYMBOL)
|
||||
return true;
|
||||
if (uchartype == UCharacterCategory.MODIFIER_SYMBOL &&
|
||||
jchartype == Character.MODIFIER_SYMBOL)
|
||||
return true;
|
||||
if (uchartype == UCharacterCategory.OTHER_SYMBOL &&
|
||||
jchartype == Character.OTHER_SYMBOL)
|
||||
return true;
|
||||
if (uchartype == UCharacterCategory.INITIAL_PUNCTUATION &&
|
||||
jchartype == Character.START_PUNCTUATION)
|
||||
return true;
|
||||
if (uchartype == UCharacterCategory.FINAL_PUNCTUATION &&
|
||||
jchartype == Character.END_PUNCTUATION)
|
||||
return true;
|
||||
/*if (uchartype == UCharacterCategory.GENERAL_OTHER_TYPES &&
|
||||
jchartype == Character.GENERAL_OTHER_TYPES)
|
||||
return true;*/
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// private methods ===================================================
|
||||
|
||||
/**
|
||||
* Difference writing to file
|
||||
* @param f file outputstream
|
||||
* @param ch code point
|
||||
* @param method for testing
|
||||
* @param ucharval UCharacter value after running method
|
||||
* @param charval Character value after running method
|
||||
*/
|
||||
private static void trackDifference(PrintWriter f, int ch, String method,
|
||||
String ucharval, String charval)
|
||||
throws Exception
|
||||
{
|
||||
if (m_hashtable_.containsKey(method))
|
||||
{
|
||||
Integer value = (Integer)m_hashtable_.get(method);
|
||||
m_hashtable_.put(method, new Integer(value.intValue() + 1));
|
||||
}
|
||||
else
|
||||
m_hashtable_.put(method, new Integer(1));
|
||||
|
||||
String temp = Integer.toHexString(ch);
|
||||
StringBuffer s = new StringBuffer(temp);
|
||||
for (int i = 0; i < 6 - temp.length(); i ++)
|
||||
s.append(' ');
|
||||
temp = UCharacter.getExtendedName(ch);
|
||||
if (temp == null)
|
||||
temp = " ";
|
||||
s.append(temp);
|
||||
for (int i = 0; i < 73 - temp.length(); i ++)
|
||||
s.append(' ');
|
||||
|
||||
s.append(method);
|
||||
for (int i = 0; i < 27 - method.length(); i ++)
|
||||
s.append(' ');
|
||||
s.append(ucharval);
|
||||
for (int i = 0; i < 11 - ucharval.length(); i ++)
|
||||
s.append(' ');
|
||||
s.append(charval);
|
||||
f.println(s.toString());
|
||||
* Comparing types
|
||||
*
|
||||
* @param uchartype
|
||||
* UCharacter type
|
||||
* @param jchartype
|
||||
* java.lang.Character type
|
||||
*/
|
||||
private static boolean compareType(int uchartype, int jchartype) {
|
||||
if (uchartype == UCharacterCategory.UNASSIGNED && jchartype == Character.UNASSIGNED)
|
||||
return true;
|
||||
if (uchartype == UCharacterCategory.UPPERCASE_LETTER && jchartype == Character.UPPERCASE_LETTER)
|
||||
return true;
|
||||
if (uchartype == UCharacterCategory.LOWERCASE_LETTER && jchartype == Character.LOWERCASE_LETTER)
|
||||
return true;
|
||||
if (uchartype == UCharacterCategory.TITLECASE_LETTER && jchartype == Character.TITLECASE_LETTER)
|
||||
return true;
|
||||
if (uchartype == UCharacterCategory.MODIFIER_LETTER && jchartype == Character.MODIFIER_LETTER)
|
||||
return true;
|
||||
if (uchartype == UCharacterCategory.OTHER_LETTER && jchartype == Character.OTHER_LETTER)
|
||||
return true;
|
||||
if (uchartype == UCharacterCategory.NON_SPACING_MARK && jchartype == Character.NON_SPACING_MARK)
|
||||
return true;
|
||||
if (uchartype == UCharacterCategory.ENCLOSING_MARK && jchartype == Character.ENCLOSING_MARK)
|
||||
return true;
|
||||
if (uchartype == UCharacterCategory.COMBINING_SPACING_MARK && jchartype == Character.COMBINING_SPACING_MARK)
|
||||
return true;
|
||||
if (uchartype == UCharacterCategory.DECIMAL_DIGIT_NUMBER && jchartype == Character.DECIMAL_DIGIT_NUMBER)
|
||||
return true;
|
||||
if (uchartype == UCharacterCategory.LETTER_NUMBER && jchartype == Character.LETTER_NUMBER)
|
||||
return true;
|
||||
if (uchartype == UCharacterCategory.OTHER_NUMBER && jchartype == Character.OTHER_NUMBER)
|
||||
return true;
|
||||
if (uchartype == UCharacterCategory.SPACE_SEPARATOR && jchartype == Character.SPACE_SEPARATOR)
|
||||
return true;
|
||||
if (uchartype == UCharacterCategory.LINE_SEPARATOR && jchartype == Character.LINE_SEPARATOR)
|
||||
return true;
|
||||
if (uchartype == UCharacterCategory.PARAGRAPH_SEPARATOR && jchartype == Character.PARAGRAPH_SEPARATOR)
|
||||
return true;
|
||||
if (uchartype == UCharacterCategory.CONTROL && jchartype == Character.CONTROL)
|
||||
return true;
|
||||
if (uchartype == UCharacterCategory.FORMAT && jchartype == Character.FORMAT)
|
||||
return true;
|
||||
if (uchartype == UCharacterCategory.PRIVATE_USE && jchartype == Character.PRIVATE_USE)
|
||||
return true;
|
||||
if (uchartype == UCharacterCategory.SURROGATE && jchartype == Character.SURROGATE)
|
||||
return true;
|
||||
if (uchartype == UCharacterCategory.DASH_PUNCTUATION && jchartype == Character.DASH_PUNCTUATION)
|
||||
return true;
|
||||
if (uchartype == UCharacterCategory.START_PUNCTUATION && jchartype == Character.START_PUNCTUATION)
|
||||
return true;
|
||||
if (uchartype == UCharacterCategory.END_PUNCTUATION && jchartype == Character.END_PUNCTUATION)
|
||||
return true;
|
||||
if (uchartype == UCharacterCategory.CONNECTOR_PUNCTUATION && jchartype == Character.CONNECTOR_PUNCTUATION)
|
||||
return true;
|
||||
if (uchartype == UCharacterCategory.OTHER_PUNCTUATION && jchartype == Character.OTHER_PUNCTUATION)
|
||||
return true;
|
||||
if (uchartype == UCharacterCategory.MATH_SYMBOL && jchartype == Character.MATH_SYMBOL)
|
||||
return true;
|
||||
if (uchartype == UCharacterCategory.CURRENCY_SYMBOL && jchartype == Character.CURRENCY_SYMBOL)
|
||||
return true;
|
||||
if (uchartype == UCharacterCategory.MODIFIER_SYMBOL && jchartype == Character.MODIFIER_SYMBOL)
|
||||
return true;
|
||||
if (uchartype == UCharacterCategory.OTHER_SYMBOL && jchartype == Character.OTHER_SYMBOL)
|
||||
return true;
|
||||
if (uchartype == UCharacterCategory.INITIAL_PUNCTUATION && jchartype == Character.START_PUNCTUATION)
|
||||
return true;
|
||||
if (uchartype == UCharacterCategory.FINAL_PUNCTUATION && jchartype == Character.END_PUNCTUATION)
|
||||
return true;
|
||||
/*
|
||||
* if (uchartype == UCharacterCategory.GENERAL_OTHER_TYPES && jchartype == Character.GENERAL_OTHER_TYPES) return
|
||||
* true;
|
||||
*/
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Does up a summary of the differences
|
||||
* @param f file outputstream
|
||||
*/
|
||||
private static void summary(PrintWriter f)
|
||||
{
|
||||
f.println("==================================================");
|
||||
f.println("Summary of differences");
|
||||
for (Enumeration e = m_hashtable_.keys() ; e.hasMoreElements() ;)
|
||||
{
|
||||
StringBuffer method = new StringBuffer((String)e.nextElement());
|
||||
int count = ((Integer)m_hashtable_.get(method.toString())).intValue();
|
||||
for (int i = 30 - method.length(); i > 0; i --)
|
||||
method.append(' ');
|
||||
f.println(method + " " + count);
|
||||
* Difference writing to file
|
||||
*
|
||||
* @param f
|
||||
* file outputstream
|
||||
* @param ch
|
||||
* code point
|
||||
* @param method
|
||||
* for testing
|
||||
* @param ucharval
|
||||
* UCharacter value after running method
|
||||
* @param charval
|
||||
* Character value after running method
|
||||
*/
|
||||
private static void trackDifference(PrintWriter f, int ch, String method, String ucharval, String charval)
|
||||
throws Exception {
|
||||
if (m_hashtable_.containsKey(method)) {
|
||||
Integer value = m_hashtable_.get(method);
|
||||
m_hashtable_.put(method, new Integer(value.intValue() + 1));
|
||||
} else
|
||||
m_hashtable_.put(method, new Integer(1));
|
||||
|
||||
String temp = Integer.toHexString(ch);
|
||||
StringBuffer s = new StringBuffer(temp);
|
||||
for (int i = 0; i < 6 - temp.length(); i++)
|
||||
s.append(' ');
|
||||
temp = UCharacter.getExtendedName(ch);
|
||||
if (temp == null)
|
||||
temp = " ";
|
||||
s.append(temp);
|
||||
for (int i = 0; i < 73 - temp.length(); i++)
|
||||
s.append(' ');
|
||||
|
||||
s.append(method);
|
||||
for (int i = 0; i < 27 - method.length(); i++)
|
||||
s.append(' ');
|
||||
s.append(ucharval);
|
||||
for (int i = 0; i < 11 - ucharval.length(); i++)
|
||||
s.append(' ');
|
||||
s.append(charval);
|
||||
f.println(s.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* Does up a summary of the differences
|
||||
*
|
||||
* @param f
|
||||
* file outputstream
|
||||
*/
|
||||
private static void summary(PrintWriter f) {
|
||||
f.println("==================================================");
|
||||
f.println("Summary of differences");
|
||||
for (String s : m_hashtable_.keySet()) {
|
||||
StringBuilder method = new StringBuilder(s);
|
||||
int count = (m_hashtable_.get(s)).intValue();
|
||||
for (int i = 30 - method.length(); i > 0; i--)
|
||||
method.append(' ');
|
||||
f.println(method + " " + count);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,24 +1,25 @@
|
||||
package com.ibm.icu.dev.test.normalizer;
|
||||
|
||||
import java.util.Hashtable;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
*******************************************************************************
|
||||
* Copyright (C) 1998-2007, International Business Machines Corporation and *
|
||||
* Copyright (C) 1998-2010, International Business Machines Corporation and *
|
||||
* Unicode, Inc. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*
|
||||
* Integer hash table. Uses Java Hashtable for now.
|
||||
* Integer hash table.
|
||||
* @author Mark Davis
|
||||
*/
|
||||
|
||||
public class IntHashtable {
|
||||
// static final String copyright = "Copyright (C) 1998-2003 International Business Machines Corporation and Unicode, Inc.";
|
||||
|
||||
|
||||
public IntHashtable (int defaultValue) {
|
||||
this.defaultValue = defaultValue;
|
||||
}
|
||||
|
||||
|
||||
public void put(int key, int value) {
|
||||
if (value == defaultValue) {
|
||||
table.remove(new Integer(key));
|
||||
@ -26,13 +27,13 @@ public class IntHashtable {
|
||||
table.put(new Integer(key), new Integer(value));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public int get(int key) {
|
||||
Object value = table.get(new Integer(key));
|
||||
Integer value = table.get(new Integer(key));
|
||||
if (value == null) return defaultValue;
|
||||
return ((Integer)value).intValue();
|
||||
return value.intValue();
|
||||
}
|
||||
|
||||
|
||||
private int defaultValue;
|
||||
private Hashtable table = new Hashtable();
|
||||
private Map<Integer, Integer> table = new HashMap<Integer, Integer>();
|
||||
}
|
@ -1,10 +1,12 @@
|
||||
package com.ibm.icu.dev.test.normalizer;
|
||||
|
||||
import java.util.Hashtable;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
*******************************************************************************
|
||||
* Copyright (C) 1998-2007, International Business Machines Corporation and *
|
||||
* Copyright (C) 1998-2010, International Business Machines Corporation and *
|
||||
* Unicode, Inc. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*
|
||||
@ -13,12 +15,11 @@ import java.util.Hashtable;
|
||||
*/
|
||||
|
||||
public class IntStringHashtable {
|
||||
// static final String copyright = "Copyright (C) 1998-2003 International Business Machines Corporation and Unicode, Inc.";
|
||||
|
||||
|
||||
public IntStringHashtable (String defaultValue) {
|
||||
this.defaultValue = defaultValue;
|
||||
}
|
||||
|
||||
|
||||
public void put(int key, String value) {
|
||||
if (value == defaultValue) {
|
||||
table.remove(new Integer(key));
|
||||
@ -26,13 +27,13 @@ public class IntStringHashtable {
|
||||
table.put(new Integer(key), value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public String get(int key) {
|
||||
Object value = table.get(new Integer(key));
|
||||
String value = table.get(new Integer(key));
|
||||
if (value == null) return defaultValue;
|
||||
return (String)value;
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
private String defaultValue;
|
||||
private Hashtable table = new Hashtable();
|
||||
private Map<Integer, String> table = new HashMap<Integer, String>();
|
||||
}
|
@ -1,25 +1,24 @@
|
||||
package com.ibm.icu.dev.test.normalizer;
|
||||
|
||||
import java.util.Hashtable;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2002-2007, International Business Machines Corporation and *
|
||||
* Copyright (C) 2002-2010, International Business Machines Corporation and *
|
||||
* Unicode, Inc. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*
|
||||
* Hashtable storing ints addressed by longs. Used
|
||||
* for storing of composition data. Uses Java Hashtable
|
||||
* for now.
|
||||
* for storing of composition data.
|
||||
* @author Vladimir Weinstein
|
||||
*/
|
||||
public class LongHashtable {
|
||||
// static final String copyright = "Copyright (C) 2002-2003 International Business Machines Corporation and Unicode, Inc.";
|
||||
|
||||
|
||||
public LongHashtable (int defaultValue) {
|
||||
this.defaultValue = defaultValue;
|
||||
}
|
||||
|
||||
|
||||
public void put(long key, int value) {
|
||||
if (value == defaultValue) {
|
||||
table.remove(new Long(key));
|
||||
@ -27,14 +26,14 @@ public class LongHashtable {
|
||||
table.put(new Long(key), new Integer(value));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public int get(long key) {
|
||||
Object value = table.get(new Long(key));
|
||||
Integer value = table.get(new Long(key));
|
||||
if (value == null) return defaultValue;
|
||||
return ((Integer)value).intValue();
|
||||
return value.intValue();
|
||||
}
|
||||
|
||||
|
||||
private int defaultValue;
|
||||
private Hashtable table = new Hashtable();
|
||||
private Map<Long, Integer> table = new HashMap<Long, Integer>();
|
||||
|
||||
}
|
||||
|
@ -12,9 +12,10 @@ package com.ibm.icu.dev.test.util;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Hashtable;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import com.ibm.icu.dev.test.TestFmwk;
|
||||
@ -1207,8 +1208,8 @@ public class ULocaleTest extends TestFmwk {
|
||||
}
|
||||
}
|
||||
private void initHashtable() {
|
||||
h[0] = new Hashtable();
|
||||
h[1] = new Hashtable();
|
||||
h[0] = new HashMap<String, String>();
|
||||
h[1] = new HashMap<String, String>();
|
||||
|
||||
//display in English
|
||||
h[0].put("collation", "collation");
|
||||
@ -1246,7 +1247,7 @@ public class ULocaleTest extends TestFmwk {
|
||||
}
|
||||
|
||||
//Hashtables for storing expected display of keys/types of locale in English and Chinese
|
||||
private static Hashtable[] h = new Hashtable[2];
|
||||
private static Map[] h = new Map[2];
|
||||
|
||||
private static final String ACCEPT_LANGUAGE_TESTS[][] = {
|
||||
/*# result fallback? */
|
||||
|
@ -5,7 +5,9 @@
|
||||
*******************************************************************************
|
||||
*/
|
||||
package com.ibm.icu.dev.test.translit;
|
||||
import java.util.Hashtable;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.ibm.icu.impl.Utility;
|
||||
import com.ibm.icu.text.Transliterator;
|
||||
@ -452,12 +454,12 @@ public class JamoTest extends TransliteratorTest {
|
||||
"(Hf)", "\u11C2",
|
||||
};
|
||||
|
||||
static Hashtable JAMO_TO_NAME;
|
||||
static Hashtable NAME_TO_JAMO;
|
||||
static Map<String, String> JAMO_TO_NAME;
|
||||
static Map<String, String> NAME_TO_JAMO;
|
||||
|
||||
static {
|
||||
JAMO_TO_NAME = new Hashtable();
|
||||
NAME_TO_JAMO = new Hashtable();
|
||||
JAMO_TO_NAME = new HashMap<String, String>();
|
||||
NAME_TO_JAMO = new HashMap<String, String>();
|
||||
for (int i=0; i<JAMO_NAMES.length; i+=2) {
|
||||
JAMO_TO_NAME.put(JAMO_NAMES[i+1], JAMO_NAMES[i]);
|
||||
NAME_TO_JAMO.put(JAMO_NAMES[i], JAMO_NAMES[i+1]);
|
||||
@ -475,7 +477,7 @@ public class JamoTest extends TransliteratorTest {
|
||||
if (c == '(') {
|
||||
int j = input.indexOf(')', i+1);
|
||||
if ((j-i) >= 2 && (j-i) <= 6) { // "(A)", "(IEUNG)"
|
||||
String jamo = (String) NAME_TO_JAMO.get(input.substring(i, j+1));
|
||||
String jamo = NAME_TO_JAMO.get(input.substring(i, j+1));
|
||||
if (jamo != null) {
|
||||
buf.append(jamo);
|
||||
i = j;
|
||||
@ -497,7 +499,7 @@ public class JamoTest extends TransliteratorTest {
|
||||
for (int i=0; i<input.length(); ++i) {
|
||||
char c = input.charAt(i);
|
||||
if (c >= 0x1100 && c <= 0x11C2) {
|
||||
String name = (String) JAMO_TO_NAME.get(input.substring(i, i+1));
|
||||
String name = JAMO_TO_NAME.get(input.substring(i, i+1));
|
||||
if (name != null) {
|
||||
buf.append(name);
|
||||
continue;
|
||||
|
Loading…
Reference in New Issue
Block a user