Oracle® Globalization Development Kit Java API Reference
10g Release 1(10.1)

B10971-01

oracle.i18n.text
Class OraCollator

java.lang.Object
  |
  +--oracle.i18n.text.OraCollator
All Implemented Interfaces:
Cloneable, Comparator

public class OraCollator
extends Object
implements Cloneable, Comparator

OraCollator class performs locale-sensitive String comparisons, including linguistic collation and binary sorting.

Since:
Oracle 10.1.0.2

Field Summary
static int CANONICAL_COMPOSITION
          OraCollator composition level value.
static int EQUAL
          The result of comparison that OraCollator returns if the two Strings are equal.
static int GREATER
          The result of comparison that OraCollator returns if the first String is greater than the second String.
static int LESS
          The result of comparison that OraCollator returns if the first String is less than the second String.
static int NO_COMPOSITION
          OraCollator composition level value.
static int PRIMARY
          OraCollator strength value.
static int SECONDARY
          OraCollator strength value.
static int TERTIARY
          OraCollator strength value.

 

Constructor Summary
protected OraCollator()
          The constructor is here only for completeness.

 

Method Summary
 Object clone()
          Make an independent duplicate of the OraCollator object.
 int compare(Object source, Object target)
          Compare two Objects using the current collation rule.
 int compare(String source, String target)
          Compare two Strings using the current collation rule.
 boolean equals(Object obj)
          Returns true if this OraCollator object equals to another
 String getCharSet()
          Get the charSet name of this OraCollator
 oracle.i18n.text.OraCollationKey getCollationKey(String source)
          Get OraCollationKey for a given source String.
 int getComposition()
          Get the composition level used for comparison, and make a getColaltionKey call or Compare call.
static oracle.i18n.text.OraCollator getInstance()
          Constructs an Oracle collation object from the default locale, converts default locale to OraLocaleInfo using the default sorting rule.
static oracle.i18n.text.OraCollator getInstance(Locale locale)
          Constructs an Oracle collation object from Java's locale.
static oracle.i18n.text.OraCollator getInstance(Locale locale, String sortRule, String charSet)
          Constructs an OraCollator instance from the specified sortRule and locale.
static oracle.i18n.text.OraCollator getInstance(oracle.i18n.util.OraLocaleInfo oraLocale)
          Constructs an Oracle collation object from an OraLocaleInfo, retrieves the default collator from the OraLocaleInfo object
static oracle.i18n.text.OraCollator getInstance(String sortRule)
          Constructs an OraCollator instance from the specified sortRule.
static oracle.i18n.text.OraCollator getInstance(String sortRule, String charSet)
          Constructs an OraCollator instance from the specified sortRule.
 String getName()
          Get the sorting rule name of this OraCollator
 int getStrength()
          Get the strength is used in comparisons, and make a getColaltionKey call or Compare call.
 int hashCode()
          Create a hashCode for this OraCollator based on sort rule, strength, decomposition level
 void setComposition(int compositionMode)
          Set the composition level used for comparison, and make a getColaltionKey call or Compare call.
 void setStrength(int newStrength)
          Set the strength is used in comparisons, and make a getColaltionKey call or Compare call.

 

Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, toString, wait, wait, wait

 

Field Detail

PRIMARY

public static final int PRIMARY
OraCollator strength value. When set, only PRIMARY differences are considered significant during comparison. The assignment of strengths to language features is locale dependant. A common example is for different base letters ("a" vs. "b") to be considered a PRIMARY difference. For monolingual and binary sort, PRIMARY set means accent insensitive.
See Also:
setStrength(int), getStrength(), Constant Field Values

SECONDARY

public static final int SECONDARY
OraCollator strength value. When set, only SECONDARY and higher-order differences are considered significant during comparison. The assignment of strengths to language features is locale dependant. A common example is for different accented forms of the same base letter ("a" vs. "â") to be considered a SECONDARY difference. For monolingual and binary sort, SECONDARY set means case insensitive .
See Also:
setStrength(int), getStrength(), Constant Field Values

TERTIARY

public static final int TERTIARY
OraCollator strength value. When set, only TERTIARY and higher-order differences are considered significant during comparison. The assignment of strengths to language features is locale dependant. A common example is for case differences ("a" vs. "A") to be considered a TERTIARY difference.
See Also:
setStrength(int), getStrength(), Constant Field Values

NO_COMPOSITION

public static final int NO_COMPOSITION
OraCollator composition level value. When NO_COMPOSITION is set, canonical equivalence is not considered.
See Also:
setComposition(int), getComposition(), Constant Field Values

CANONICAL_COMPOSITION

public static final int CANONICAL_COMPOSITION
OraCollator composition level value. When CANONICAL_COMPOSITION is set, canonical equivalence is considered as same.
See Also:
setComposition(int), getComposition(), Constant Field Values

EQUAL

public static final int EQUAL
The result of comparison that OraCollator returns if the two Strings are equal.
See Also:
Constant Field Values

LESS

public static final int LESS
The result of comparison that OraCollator returns if the first String is less than the second String.
See Also:
Constant Field Values

GREATER

public static final int GREATER
The result of comparison that OraCollator returns if the first String is greater than the second String.
See Also:
Constant Field Values
Constructor Detail

OraCollator

protected OraCollator()
The constructor is here only for completeness. The getInstance method should be used instead to create new OraCollator objects.
Method Detail

getInstance

public static oracle.i18n.text.OraCollator getInstance()
Constructs an Oracle collation object from the default locale, converts default locale to OraLocaleInfo using the default sorting rule.
Returns:
OraCollator instance

