# UnicodeFilter

Added in[API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Summary:[Inherited Constants](https://developer.android.com/reference/android/icu/text/UnicodeFilter#inhconstants)\|[Methods](https://developer.android.com/reference/android/icu/text/UnicodeFilter#pubmethods)\|[Inherited Methods](https://developer.android.com/reference/android/icu/text/UnicodeFilter#inhmethods)  

# UnicodeFilter

*** ** * ** ***

[Kotlin](https://developer.android.com/reference/kotlin/android/icu/text/UnicodeFilter "View this page in Kotlin")\|Java

`
public


abstract
class
UnicodeFilter
`  
`

extends `[Object](https://developer.android.com/reference/java/lang/Object)`


``


implements

`[UnicodeMatcher](https://developer.android.com/reference/android/icu/text/UnicodeMatcher)`


`

|---|--------------------------------|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.icu.text.UnicodeFilter |

|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Known direct subclasses [UnicodeSet](https://developer.android.com/reference/android/icu/text/UnicodeSet) |-----------------------------------------------------------------------------------|-----------------------------------------------------------------| | [UnicodeSet](https://developer.android.com/reference/android/icu/text/UnicodeSet) | A mutable set of Unicode characters and multicharacter strings. | |

<br />

*** ** * ** ***

`UnicodeFilter`defines a protocol for selecting a subset of the full range (U+0000 to U+FFFF) of Unicode characters. Currently, filters are used in conjunction with classes like[Transliterator](https://developer.android.com/reference/android/icu/text/Transliterator)to only process selected characters through a transformation.

## Summary

|                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      ### Inherited constants                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| From interface[android.icu.text.UnicodeMatcher](https://developer.android.com/reference/android/icu/text/UnicodeMatcher) |--------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | `char` | [ETHER](https://developer.android.com/reference/android/icu/text/UnicodeMatcher#ETHER) The character at index i, where i \< contextStart \|\| i \>= contextLimit, is ETHER.                             | | `int`  | [U_MATCH](https://developer.android.com/reference/android/icu/text/UnicodeMatcher#U_MATCH) Constant returned by`matches()`indicating a complete match between the text and this matcher.                | | `int`  | [U_MISMATCH](https://developer.android.com/reference/android/icu/text/UnicodeMatcher#U_MISMATCH) Constant returned by`matches()`indicating a mismatch between the text and this matcher.                | | `int`  | [U_PARTIAL_MATCH](https://developer.android.com/reference/android/icu/text/UnicodeMatcher#U_PARTIAL_MATCH) Constant returned by`matches()`indicating a partial match between the text and this matcher. | |

|                                                                                                                                                                                        ### Public methods                                                                                                                                                                                        ||
|---------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` abstract boolean` | ` `[contains](https://developer.android.com/reference/android/icu/text/UnicodeFilter#contains(int))`(int c) ` Returnstruefor characters that are in the selected subset.                                                                                                                                                                                                    |
| ` int`              | ` `[matches](https://developer.android.com/reference/android/icu/text/UnicodeFilter#matches(android.icu.text.Replaceable,%20int[],%20int,%20boolean))`(`[Replaceable](https://developer.android.com/reference/android/icu/text/Replaceable)` text, int[] offset, int limit, boolean incremental) ` Default implementation of UnicodeMatcher::matches() for Unicode filters. |

| ### Inherited methods |
|-----------------------|---|
| From class` `[java.lang.Object](https://developer.android.com/reference/java/lang/Object)` ` |--------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` `[Object](https://developer.android.com/reference/java/lang/Object)          | ` `[clone](https://developer.android.com/reference/java/lang/Object#clone())`() ` Creates and returns a copy of this object.                                                                                                                                                      | | ` boolean`                                                                     | ` `[equals](https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object))`(`[Object](https://developer.android.com/reference/java/lang/Object)` obj) ` Indicates whether some other object is "equal to" this one.                                           | | ` void`                                                                        | ` `[finalize](https://developer.android.com/reference/java/lang/Object#finalize())`() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.                                                          | | ` final `[Class](https://developer.android.com/reference/java/lang/Class)`<?>` | ` `[getClass](https://developer.android.com/reference/java/lang/Object#getClass())`() ` Returns the runtime class of this`Object`.                                                                                                                                                | | ` int`                                                                         | ` `[hashCode](https://developer.android.com/reference/java/lang/Object#hashCode())`() ` Returns a hash code value for the object.                                                                                                                                                 | | ` final void`                                                                  | ` `[notify](https://developer.android.com/reference/java/lang/Object#notify())`() ` Wakes up a single thread that is waiting on this object's monitor.                                                                                                                            | | ` final void`                                                                  | ` `[notifyAll](https://developer.android.com/reference/java/lang/Object#notifyAll())`() ` Wakes up all threads that are waiting on this object's monitor.                                                                                                                         | | ` `[String](https://developer.android.com/reference/java/lang/String)          | ` `[toString](https://developer.android.com/reference/java/lang/Object#toString())`() ` Returns a string representation of the object.                                                                                                                                            | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait(long,%20int))`(long timeoutMillis, int nanos) ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*, or until a certain amount of real time has elapsed. | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait(long))`(long timeoutMillis) ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*, or until a certain amount of real time has elapsed.                   | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait())`() ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*.                                                                                             | ||
| From interface` `[android.icu.text.UnicodeMatcher](https://developer.android.com/reference/android/icu/text/UnicodeMatcher)` ` |--------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` abstract void`                                                               | ` `[addMatchSetTo](https://developer.android.com/reference/android/icu/text/UnicodeMatcher#addMatchSetTo(android.icu.text.UnicodeSet))`(`[UnicodeSet](https://developer.android.com/reference/android/icu/text/UnicodeSet)` toUnionTo) ` Union the set of all characters that may be matched by this object into the given set.                                                                        | | ` abstract int`                                                                | ` `[matches](https://developer.android.com/reference/android/icu/text/UnicodeMatcher#matches(android.icu.text.Replaceable,%20int[],%20int,%20boolean))`(`[Replaceable](https://developer.android.com/reference/android/icu/text/Replaceable)` text, int[] offset, int limit, boolean incremental) ` Return a UMatchDegree value indicating the degree of match for the given text at the given offset. | | ` abstract boolean`                                                            | ` `[matchesIndexValue](https://developer.android.com/reference/android/icu/text/UnicodeMatcher#matchesIndexValue(int))`(int v) ` Returns true if this matcher will match a character c, where c \& 0xFF == v, at offset, in the forward direction (with limit \> offset).                                                                                                                              | | ` abstract `[String](https://developer.android.com/reference/java/lang/String) | ` `[toPattern](https://developer.android.com/reference/android/icu/text/UnicodeMatcher#toPattern(boolean))`(boolean escapeUnprintable) ` Returns a string representation of this matcher.                                                                                                                                                                                                              | ||

## Public methods

### contains

Added in[API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public abstract boolean contains (int c)
```

Returnstruefor characters that are in the selected subset. In other words, if a character is**to be filtered** , thencontains()returns**false**.

<br />

|    Parameters     ||
|-----|--------------|
| `c` | `int` <br /> |

|      Returns      ||
|-----------|--------|
| `boolean` | <br /> |

### matches

Added in[API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public int matches (Replaceable text, 
                int[] offset, 
                int limit, 
                boolean incremental)
```

Default implementation of UnicodeMatcher::matches() for Unicode filters. Matches a single 16-bit code unit at offset.

<br />

|                                                                                                                                                                     Parameters                                                                                                                                                                      ||
|---------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `text`        | `Replaceable`: the text to be matched <br />                                                                                                                                                                                                                                                                                         |
| `offset`      | `int`: on input, the index into text at which to begin matching. On output, the limit of the matched text. The number of matched characters is the output value of offset minus the input value. Offset should always point to the HIGH SURROGATE (leading code unit) of a pair of surrogates, both on entry and upon return. <br /> |
| `limit`       | `int`: the limit index of text to be matched. Greater than offset for a forward direction match, less than offset for a backward direction match. The last character to be considered for matching will be text.charAt(limit-1) in the forward direction or text.charAt(limit+1) in the backward direction. <br />                   |
| `incremental` | `boolean`: if true, then assume further characters may be inserted at limit and check for partial matching. Otherwise assume the text as given is complete. <br />                                                                                                                                                                   |

|                                                                              Returns                                                                               ||
|-------|-------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `int` | a match degree value indicating a full match, a partial match, or a mismatch. If incremental is false then U_PARTIAL_MATCH should never be returned. <br /> |