# TextBoundsInfo.Builder

Added in[API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Summary:[Ctors](https://developer.android.com/reference/android/view/inputmethod/TextBoundsInfo.Builder#pubctors)\|[Methods](https://developer.android.com/reference/android/view/inputmethod/TextBoundsInfo.Builder#pubmethods)\|[Inherited Methods](https://developer.android.com/reference/android/view/inputmethod/TextBoundsInfo.Builder#inhmethods)  

# TextBoundsInfo.Builder

*** ** * ** ***

[Kotlin](https://developer.android.com/reference/kotlin/android/view/inputmethod/TextBoundsInfo.Builder "View this page in Kotlin")\|Java

`
public
static
final

class
TextBoundsInfo.Builder
`  
`

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


``


`

|---|-------------------------------------------------|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.view.inputmethod.TextBoundsInfo.Builder |

<br />

*** ** * ** ***

The builder class to create a[TextBoundsInfo](https://developer.android.com/reference/android/view/inputmethod/TextBoundsInfo)object.

## Summary

|                                                                                                                          ### Public constructors                                                                                                                           ||
|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| ` `[Builder](https://developer.android.com/reference/android/view/inputmethod/TextBoundsInfo.Builder#Builder(int,%20int))`(int start, int end) ` Create a builder for[TextBoundsInfo](https://developer.android.com/reference/android/view/inputmethod/TextBoundsInfo). |

|                                                                                                                                                                                                                                                                    ### Public methods                                                                                                                                                                                                                                                                     ||
|----------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` `[TextBoundsInfo](https://developer.android.com/reference/android/view/inputmethod/TextBoundsInfo)                 | ` `[build](https://developer.android.com/reference/android/view/inputmethod/TextBoundsInfo.Builder#build())`() ` Create the[TextBoundsInfo](https://developer.android.com/reference/android/view/inputmethod/TextBoundsInfo)using the parameters in this[Builder](https://developer.android.com/reference/android/view/inputmethod/TextBoundsInfo.Builder).                                                                         |
| ` `[TextBoundsInfo.Builder](https://developer.android.com/reference/android/view/inputmethod/TextBoundsInfo.Builder) | ` `[clear](https://developer.android.com/reference/android/view/inputmethod/TextBoundsInfo.Builder#clear())`() ` Clear all the parameters set on this[Builder](https://developer.android.com/reference/android/view/inputmethod/TextBoundsInfo.Builder)to reuse it.                                                                                                                                                                 |
| ` `[TextBoundsInfo.Builder](https://developer.android.com/reference/android/view/inputmethod/TextBoundsInfo.Builder) | ` `[setCharacterBidiLevel](https://developer.android.com/reference/android/view/inputmethod/TextBoundsInfo.Builder#setCharacterBidiLevel(int[]))`(int[] characterBidiLevels) ` Set the BiDi levels for the character.                                                                                                                                                                                                               |
| ` `[TextBoundsInfo.Builder](https://developer.android.com/reference/android/view/inputmethod/TextBoundsInfo.Builder) | ` `[setCharacterBounds](https://developer.android.com/reference/android/view/inputmethod/TextBoundsInfo.Builder#setCharacterBounds(float[]))`(float[] characterBounds) ` Set the characters bounds, in the coordinates of the editor.                                                                                                                                                                                               |
| ` `[TextBoundsInfo.Builder](https://developer.android.com/reference/android/view/inputmethod/TextBoundsInfo.Builder) | ` `[setCharacterFlags](https://developer.android.com/reference/android/view/inputmethod/TextBoundsInfo.Builder#setCharacterFlags(int[]))`(int[] characterFlags) ` Set the flags of the characters.                                                                                                                                                                                                                                  |
| ` `[TextBoundsInfo.Builder](https://developer.android.com/reference/android/view/inputmethod/TextBoundsInfo.Builder) | ` `[setGraphemeSegmentFinder](https://developer.android.com/reference/android/view/inputmethod/TextBoundsInfo.Builder#setGraphemeSegmentFinder(android.text.SegmentFinder))`(`[SegmentFinder](https://developer.android.com/reference/android/text/SegmentFinder)` graphemeSegmentFinder) ` Set the[SegmentFinder](https://developer.android.com/reference/android/text/SegmentFinder)that locates the grapheme cluster boundaries. |
| ` `[TextBoundsInfo.Builder](https://developer.android.com/reference/android/view/inputmethod/TextBoundsInfo.Builder) | ` `[setLineSegmentFinder](https://developer.android.com/reference/android/view/inputmethod/TextBoundsInfo.Builder#setLineSegmentFinder(android.text.SegmentFinder))`(`[SegmentFinder](https://developer.android.com/reference/android/text/SegmentFinder)` lineSegmentFinder) ` Set the[SegmentFinder](https://developer.android.com/reference/android/text/SegmentFinder)that locates the line boundaries.                         |
| ` `[TextBoundsInfo.Builder](https://developer.android.com/reference/android/view/inputmethod/TextBoundsInfo.Builder) | ` `[setMatrix](https://developer.android.com/reference/android/view/inputmethod/TextBoundsInfo.Builder#setMatrix(android.graphics.Matrix))`(`[Matrix](https://developer.android.com/reference/android/graphics/Matrix)` matrix) ` Sets the matrix that transforms local coordinates into screen coordinates.                                                                                                                        |
| ` `[TextBoundsInfo.Builder](https://developer.android.com/reference/android/view/inputmethod/TextBoundsInfo.Builder) | ` `[setStartAndEnd](https://developer.android.com/reference/android/view/inputmethod/TextBoundsInfo.Builder#setStartAndEnd(int,%20int))`(int start, int end) ` Set the start and end index of the[TextBoundsInfo](https://developer.android.com/reference/android/view/inputmethod/TextBoundsInfo).                                                                                                                                 |
| ` `[TextBoundsInfo.Builder](https://developer.android.com/reference/android/view/inputmethod/TextBoundsInfo.Builder) | ` `[setWordSegmentFinder](https://developer.android.com/reference/android/view/inputmethod/TextBoundsInfo.Builder#setWordSegmentFinder(android.text.SegmentFinder))`(`[SegmentFinder](https://developer.android.com/reference/android/text/SegmentFinder)` wordSegmentFinder) ` Set the[SegmentFinder](https://developer.android.com/reference/android/text/SegmentFinder)that locates the word boundaries.                         |

| ### 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*.                                                                                             | ||

## Public constructors

### Builder

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

```
public Builder (int start, 
                int end)
```

Create a builder for[TextBoundsInfo](https://developer.android.com/reference/android/view/inputmethod/TextBoundsInfo).

<br />

|                                                                         Parameters                                                                         ||
|---------|---------------------------------------------------------------------------------------------------------------------------------------------------|
| `start` | `int`: the start index of the[TextBoundsInfo](https://developer.android.com/reference/android/view/inputmethod/TextBoundsInfo), inclusive. <br /> |
| `end`   | `int`: the end index of the[TextBoundsInfo](https://developer.android.com/reference/android/view/inputmethod/TextBoundsInfo), exclusive. <br />   |

|                                                                                      Throws                                                                                       ||
|--------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------|
| [IllegalArgumentException](https://developer.android.com/reference/java/lang/IllegalArgumentException) | if the given`start`or`end`is negative, or`end`is smaller than the`start`. |

## Public methods

### build

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

```
public TextBoundsInfo build ()
```

Create the[TextBoundsInfo](https://developer.android.com/reference/android/view/inputmethod/TextBoundsInfo)using the parameters in this[Builder](https://developer.android.com/reference/android/view/inputmethod/TextBoundsInfo.Builder).

<br />

|                                                                Returns                                                                ||
|---------------------------------------------------------------------------------------------------|------------------------------------|
| [TextBoundsInfo](https://developer.android.com/reference/android/view/inputmethod/TextBoundsInfo) | This value cannot be`null`. <br /> |

|                                                                                                                                                                                                                                                                                                                     Throws                                                                                                                                                                                                                                                                                                                     ||
|--------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [IllegalStateException](https://developer.android.com/reference/java/lang/IllegalStateException) | in the following conditions: - if the`start`or`end`is not set. - if the`matrix`is not set. - if`characterBounds`is not set or its length doesn't equal to 4 \* (`end`-`start`). - if the`characterFlags`is not set or its length doesn't equal to (`end`-`start`). - if`graphemeSegmentFinder`,`wordSegmentFinder`or`lineSegmentFinder`is not set. - if characters in the same line has inconsistent[TextBoundsInfo.FLAG_LINE_IS_RTL](https://developer.android.com/reference/android/view/inputmethod/TextBoundsInfo#FLAG_LINE_IS_RTL)flag. |

### clear

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

```
public TextBoundsInfo.Builder clear ()
```

Clear all the parameters set on this[Builder](https://developer.android.com/reference/android/view/inputmethod/TextBoundsInfo.Builder)to reuse it.

<br />

|                                                                        Returns                                                                        ||
|-------------------------------------------------------------------------------------------------------------------|------------------------------------|
| [TextBoundsInfo.Builder](https://developer.android.com/reference/android/view/inputmethod/TextBoundsInfo.Builder) | This value cannot be`null`. <br /> |

### setCharacterBidiLevel

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

```
public TextBoundsInfo.Builder setCharacterBidiLevel (int[] characterBidiLevels)
```

Set the BiDi levels for the character. The bidiLevel of the i-th character in the editor is stored at index (i - start). The length of the given array must equal to (end - start).  
BiDi level is defined by[the unicode bidirectional algorithm](https://unicode.org/reports/tr9/#Basic_Display_Algorithm). One can determine whether a character's direction is right-to-left (RTL) or left-to-right (LTR) by checking the last bit of the BiDi level. If it's 1, the character is RTL, otherwise the character is LTR. The BiDi level of a character must be in the range of \[0, 125\].

<br />

|                                                Parameters                                                 ||
|-----------------------|------------------------------------------------------------------------------------|
| `characterBidiLevels` | `int`: the array of the character's BiDi level. This value cannot be`null`. <br /> |

|                                                                        Returns                                                                        ||
|-------------------------------------------------------------------------------------------------------------------|------------------------------------|
| [TextBoundsInfo.Builder](https://developer.android.com/reference/android/view/inputmethod/TextBoundsInfo.Builder) | This value cannot be`null`. <br /> |

|                                                                                              Throws                                                                                              ||
|--------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------|
| [NullPointerException](https://developer.android.com/reference/java/lang/NullPointerException)         | if the given`characterBidiLevels`is`null`.                                               |
| [IllegalArgumentException](https://developer.android.com/reference/java/lang/IllegalArgumentException) | if the given`characterBidiLevels`contains an element that's out of the range \[0, 125\]. |

**See also:**

- [TextBoundsInfo.getCharacterBidiLevel(int)](https://developer.android.com/reference/android/view/inputmethod/TextBoundsInfo#getCharacterBidiLevel(int))  

### setCharacterBounds

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

```
public TextBoundsInfo.Builder setCharacterBounds (float[] characterBounds)
```

Set the characters bounds, in the coordinates of the editor.  
The given array should be divided into groups of four where each element represents left, top, right and bottom of the character bounds respectively. The bounds of the i-th character in the editor should be stored at index 4 \* (i - start). The length of the given array must equal to 4 \* (end - start).  
Sometimes multiple characters in a single grapheme are rendered as one symbol on the screen. So those characters only have one shared bounds. In this case, we recommend the editor to assign all the width to the bounds of the first character in the grapheme, and make the rest characters' bounds zero-width.  
For example, the string "'0xD83D' '0xDE00'" is rendered as one grapheme - a grinning face emoji. If the bounds of the grapheme is: Rect(5, 10, 15, 20), the character bounds of the string should be: \[ Rect(5, 10, 15, 20), Rect(15, 10, 15, 20) \].

<br />

|                                                 Parameters                                                  ||
|-------------------|------------------------------------------------------------------------------------------|
| `characterBounds` | `float`: the array of the flattened character bounds. This value cannot be`null`. <br /> |

|                                                                        Returns                                                                        ||
|-------------------------------------------------------------------------------------------------------------------|------------------------------------|
| [TextBoundsInfo.Builder](https://developer.android.com/reference/android/view/inputmethod/TextBoundsInfo.Builder) | This value cannot be`null`. <br /> |

|                                                                 Throws                                                                 ||
|------------------------------------------------------------------------------------------------|----------------------------------------|
| [NullPointerException](https://developer.android.com/reference/java/lang/NullPointerException) | if the given`characterBounds`is`null`. |

### setCharacterFlags

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

```
public TextBoundsInfo.Builder setCharacterFlags (int[] characterFlags)
```

Set the flags of the characters. The flags of the i-th character in the editor is stored at index (i - start). The length of the given array must equal to (end - start). The flags contain the following information:

- The[TextBoundsInfo.FLAG_CHARACTER_WHITESPACE](https://developer.android.com/reference/android/view/inputmethod/TextBoundsInfo#FLAG_CHARACTER_WHITESPACE)flag, indicating the character is a whitespace.
- The[TextBoundsInfo.FLAG_CHARACTER_LINEFEED](https://developer.android.com/reference/android/view/inputmethod/TextBoundsInfo#FLAG_CHARACTER_LINEFEED)flag, indicating the character is a linefeed.
- The[TextBoundsInfo.FLAG_CHARACTER_PUNCTUATION](https://developer.android.com/reference/android/view/inputmethod/TextBoundsInfo#FLAG_CHARACTER_PUNCTUATION)flag, indicating the character is a punctuation.
- The[TextBoundsInfo.FLAG_LINE_IS_RTL](https://developer.android.com/reference/android/view/inputmethod/TextBoundsInfo#FLAG_LINE_IS_RTL)flag, indicating the line this character belongs to is RTL. All all character in the same line must have the same line direction. Check[TextBoundsInfo.getLineSegmentFinder()](https://developer.android.com/reference/android/view/inputmethod/TextBoundsInfo#getLineSegmentFinder())for more information of line boundaries.

<br />

<br />

|                                           Parameters                                            ||
|------------------|-------------------------------------------------------------------------------|
| `characterFlags` | `int`: the array of the character's flags. This value cannot be`null`. <br /> |

|                                                                        Returns                                                                        ||
|-------------------------------------------------------------------------------------------------------------------|------------------------------------|
| [TextBoundsInfo.Builder](https://developer.android.com/reference/android/view/inputmethod/TextBoundsInfo.Builder) | This value cannot be`null`. <br /> |

|                                                                           Throws                                                                            ||
|--------------------------------------------------------------------------------------------------------|-----------------------------------------------------|
| [NullPointerException](https://developer.android.com/reference/java/lang/NullPointerException)         | if the given`characterFlags`is`null`.               |
| [IllegalArgumentException](https://developer.android.com/reference/java/lang/IllegalArgumentException) | if the given`characterFlags`contains invalid flags. |

**See also:**

- [TextBoundsInfo.getCharacterFlags(int)](https://developer.android.com/reference/android/view/inputmethod/TextBoundsInfo#getCharacterFlags(int))  

### setGraphemeSegmentFinder

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

```
public TextBoundsInfo.Builder setGraphemeSegmentFinder (SegmentFinder graphemeSegmentFinder)
```

Set the[SegmentFinder](https://developer.android.com/reference/android/text/SegmentFinder)that locates the grapheme cluster boundaries. Grapheme is defined in[the unicode annex #29: unicode text segmentation](https://unicode.org/reports/tr29/#Grapheme_Cluster_Boundaries). It's a user-perspective character. And it's usually the minimal unit for selection, backspace, deletion etc.  
Please note that only the grapheme segments within the range from start to end will be available to the IME. The remaining information will be discarded during serialization for better performance.

<br />

|                                                                                                    Parameters                                                                                                    ||
|-------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `graphemeSegmentFinder` | `SegmentFinder`: the[SegmentFinder](https://developer.android.com/reference/android/text/SegmentFinder)that locates the grapheme cluster boundaries. This value cannot be`null`. <br /> |

|                                                                        Returns                                                                        ||
|-------------------------------------------------------------------------------------------------------------------|------------------------------------|
| [TextBoundsInfo.Builder](https://developer.android.com/reference/android/view/inputmethod/TextBoundsInfo.Builder) | This value cannot be`null`. <br /> |

|                                                                    Throws                                                                    ||
|------------------------------------------------------------------------------------------------|----------------------------------------------|
| [NullPointerException](https://developer.android.com/reference/java/lang/NullPointerException) | if the given`graphemeSegmentFinder`is`null`. |

**See also:**

- [TextBoundsInfo.getGraphemeSegmentFinder()](https://developer.android.com/reference/android/view/inputmethod/TextBoundsInfo#getGraphemeSegmentFinder())
- [SegmentFinder](https://developer.android.com/reference/android/text/SegmentFinder)
- [SegmentFinder.PrescribedSegmentFinder](https://developer.android.com/reference/android/text/SegmentFinder.PrescribedSegmentFinder)  

### setLineSegmentFinder

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

```
public TextBoundsInfo.Builder setLineSegmentFinder (SegmentFinder lineSegmentFinder)
```

Set the[SegmentFinder](https://developer.android.com/reference/android/text/SegmentFinder)that locates the line boundaries. Aside from the hard breaks in the text, it should also locate the soft line breaks added by the editor. It is expected that the characters within the same line is rendered on the same baseline. (Except for some text formatted as subscript and superscript.)  
Please note that only the line segments within the range from start to end will be available to the IME. The remaining information will be discarded during serialization for better performance.

<br />

|                                                                                              Parameters                                                                                              ||
|---------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `lineSegmentFinder` | `SegmentFinder`: set the[SegmentFinder](https://developer.android.com/reference/android/text/SegmentFinder)that locates the line boundaries. This value cannot be`null`. <br /> |

|                                                                        Returns                                                                        ||
|-------------------------------------------------------------------------------------------------------------------|------------------------------------|
| [TextBoundsInfo.Builder](https://developer.android.com/reference/android/view/inputmethod/TextBoundsInfo.Builder) | This value cannot be`null`. <br /> |

|                                                                  Throws                                                                  ||
|------------------------------------------------------------------------------------------------|------------------------------------------|
| [NullPointerException](https://developer.android.com/reference/java/lang/NullPointerException) | if the given`lineSegmentFinder`is`null`. |

**See also:**

- [TextBoundsInfo.getLineSegmentFinder()](https://developer.android.com/reference/android/view/inputmethod/TextBoundsInfo#getLineSegmentFinder())
- [SegmentFinder](https://developer.android.com/reference/android/text/SegmentFinder)
- [SegmentFinder.PrescribedSegmentFinder](https://developer.android.com/reference/android/text/SegmentFinder.PrescribedSegmentFinder)  

### setMatrix

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

```
public TextBoundsInfo.Builder setMatrix (Matrix matrix)
```

Sets the matrix that transforms local coordinates into screen coordinates.

<br />

|                                                          Parameters                                                          ||
|----------|--------------------------------------------------------------------------------------------------------------------|
| `matrix` | `Matrix`: transformation matrix from local coordinates into screen coordinates. This value cannot be`null`. <br /> |

|                                                                        Returns                                                                        ||
|-------------------------------------------------------------------------------------------------------------------|------------------------------------|
| [TextBoundsInfo.Builder](https://developer.android.com/reference/android/view/inputmethod/TextBoundsInfo.Builder) | This value cannot be`null`. <br /> |

|                                                            Throws                                                             ||
|------------------------------------------------------------------------------------------------|-------------------------------|
| [NullPointerException](https://developer.android.com/reference/java/lang/NullPointerException) | if the given`matrix`is`null`. |

### setStartAndEnd

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

```
public TextBoundsInfo.Builder setStartAndEnd (int start, 
                int end)
```

Set the start and end index of the[TextBoundsInfo](https://developer.android.com/reference/android/view/inputmethod/TextBoundsInfo). It's the range of the characters whose information is available in the[TextBoundsInfo](https://developer.android.com/reference/android/view/inputmethod/TextBoundsInfo).

<br />

|                                                                                    Parameters                                                                                    ||
|---------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `start` | `int`: the start index of the[TextBoundsInfo](https://developer.android.com/reference/android/view/inputmethod/TextBoundsInfo), inclusive. Value is 0 or greater <br /> |
| `end`   | `int`: the end index of the[TextBoundsInfo](https://developer.android.com/reference/android/view/inputmethod/TextBoundsInfo), exclusive. Value is 0 or greater <br />   |

|                                                                        Returns                                                                        ||
|-------------------------------------------------------------------------------------------------------------------|------------------------------------|
| [TextBoundsInfo.Builder](https://developer.android.com/reference/android/view/inputmethod/TextBoundsInfo.Builder) | This value cannot be`null`. <br /> |

|                                                                                      Throws                                                                                       ||
|--------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------|
| [IllegalArgumentException](https://developer.android.com/reference/java/lang/IllegalArgumentException) | if the given`start`or`end`is negative, or`end`is smaller than the`start`. |

### setWordSegmentFinder

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

```
public TextBoundsInfo.Builder setWordSegmentFinder (SegmentFinder wordSegmentFinder)
```

Set the[SegmentFinder](https://developer.android.com/reference/android/text/SegmentFinder)that locates the word boundaries.  
Please note that only the word segments within the range from start to end will be available to the IME. The remaining information will be discarded during serialization for better performance.

<br />

|                                                                                              Parameters                                                                                              ||
|---------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `wordSegmentFinder` | `SegmentFinder`: set the[SegmentFinder](https://developer.android.com/reference/android/text/SegmentFinder)that locates the word boundaries. This value cannot be`null`. <br /> |

|                                                                        Returns                                                                        ||
|-------------------------------------------------------------------------------------------------------------------|------------------------------------|
| [TextBoundsInfo.Builder](https://developer.android.com/reference/android/view/inputmethod/TextBoundsInfo.Builder) | This value cannot be`null`. <br /> |

|                                                                  Throws                                                                  ||
|------------------------------------------------------------------------------------------------|------------------------------------------|
| [NullPointerException](https://developer.android.com/reference/java/lang/NullPointerException) | if the given`wordSegmentFinder`is`null`. |

**See also:**

- [TextBoundsInfo.getWordSegmentFinder()](https://developer.android.com/reference/android/view/inputmethod/TextBoundsInfo#getWordSegmentFinder())
- [SegmentFinder](https://developer.android.com/reference/android/text/SegmentFinder)
- [SegmentFinder.PrescribedSegmentFinder](https://developer.android.com/reference/android/text/SegmentFinder.PrescribedSegmentFinder)