getInstance

public static oracle.i18n.text.OraCollator getInstance(Locale locale)
Constructs an Oracle collation object from Java's locale. It converts Java locale to Oracle locale and uses this to get the OraCollator.
Parameters:
locale - java Locale object
Returns:
OraCollator instance

getInstance

public static oracle.i18n.text.OraCollator getInstance(oracle.i18n.util.OraLocaleInfo oraLocale)
Constructs an Oracle collation object from an OraLocaleInfo, retrieves the default collator from the OraLocaleInfo object
Parameters:
oraLocale - OraLocaleInfo object
Returns:
OraCollator instance

getInstance

public static oracle.i18n.text.OraCollator getInstance(String sortRule)
Constructs an OraCollator instance from the specified sortRule. The sortRule is the same as NLSRTL's NLS_SORT names; e.g., xgerman, GENERIC_M, unicode_binary, binary, etc. ai or ci can be attached to sort rules to specify the comparison level.
Parameters:
sortRule - oracle sort rule name
Returns:
OraCollator instance

getInstance

public static oracle.i18n.text.OraCollator getInstance(String sortRule,
String charSet)
Constructs an OraCollator instance from the specified sortRule. This method will take both Oracle sorting rule and "binary" as sortRule. If using Oracle sorting rule, the charSet values will be ignored. If using binary sorting rule, charSet could be specified by the charSet on the database server. Strings from ai or ci can be attached to "binary" for specifying the comparison level.
Parameters:
sortRule - Oracle sort rule name
charSet - Oracle database character set, could be NULL. Default: UTF16
Returns:
OraCollator instance

getInstance

public static oracle.i18n.text.OraCollator getInstance(Locale locale,
String sortRule,
String charSet)
Constructs an OraCollator instance from the specified sortRule and locale. This method will take both Oracle sorting rule and "binary" as sortRule. If using Oracle sorting rule, the charSet values will be ignored. If using binary sorting rule, charSet could be specified by the charSet on the database server. Strings from ai or ci can be attached to "binary" for specifying the comparison level; it will also record the locale information in the instance.
Parameters:
locale - java Locale object
sortRule - Oracle sort rule name
charSet - Oracle database character set, could be NULL. Default: UTF16
Returns:
OraCollator instance

getName

public String getName()
Get the sorting rule name of this OraCollator
Returns:
sorting rule name

getCharSet

public String getCharSet()
Get the charSet name of this OraCollator
Returns:
database character set

setStrength

public void setStrength(int newStrength)
Set the strength is used in comparisons, and make a getColaltionKey call or Compare call. Strength could have the values of PRIMARY, SECONDARY or TERTIARY.
Parameters:
newStrength - the new strength to be set; PRIMARY, SECONDARY or TERTIARY
See Also:
PRIMARY, SECONDARY, TERTIARY

getStrength

public int getStrength()
Get the strength is used in comparisons, and make a getColaltionKey call or Compare call. Strength could have the values of PRIMARY, SECONDARY or TERTIARY.
Returns:
the current set strength; PRIMARY, SECONDARY or TERTIARY
See Also:
PRIMARY, SECONDARY, TERTIARY

setComposition

public void setComposition(int compositionMode)
Set the composition level used for comparison, and make a getColaltionKey call or Compare call. Composition level could be CANONICAL_COMPOSITION or NO_COMPOSITION.
See Also:
NO_COMPOSITION, CANONICAL_COMPOSITION

getComposition

public int getComposition()
Get the composition level used for comparison, and make a getColaltionKey call or Compare call. Composition level could be CANONICAL_COMPOSITION or NO_COMPOSITION.
Returns:
the current set compostion level; CANONICAL_COMPOSITION or NO_COMPOSITION
See Also:
NO_COMPOSITION, CANONICAL_COMPOSITION

clone

public Object clone()
Make an independent duplicate of the OraCollator object.
Overrides:
clone in class Object
Returns:
OraCollator object

hashCode

public int hashCode()
Create a hashCode for this OraCollator based on sort rule, strength, decomposition level
Overrides:
hashCode in class Object
Returns:
a hashCode

equals

public boolean equals(Object obj)
Returns true if this OraCollator object equals to another
Specified by:
equals in interface Comparator
Overrides:
equals in class Object
Parameters:
obj - a target object to be compared with
Returns:
TRUE if equal or FALSE if not.

compare

public int compare(Object source,
Object target)
Compare two Objects using the current collation rule. The comparison result will depend on the sorting rule and the setting of comparison level.

This implementation merely returns compare((String)o1, (String)o2).

Specified by:
compare in interface Comparator
Parameters:
source - first Object to be compared
target - second Object to be compared
Returns:
OraCollator.GREATER, OraCollator.EQUAL, OraCollator.LESS
Throws:
ClassCastException - if arguments cannot be cast to Strings.

compare

public int compare(String source,
String target)
Compare two Strings using the current collation rule. The comparison result will depend on the sorting rule and the setting of comparison level.
Parameters:
source - first String to be compared
target - second String to be compared
Returns:
OraCollator.GREATER, OraCollator.EQUAL, OraCollator.LESS

getCollationKey

public oracle.i18n.text.OraCollationKey getCollationKey(String source)
Get OraCollationKey for a given source String.
Parameters:
source - source String to get oracle collation key
Returns:
OraCollationKey object

Oracle® Globalization Development Kit Java API Reference
10g Release 1(10.1)

B10971-01

Copyright © 2003 Oracle Corporation. All Rights Reserved.