# Collator

public abstract class **Collator** extends [Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html)  
implements [Comparator](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Comparator.html)\<[Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html)\> [Cloneable](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Cloneable.html) The `Collator` class performs locale-sensitive
`String` comparison. You use this class to build
searching and sorting routines for natural language text.


`Collator` is an abstract base class. Subclasses
implement specific collation strategies. One subclass,
`RuleBasedCollator`, is currently provided with
the Java Platform and is applicable to a wide set of languages. Other
subclasses may be created to handle more specialized needs.


Like other locale-sensitive classes, you can use the static
factory method, `getInstance`, to obtain the appropriate
`Collator` object for a given locale. You will only need
to look at the subclasses of `Collator` if you need
to understand the details of a particular collation strategy or
if you need to modify that strategy.


The following example shows how to compare two strings using
the `Collator` for the default locale.
>
>     // Compare two strings in the default locale
>      Collator myCollator = Collator.getInstance();
>      if( myCollator.compare("abc", "ABC") < 0 )
>          System.out.println("abc is less than ABC");
>      else
>          System.out.println("abc is greater than or equal to ABC");
>      

You can set a `Collator`'s *strength* property
to determine the level of difference considered significant in
comparisons. Four strengths are provided: `PRIMARY`,
`SECONDARY`, `TERTIARY`, and `IDENTICAL`.
The exact assignment of strengths to language features is
locale dependant. For example, in Czech, "e" and "f" are considered
primary differences, while "e" and "ě" are secondary differences,
"e" and "E" are tertiary differences and "e" and "e" are identical.
The following shows how both case and accents could be ignored for
US English.
>
> ```
>  //Get the Collator for US English and set its strength to PRIMARY
>  Collator usCollator = Collator.getInstance(Locale.US);
>  usCollator.setStrength(Collator.PRIMARY);
>  if( usCollator.compare("abc", "ABC") == 0 ) {
>      System.out.println("Strings are equivalent");
>  }
>  
> ```


For comparing `String`s exactly once, the `compare`
method provides the best performance. When sorting a list of
`String`s however, it is generally necessary to compare each
`String` multiple times. In this case, `CollationKey`s
provide better performance. The `CollationKey` class converts
a `String` to a series of bits that can be compared bitwise
against other `CollationKey`s. A `CollationKey` is
created by a `Collator` object for a given `String`.


**Note:** `CollationKey`s from different
`Collator`s can not be compared. See the class description
for `https://developers.google.com/j2objc/javadoc/jre/reference/java/text/CollationKey.html`
for an example using `CollationKey`s.

##### See Also

- `https://developers.google.com/j2objc/javadoc/jre/`
- `https://developers.google.com/j2objc/javadoc/jre/reference/java/text/CollationKey.html`
- `https://developers.google.com/j2objc/javadoc/jre/`
- `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Locale.html`

### Constant Summary

