# UnicodeSetSpanner.CountMethod

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

# CountMethod

*** ** * ** ***

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

```
class CountMethod
```

|---|---|--------------------------------------------------------------------------------------------------------------------------------------------------|
| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)                                                                      |||
| ↳ | [kotlin.Enum](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-enum/index.html)\<[android.icu.text.UnicodeSetSpanner.CountMethod](https://developer.android.com/reference/kotlin/android/icu/text/UnicodeSetSpanner.CountMethod#)\> ||
|   | ↳ | [android.icu.text.UnicodeSetSpanner.CountMethod](https://developer.android.com/reference/kotlin/android/icu/text/UnicodeSetSpanner.CountMethod#) |

|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Known Direct Subclasses [UnicodeSetSpanner.CountMethod.MIN_ELEMENTS](https://developer.android.com/reference/kotlin/android/icu/text/UnicodeSetSpanner.CountMethod#ENUM_VALUE:MIN_ELEMENTS),[UnicodeSetSpanner.CountMethod.WHOLE_SPAN](https://developer.android.com/reference/kotlin/android/icu/text/UnicodeSetSpanner.CountMethod#ENUM_VALUE:WHOLE_SPAN) |---------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | [UnicodeSetSpanner.CountMethod.MIN_ELEMENTS](https://developer.android.com/reference/kotlin/android/icu/text/UnicodeSetSpanner.CountMethod#ENUM_VALUE:MIN_ELEMENTS) | Use the smallest number of elements in the spanned range for counting and modification, based on the[UnicodeSet.SpanCondition](https://developer.android.com/reference/kotlin/android/icu/text/UnicodeSet.SpanCondition). | | [UnicodeSetSpanner.CountMethod.WHOLE_SPAN](https://developer.android.com/reference/kotlin/android/icu/text/UnicodeSetSpanner.CountMethod#ENUM_VALUE:WHOLE_SPAN)     | Collapse spans.                                                                                                                                                                                                           | |

Options for replaceFrom and countIn to control how to treat each matched span. It is similar to whether one is replacing \[abc\] by x, or \[abc\]\* by x.

## Summary

|                                                                                                                                                                            Enum values                                                                                                                                                                             ||
|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| [MIN_ELEMENTS](https://developer.android.com/reference/kotlin/android/icu/text/UnicodeSetSpanner.CountMethod#ENUM_VALUE:MIN_ELEMENTS) Use the smallest number of elements in the spanned range for counting and modification, based on the[UnicodeSet.SpanCondition](https://developer.android.com/reference/kotlin/android/icu/text/UnicodeSet.SpanCondition). |
| [WHOLE_SPAN](https://developer.android.com/reference/kotlin/android/icu/text/UnicodeSetSpanner.CountMethod#ENUM_VALUE:WHOLE_SPAN) Collapse spans.                                                                                                                                                                                                               |

## Enum values

### MIN_ELEMENTS

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

```
enum val MIN_ELEMENTS : UnicodeSetSpanner.CountMethod
```

Use the smallest number of elements in the spanned range for counting and modification, based on the[UnicodeSet.SpanCondition](https://developer.android.com/reference/kotlin/android/icu/text/UnicodeSet.SpanCondition). If the set has no strings, this will be the same as the number of spanned code points.

For example, in the string "abab" with SpanCondition.SIMPLE:

- spanning with \[ab\] will count four MIN_ELEMENTS.
- spanning with \[{ab}\] will count two MIN_ELEMENTS.
- spanning with \[ab{ab}\] will also count two MIN_ELEMENTS.  

### WHOLE_SPAN

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

```
enum val WHOLE_SPAN : UnicodeSetSpanner.CountMethod
```

Collapse spans. That is, modify/count the entire matching span as a single item, instead of separate set elements.