FileDocCategorySizeDatePackage
StringComparator.javaAPI DocphoneME MR2 API (J2ME)3779Fri May 04 08:29:14 BST 2007javax.microedition.global

StringComparator

public final class StringComparator extends Object

Fields Summary
public static final int
LEVEL1
public static final int
LEVEL2
public static final int
LEVEL3
public static final int
IDENTICAL
private int
level
Collation level
private String
locale
Locale
private static com.sun.j2me.global.CollationAbstractionLayer
collationAbstractionLayer
Instance of the CollationAbstractionLayer
private com.sun.j2me.global.CommonStringComparator
stringComparatorImpl
String comparator
Constructors Summary
public StringComparator()

    
    // JAVADOC COMMENT ELIDED 
      
        this(System.getProperty("microedition.locale"), LEVEL1);
    
public StringComparator(String locale)

        this(locale, LEVEL1);
    
public StringComparator(String locale, int level)

        
        // check the level
        if ((level < LEVEL1) || (level > LEVEL3) && (level != IDENTICAL)) {
            throw new IllegalArgumentException("Invalid level");
        }

        if (!LocaleHelpers.isValidLocale(locale) && !("".equals(locale))) {
            throw new IllegalArgumentException("Invalid locale format");
        }

        locale = LocaleHelpers.normalizeLocale(locale);

        if ("".equals(locale)) {
            this.locale = null;
        } else {
            this.locale = locale;
        }
        this.level = level;

        if (locale == null) {
            locale = "";
        }

        stringComparatorImpl = collationAbstractionLayer.getStringComparator(
                locale, level);
    
Methods Summary
public intcompare(java.lang.String s1, java.lang.String s2)

        return stringComparatorImpl.compare(s1, s2);
    
public booleanequals(java.lang.String s1, java.lang.String s2)

        return stringComparatorImpl.equals(s1, s2);
    
public intgetLevel()

        return level;
    
public java.lang.StringgetLocale()

        return locale;
    
public static java.lang.String[]getSupportedLocales()

        return collationAbstractionLayer.getSupportedLocales();