|---|---|---|
| int | [CANONICAL_DECOMPOSITION](https://developers.google.com/j2objc/javadoc/jre/reference/java/text/Collator.html#CANONICAL_DECOMPOSITION) | Constant used to specify the decomposition rule. |
| int | [FULL_DECOMPOSITION](https://developers.google.com/j2objc/javadoc/jre/reference/java/text/Collator.html#FULL_DECOMPOSITION) | Constant used to specify the decomposition rule. |
| int | [IDENTICAL](https://developers.google.com/j2objc/javadoc/jre/reference/java/text/Collator.html#IDENTICAL) | Constant used to specify the collation strength. |
| int | [NO_DECOMPOSITION](https://developers.google.com/j2objc/javadoc/jre/reference/java/text/Collator.html#NO_DECOMPOSITION) | Constant used to specify the decomposition rule. |
| int | [PRIMARY](https://developers.google.com/j2objc/javadoc/jre/reference/java/text/Collator.html#PRIMARY) | Constant used to specify the collation strength. |
| int | [SECONDARY](https://developers.google.com/j2objc/javadoc/jre/reference/java/text/Collator.html#SECONDARY) | Constant used to specify the collation strength. |
| int | [TERTIARY](https://developers.google.com/j2objc/javadoc/jre/reference/java/text/Collator.html#TERTIARY) | Constant used to specify the collation strength. |

### Public Constructor Summary

|---|---|
|   | [Collator](https://developers.google.com/j2objc/javadoc/jre/reference/java/text/Collator.html#Collator())() |

### Public Method Summary

|---|---|
| [Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) | [clone](https://developers.google.com/j2objc/javadoc/jre/reference/java/text/Collator.html#clone())() Creates and returns a copy of this `Object`. |
| int | [compare](https://developers.google.com/j2objc/javadoc/jre/reference/java/text/Collator.html#compare(java.lang.Object,%20java.lang.Object))([Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) object1, [Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) object2) Compares two objects to determine their relative order. |
| abstract int | [compare](https://developers.google.com/j2objc/javadoc/jre/reference/java/text/Collator.html#compare(java.lang.String,%20java.lang.String))([String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) string1, [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) string2) Compares two strings to determine their relative order. |
| boolean | [equals](https://developers.google.com/j2objc/javadoc/jre/reference/java/text/Collator.html#equals(java.lang.String,%20java.lang.String))([String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) string1, [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) string2) Compares two strings using the collation rules to determine if they are equal. |
| static [Locale\[\]](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Locale.html) | [getAvailableLocales](https://developers.google.com/j2objc/javadoc/jre/reference/java/text/Collator.html#getAvailableLocales())() Returns an array of locales for which custom `Collator` instances are available. |
| abstract [CollationKey](https://developers.google.com/j2objc/javadoc/jre/reference/java/text/CollationKey.html) | [getCollationKey](https://developers.google.com/j2objc/javadoc/jre/reference/java/text/Collator.html#getCollationKey(java.lang.String))([String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) string) Returns a `https://developers.google.com/j2objc/javadoc/jre/reference/java/text/CollationKey.html` for the specified string for this collator with the current decomposition rule and strength value. |
| abstract int | [getDecomposition](https://developers.google.com/j2objc/javadoc/jre/reference/java/text/Collator.html#getDecomposition())() Returns the decomposition rule for this collator. |
| static [Collator](https://developers.google.com/j2objc/javadoc/jre/reference/java/text/Collator.html) | [getInstance](https://developers.google.com/j2objc/javadoc/jre/reference/java/text/Collator.html#getInstance())() Returns a `Collator` instance which is appropriate for the user's default `Locale`. |
| static [Collator](https://developers.google.com/j2objc/javadoc/jre/reference/java/text/Collator.html) | [getInstance](https://developers.google.com/j2objc/javadoc/jre/reference/java/text/Collator.html#getInstance(java.util.Locale))([Locale](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Locale.html) locale) Returns a `Collator` instance which is appropriate for `locale`. |
| abstract int | [getStrength](https://developers.google.com/j2objc/javadoc/jre/reference/java/text/Collator.html#getStrength())() Returns the strength value for this collator. |
| abstract void | [setDecomposition](https://developers.google.com/j2objc/javadoc/jre/reference/java/text/Collator.html#setDecomposition(int))(int value) Sets the decomposition rule for this collator. |
| abstract void | [setStrength](https://developers.google.com/j2objc/javadoc/jre/reference/java/text/Collator.html#setStrength(int))(int value) Sets the strength value for this collator. |

### Inherited Method Summary

From class [java.lang.Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html)

|---|---|
| [Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) | [clone](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#clone())() Creates and returns a copy of this `Object`. |
| boolean | [equals](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#equals(java.lang.Object))([Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) obj) Compares this instance with the specified object and indicates if they are equal. |
| void | [finalize](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#finalize())() Invoked when the garbage collector has detected that this instance is no longer reachable. |
| final [Class](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Class.html)\<?\> | [getClass](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#getClass())() Returns the unique instance of `https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Class.html` that represents this object's class. |
| int | [hashCode](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#hashCode())() Returns an integer hash code for this object. |
| final void | [notify](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#notify())() Causes a thread which is waiting on this object's monitor (by means of calling one of the `wait()` methods) to be woken up. |
| final void | [notifyAll](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#notifyAll())() Causes all threads which are waiting on this object's monitor (by means of calling one of the `wait()` methods) to be woken up. |
| [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) | [toString](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#toString())() Returns a string containing a concise, human-readable description of this object. |
| final void | [wait](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#wait(long,%20int))(long timeout, int nanos) Causes the calling thread to wait until another thread calls the `notify()` or `notifyAll()` method of this object or until the specified timeout expires. |
| final void | [wait](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#wait(long))(long timeout) Causes the calling thread to wait until another thread calls the `notify()` or `notifyAll()` method of this object or until the specified timeout expires. |
| final void | [wait](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#wait())() Causes the calling thread to wait until another thread calls the `notify()` or `notifyAll()` method of this object. |

From interface [java.util.Comparator](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Comparator.html)

|---|---|
| abstract int | [compare](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Comparator.html#compare(T,%20T))([Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) o1, [Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) o2) Compares its two arguments for order. |
| static \<T, U\> [Comparator](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Comparator.html)\<[Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html)\> | [comparing](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Comparator.html#comparing(java.util.function.Function<?%20super%20T,%20?%20extends%20U>,%20java.util.Comparator<?%20super%20U>))([Function](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/function/Function.html)\<? super T, ? extends U\> keyExtractor, [Comparator](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Comparator.html)\<? super U\> keyComparator) Accepts a function that extracts a sort key from a type `T`, and returns a `Comparator<T>` that compares by that sort key using the specified `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Comparator.html`. |
| static \<T, U extends [Comparable](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Comparable.html)\<? super U\>\> [Comparator](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Comparator.html)\<[Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html)\> | [comparing](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Comparator.html#comparing(java.util.function.Function<?%20super%20T,%20?%20extends%20U>))([Function](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/function/Function.html)\<? super T, ? extends U\> keyExtractor) Accepts a function that extracts a `https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Comparable.html` sort key from a type `T`, and returns a `Comparator<T>` that compares by that sort key. |
| static \<T\> [Comparator](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Comparator.html)\<[Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html)\> | [comparingDouble](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Comparator.html#comparingDouble(java.util.function.ToDoubleFunction<?%20super%20T>))([ToDoubleFunction](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/function/ToDoubleFunction.html)\<? super T\> keyExtractor) Accepts a function that extracts a `double` sort key from a type `T`, and returns a `Comparator<T>` that compares by that sort key. |
| static \<T\> [Comparator](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Comparator.html)\<[Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html)\> | [comparingInt](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Comparator.html#comparingInt(java.util.function.ToIntFunction<?%20super%20T>))([ToIntFunction](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/function/ToIntFunction.html)\<? super T\> keyExtractor) Accepts a function that extracts an `int` sort key from a type `T`, and returns a `Comparator<T>` that compares by that sort key. |
| static \<T\> [Comparator](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Comparator.html)\<[Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html)\> | [comparingLong](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Comparator.html#comparingLong(java.util.function.ToLongFunction<?%20super%20T>))([ToLongFunction](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/function/ToLongFunction.html)\<? super T\> keyExtractor) Accepts a function that extracts a `long` sort key from a type `T`, and returns a `Comparator<T>` that compares by that sort key. |
| abstract boolean | [equals](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Comparator.html#equals(java.lang.Object))([Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) obj) Indicates whether some other object is "equal to" this comparator. |
| static \<T extends [Comparable](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Comparable.html)\<? super T\>\> [Comparator](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Comparator.html)\<T\> | [naturalOrder](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Comparator.html#naturalOrder())() Returns a comparator that compares `https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Comparable.html` objects in natural order. |
| static \<T\> [Comparator](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Comparator.html)\<[Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html)\> | [nullsFirst](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Comparator.html#nullsFirst(java.util.Comparator<?%20super%20T>))([Comparator](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Comparator.html)\<? super T\> comparator) Returns a null-friendly comparator that considers `null` to be less than non-null. |
| static \<T\> [Comparator](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Comparator.html)\<[Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html)\> | [nullsLast](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Comparator.html#nullsLast(java.util.Comparator<?%20super%20T>))([Comparator](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Comparator.html)\<? super T\> comparator) Returns a null-friendly comparator that considers `null` to be greater than non-null. |
| static \<T extends [Comparable](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Comparable.html)\<? super T\>\> [Comparator](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Comparator.html)\<T\> | [reverseOrder](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Comparator.html#reverseOrder())() Returns a comparator that imposes the reverse of the *natural ordering*. |
| [Comparator](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Comparator.html)\<[Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html)\> | [reversed](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Comparator.html#reversed())() Returns a comparator that imposes the reverse ordering of this comparator. |
| \<U extends [Comparable](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Comparable.html)\<? super U\>\> [Comparator](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Comparator.html)\<[Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html)\> | [thenComparing](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Comparator.html#thenComparing(java.util.function.Function<?%20super%20T,%20?%20extends%20U>))([Function](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/function/Function.html)\<? super T, ? extends U\> keyExtractor) Returns a lexicographic-order comparator with a function that extracts a `Comparable` sort key. |
| \<U\> [Comparator](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Comparator.html)\<[Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html)\> | [thenComparing](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Comparator.html#thenComparing(java.util.function.Function<?%20super%20T,%20?%20extends%20U>,%20java.util.Comparator<?%20super%20U>))([Function](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/function/Function.html)\<? super T, ? extends U\> keyExtractor, [Comparator](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Comparator.html)\<? super U\> keyComparator) Returns a lexicographic-order comparator with a function that extracts a key to be compared with the given `Comparator`. |
| [Comparator](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Comparator.html)\<[Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html)\> | [thenComparing](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Comparator.html#thenComparing(java.util.Comparator<?%20super%20T>))([Comparator](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Comparator.html)\<? super T\> other) Returns a lexicographic-order comparator with another comparator. |
| [Comparator](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Comparator.html)\<[Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html)\> | [thenComparingDouble](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Comparator.html#thenComparingDouble(java.util.function.ToDoubleFunction<?%20super%20T>))([ToDoubleFunction](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/function/ToDoubleFunction.html)\<? super T\> keyExtractor) Returns a lexicographic-order comparator with a function that extracts a `double` sort key. |
| [Comparator](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Comparator.html)\<[Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html)\> | [thenComparingInt](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Comparator.html#thenComparingInt(java.util.function.ToIntFunction<?%20super%20T>))([ToIntFunction](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/function/ToIntFunction.html)\<? super T\> keyExtractor) Returns a lexicographic-order comparator with a function that extracts a `int` sort key. |
| [Comparator](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Comparator.html)\<[Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html)\> | [thenComparingLong](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Comparator.html#thenComparingLong(java.util.function.ToLongFunction<?%20super%20T>))([ToLongFunction](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/function/ToLongFunction.html)\<? super T\> keyExtractor) Returns a lexicographic-order comparator with a function that extracts a `long` sort key. |

## Constants

#### public static final int
**CANONICAL_DECOMPOSITION**

Constant used to specify the decomposition rule.
Constant Value: 1

#### public static final int
**FULL_DECOMPOSITION**

Constant used to specify the decomposition rule. This value for
decomposition is not supported.
Constant Value: 2

#### public static final int
**IDENTICAL**

Constant used to specify the collation strength.
Constant Value: 3

#### public static final int
**NO_DECOMPOSITION**

Constant used to specify the decomposition rule.
Constant Value: 0

#### public static final int
**PRIMARY**

Constant used to specify the collation strength.
Constant Value: 0

#### public static final int
**SECONDARY**

Constant used to specify the collation strength.
Constant Value: 1

#### public static final int
**TERTIARY**

Constant used to specify the collation strength.
Constant Value: 2

## Public Constructors

#### public
**Collator**
()

<br />

## Public Methods

#### public [Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html)
**clone**
()

Creates and returns a copy of this `Object`. The default
implementation returns a so-called "shallow" copy: It creates a new
instance of the same class and then copies the field values (including
object references) from this instance to the new instance. A "deep" copy,
in contrast, would also recursively clone nested objects. A subclass that
needs to implement this kind of cloning should call `super.clone()`
to create the new instance and then create deep copies of the nested,
mutable objects.

##### Returns

- a copy of this object.

#### public int
**compare**
([Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) object1, [Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) object2)

Compares two objects to determine their relative order. The objects must
be strings.

##### Parameters

| object1 | the first string to compare. |
| object2 | the second string to compare. |
|---|---|

##### Returns

- a negative value if `object1` is less than `object2`, 0 if they are equal, and a positive value if `object1` is greater than `object2`.

##### Throws

| [ClassCastException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/ClassCastException.html) | if `object1` or `object2` is not a `String`. |
|---|---|

#### public abstract int
**compare**
([String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) string1, [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) string2)

Compares two strings to determine their relative order.

##### Parameters

| string1 | the first string to compare. |
| string2 | the second string to compare. |
|---|---|

##### Returns

- a negative value if `string1` is less than `string2`, 0 if they are equal and a positive value if `string1` is greater than `string2`.

#### public boolean
**equals**
([String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) string1, [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) string2)

Compares two strings using the collation rules to determine if they are
equal.

##### Parameters

| string1 | the first string to compare. |
| string2 | the second string to compare. |
|---|---|

##### Returns

- `true` if `string1` and `string2` are equal using the collation rules, false otherwise.

#### public static [Locale\[\]](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Locale.html)
**getAvailableLocales**
()

Returns an array of locales for which custom `Collator` instances
are available.

Note that Android does not support user-supplied locale service providers.

#### public abstract [CollationKey](https://developers.google.com/j2objc/javadoc/jre/reference/java/text/CollationKey.html)
**getCollationKey**
([String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) string)

Returns a `https://developers.google.com/j2objc/javadoc/jre/reference/java/text/CollationKey.html` for the specified string for this collator
with the current decomposition rule and strength value.

##### Parameters

| string | the source string that is converted into a collation key. |
|---|---|

##### Returns

- the collation key for `string`.

#### public abstract int
**getDecomposition**
()

Returns the decomposition rule for this collator.

##### Returns

- the decomposition rule, either `NO_DECOMPOSITION` or `CANONICAL_DECOMPOSITION`. `FULL_DECOMPOSITION` is not supported.

#### public static [Collator](https://developers.google.com/j2objc/javadoc/jre/reference/java/text/Collator.html)
**getInstance**
()

Returns a `Collator` instance which is appropriate for the user's default
`Locale`.
See "[Be wary of the default locale](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Locale.html#default_locale)".

#### public static [Collator](https://developers.google.com/j2objc/javadoc/jre/reference/java/text/Collator.html)
**getInstance**
([Locale](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Locale.html) locale)

Returns a `Collator` instance which is appropriate for `locale`.

##### Parameters

| locale |   |
|---|---|

#### public abstract int
**getStrength**
()

Returns the strength value for this collator.

##### Returns

- the strength value, either PRIMARY, SECONDARY, TERTIARY or IDENTICAL.

#### public abstract void
**setDecomposition**
(int value)

Sets the decomposition rule for this collator.

##### Parameters

| value | the decomposition rule, either `NO_DECOMPOSITION` or `CANONICAL_DECOMPOSITION`. `FULL_DECOMPOSITION` is not supported. |
|---|---|

##### Throws

| [IllegalArgumentException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/IllegalArgumentException.html) | if the provided decomposition rule is not valid. This includes `FULL_DECOMPOSITION`. |
|---|---|

#### public abstract void
**setStrength**
(int value)

Sets the strength value for this collator.

##### Parameters

| value | the strength value, either PRIMARY, SECONDARY, TERTIARY, or IDENTICAL. |
|---|---|

##### Throws

| [IllegalArgumentException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/IllegalArgumentException.html) | if the provided strength value is not valid. |
|---|---|