home *** CD-ROM | disk | FTP | other *** search
- package java.text;
-
- import java.io.Serializable;
- import java.text.resources.LocaleData;
- import java.util.Hashtable;
- import java.util.Locale;
- import java.util.MissingResourceException;
- import java.util.ResourceBundle;
-
- public abstract class Collator implements Cloneable, Serializable {
- public static final int PRIMARY = 0;
- public static final int SECONDARY = 1;
- public static final int TERTIARY = 2;
- public static final int IDENTICAL = 3;
- public static final int NO_DECOMPOSITION = 0;
- public static final int CANONICAL_DECOMPOSITION = 1;
- public static final int FULL_DECOMPOSITION = 2;
- private int strength = 2;
- private int decmp = 1;
- private static Hashtable cache = new Hashtable();
- static final int LESS = -1;
- static final int EQUAL = 0;
- static final int GREATER = 1;
- static final long serialVersionUID = -7718728969026499504L;
-
- public static synchronized Collator getInstance() {
- return getInstance(Locale.getDefault());
- }
-
- public static synchronized Collator getInstance(Locale var0) {
- Collator var1 = null;
- var1 = (RuleBasedCollator)cache.get(var0);
- if (var1 != null) {
- return (Collator)((RuleBasedCollator)var1).clone();
- } else {
- String var2;
- try {
- ResourceBundle var3 = ResourceBundle.getBundle("java.text.resources.LocaleElements", var0);
- var2 = var3.getString("CollationElements");
- } catch (MissingResourceException var6) {
- var2 = "";
- }
-
- try {
- var1 = new RuleBasedCollator(CollationRules.DEFAULTRULES + var2);
- } catch (ParseException var5) {
- try {
- var1 = new RuleBasedCollator(CollationRules.DEFAULTRULES);
- } catch (ParseException var4) {
- }
- }
-
- cache.put(var0, var1);
- return var1;
- }
- }
-
- public abstract int compare(String var1, String var2);
-
- public abstract CollationKey getCollationKey(String var1);
-
- public boolean equals(String var1, String var2) {
- return this.compare(var1, var2) == 0;
- }
-
- public synchronized int getStrength() {
- return this.strength;
- }
-
- public synchronized void setStrength(int var1) {
- if (var1 != 0 && var1 != 1 && var1 != 2 && var1 != 3) {
- throw new IllegalArgumentException("Incorrect comparison level.");
- } else {
- this.strength = var1;
- }
- }
-
- public synchronized int getDecomposition() {
- return this.decmp;
- }
-
- public synchronized void setDecomposition(int var1) {
- if (var1 != 0 && var1 != 1 && var1 != 2) {
- throw new IllegalArgumentException("Wrong decomposition mode.");
- } else {
- this.decmp = var1;
- }
- }
-
- public static synchronized Locale[] getAvailableLocales() {
- return LocaleData.getAvailableLocales("CollationElements");
- }
-
- public Object clone() {
- try {
- return (Collator)super.clone();
- } catch (CloneNotSupportedException var1) {
- throw new InternalError();
- }
- }
-
- public boolean equals(Object var1) {
- if (this == var1) {
- return true;
- } else if (var1 == null) {
- return false;
- } else if (this.getClass() != var1.getClass()) {
- return false;
- } else {
- Collator var2 = (Collator)var1;
- return this.strength == var2.strength && this.decmp == var2.decmp;
- }
- }
-
- public abstract int hashCode();
-
- protected Collator() {
- }
- }
-