CompareMode

Instances of this class can compare strings. Case sensitive and case insensitive comparison is supported, and comparison using a collator.

Methods
static boolean compareLocaleNames(Locale locale, String name)
Compare name name of the locale with the given name.
static boolean compareLocaleNames(Locale locale, String name)
Compare name name of the locale with the given name. The case of the name is ignored.
Parameters:
locale - the locale
name - the name
Returns:
true if they match
static Collator getCollator(String name)
Get the collator object for the given language name or language / country combination.
static Collator getCollator(String name)
Get the collator object for the given language name or language / country combination.
Parameters:
name - the language name
Returns:
the collator
static CompareMode getInstance(String name, int strength)
Create a new compare mode with the given collator and strength.
static CompareMode getInstance(String name, int strength)
Create a new compare mode with the given collator and strength. If required, a new CompareMode is created, or if possible the last one is returned. A cache is used to speed up comparison when using a collator; CollationKey objects are cached.
Parameters:
name - the collation name or null
strength - the collation strength
Returns:
the compare mode
static CompareMode getInstance(String name, int strength, boolean binaryUnsigned)
Create a new compare mode with the given collator and strength.
static CompareMode getInstance(String name, int strength, boolean binaryUnsigned)
Create a new compare mode with the given collator and strength. If required, a new CompareMode is created, or if possible the last one is returned. A cache is used to speed up comparison when using a collator; CollationKey objects are cached.
Parameters:
name - the collation name or null
strength - the collation strength
binaryUnsigned - whether to compare binaries as unsigned
Returns:
the compare mode
static String getName(Locale l)
Get the collation name.
static String getName(Locale l)
Get the collation name.
Parameters:
l - the locale
Returns:
the name of the collation
int compareString(String a, String b, boolean ignoreCase)
Compare two strings.
int compareString(String a, String b, boolean ignoreCase)
Compare two strings.
Parameters:
a - the first string
b - the second string
ignoreCase - true if a case-insensitive comparison should be made
Returns:
-1 if the first string is 'smaller', 1 if the second string is smaller, and 0 if they are equal
boolean equals(Object obj)
boolean equals(Object obj)
boolean equalsChars(String a, int ai, String b, int bi, boolean ignoreCase)
Compare two characters in a string.
boolean equalsChars(String a, int ai, String b, int bi, boolean ignoreCase)
Compare two characters in a string.
Parameters:
a - the first string
ai - the character index in the first string
b - the second string
bi - the character index in the second string
ignoreCase - true if a case-insensitive comparison should be made
Returns:
true if the characters are equals
String getName()
String getName()
int getStrength()
int getStrength()
int hashCode()
int hashCode()
boolean isBinaryUnsigned()
boolean isBinaryUnsigned()

Fields
static String CHARSET = "CHARSET_"
static String DEFAULT = "DEFAULT_"
static String ICU4J = "ICU4J_"
static String OFF = "OFF"
static String SIGNED = "SIGNED"
static String UNSIGNED = "UNSIGNED"

CHARSET = "CHARSET_"

This constant means the charset specified should be used. This will fail if the specified charset does not exist.

DEFAULT = "DEFAULT_"

This constant means the default collator should be used, even if ICU4J is in the classpath.

ICU4J = "ICU4J_"

This constant means ICU4J should be used (this will fail if it is not in the classpath).

OFF = "OFF"

This constant means there is no collator set, and the default string comparison is to be used.

SIGNED = "SIGNED"

This constant means that the BINARY columns are sorted as if the bytes were signed.

UNSIGNED = "UNSIGNED"

This constant means that the BINARY columns are sorted as if the bytes were unsigned.