|
BenQ Mobile |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavax.microedition.global.StringComparator
Compares two strings using locale-specific rules. The comparison is performed by the compare method according to the Unicode Collation Algorithm (Unicode Technical Standard #10). Canonical character decomposition is always used.
If the selected locale is null or the empty string, the StringComparator uses the generic collation algorithm, which may not be appropriate for all situations. If the selected locale is non-null and non-empty, but the StringComparator implementation does not support it, the constructors throw an UnsupportedLocaleException. If the selected locale is supported, the collation is tailored according to the locale. The tailored collation rules are implementation-specific and are not exposed to application programmers.
The generic collation data should match the common data in the Common Locale Data Repository (see http: //www.unicode.org/cldr/ for details).
The default StringComparator constructor uses the LEVEL1 collation level.
Copyright: Copyright (c) Siemens AG 2004 * ALL RIGHTS RESERVED
Field Summary | |
static int |
IDENTICAL
Constant for the comparison level that takes all differences between characters into account. |
static int |
LEVEL1
Constant for the primary collation level. |
static int |
LEVEL2
Constant for the secondary collation level. |
static int |
LEVEL3
Constant for the tertiary collation level. |
Constructor Summary | |
StringComparator()
Constructs an instance using the default locale indicated by the microedition.locale system property, using the default collation level LEVEL1. |
|
StringComparator(java.lang.String locale)
Constructs an instance using the specified locale and the default collation level LEVEL1. |
|
StringComparator(java.lang.String locale,
int level)
Constructs an instance using the specified locale and collation level. |
Method Summary | |
int |
compare(java.lang.String s1,
java.lang.String s2)
Compares the two strings using the rules specific to the associated locale of this instance. |
boolean |
equals(java.lang.String s1,
java.lang.String s2)
Tests if the two strings are equal according to the rules specific to the associated locale of this instance. |
int |
getLevel()
Gets the current comparison level. |
java.lang.String |
getLocale()
Gets the locale of this StringComparator. |
static java.lang.String[] |
getSupportedLocales()
Gets the locales for which a StringComparator is available in this implementation. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int LEVEL1
public static final int LEVEL2
public static final int LEVEL3
public static final int IDENTICAL
Constructor Detail |
public StringComparator(java.lang.String locale, int level) throws UnsupportedLocaleException, java.lang.IllegalArgumentException
Parameters: locale - the locale to use, or null to use the generic collation algorithm level - the collation level to use
locale
- the locale to use,
or null to use the generic collation algorithmlevel
- the collation level to use
UnsupportedLocaleException
- -
if the specified locale is not supported by the
StringComparator implementation
java.lang.IllegalArgumentException
- -
if the specified locale is not valid
according to the MIDP 2.0 specification,
or if level is not one of the constants defined in this classpublic StringComparator() throws UnsupportedLocaleException
UnsupportedLocaleException
- - if the default locale is
not supported by the StringComparator implementationpublic StringComparator(java.lang.String locale) throws UnsupportedLocaleException
locale
- - the locale to use,
or null to use the generic collation algorithm
UnsupportedLocaleException
- if the specified
locale is not supported by the
if the specified locale is non-null but not valid according
to the MIDP 2.0 specificationMethod Detail |
public int compare(java.lang.String s1, java.lang.String s2) throws java.lang.NullPointerException
s1
- first string to compares2
- second string to compare
java.lang.NullPointerException
- - if either s1 or s2 is nullpublic boolean equals(java.lang.String s1, java.lang.String s2) throws java.lang.NullPointerException
s1
- first string to compares2
- second string to compare
java.lang.NullPointerException
- - if either n2 or s2 is nullpublic int getLevel()
public java.lang.String getLocale()
public static java.lang.String[] getSupportedLocales()
|
BenQ Mobile |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright © 2006 BenQ Mobile GmbH & Co. OHG or respective copyright owner. All Rights Reserved. BenQ Corp. is a trademark licensee of Siemens AG. |
For further information about Mobility Toolkit (MTK) visit our Developer Portal. |