Stay organized with collections
Save and categorize content based on your preferences.
PrescribedSegmentFinder
open class PrescribedSegmentFinder : SegmentFinder
The default SegmentFinder
implementation based on given segment ranges.
Summary
Inherited constants |
From class SegmentFinder
Int |
DONE
Return value of previousStartBoundary(int), previousEndBoundary(int), nextStartBoundary(int), and nextEndBoundary(int) when there are no boundaries of the specified type in the specified direction.
|
|
Public constructors |
Create a SegmentFinder with segments stored in an array, where i-th segment's start is stored at segments[2 * i] and end is stored at segments[2 * i + 1] respectively.
|
Public methods |
open Int |
Returns the character offset of the next text segment end boundary after the specified character offset, or DONE if there are none.
|
open Int |
Returns the character offset of the next text segment start boundary after the specified character offset, or DONE if there are none.
|
open Int |
Returns the character offset of the previous text segment end boundary before the specified character offset, or DONE if there are none.
|
open Int |
Returns the character offset of the previous text segment start boundary before the specified character offset, or DONE if there are none.
|
Public constructors
PrescribedSegmentFinder
PrescribedSegmentFinder(segments: IntArray)
Create a SegmentFinder with segments stored in an array, where i-th segment's start is stored at segments[2 * i] and end is stored at segments[2 * i + 1] respectively.
It is required that segments do not overlap, and are already sorted by their start indices.
Parameters |
segments |
IntArray: the array that stores the segment ranges. |
Exceptions |
java.lang.IllegalArgumentException |
if the given segments array's length is not even; the given segments are not sorted or there are segments overlap with others. |
Public methods
nextEndBoundary
open fun nextEndBoundary(offset: Int): Int
Returns the character offset of the next text segment end boundary after the specified character offset, or DONE
if there are none.
Parameters |
offset |
Int: Value is 0 or greater |
nextStartBoundary
open fun nextStartBoundary(offset: Int): Int
Returns the character offset of the next text segment start boundary after the specified character offset, or DONE
if there are none.
Parameters |
offset |
Int: Value is 0 or greater |
previousEndBoundary
open fun previousEndBoundary(offset: Int): Int
Returns the character offset of the previous text segment end boundary before the specified character offset, or DONE
if there are none.
Parameters |
offset |
Int: Value is 0 or greater |
previousStartBoundary
open fun previousStartBoundary(offset: Int): Int
Returns the character offset of the previous text segment start boundary before the specified character offset, or DONE
if there are none.
Parameters |
offset |
Int: Value is 0 or greater |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-02-10 UTC."],[],[],null,["# SegmentFinder.PrescribedSegmentFinder\n\nAdded in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)\n\nPrescribedSegmentFinder\n=======================\n\n*** ** * ** ***\n\nKotlin \\|[Java](/reference/android/text/SegmentFinder.PrescribedSegmentFinder \"View this page in Java\") \n\n```\nopen class PrescribedSegmentFinder : SegmentFinder\n```\n\n|---|---|---------------------------------------------------------|\n| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html) |||\n| ↳ | [android.text.SegmentFinder](/reference/kotlin/android/text/SegmentFinder) ||\n| | ↳ | [android.text.SegmentFinder.PrescribedSegmentFinder](#) |\n\nThe default [SegmentFinder](/reference/kotlin/android/text/SegmentFinder) implementation based on given segment ranges.\n\nSummary\n-------\n\n| Inherited constants ||\n|---|---|\n| From class [SegmentFinder](/reference/kotlin/android/text/SegmentFinder) |----------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [DONE](/reference/kotlin/android/text/SegmentFinder#DONE:kotlin.Int) Return value of previousStartBoundary(int), previousEndBoundary(int), nextStartBoundary(int), and nextEndBoundary(int) when there are no boundaries of the specified type in the specified direction. \u003cbr /\u003e | ||\n\n| Public constructors ||\n|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|\n| [PrescribedSegmentFinder](#PrescribedSegmentFinder(kotlin.IntArray))`(`segments:` `[IntArray](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int-array/index.html)`)` Create a SegmentFinder with segments stored in an array, where i-th segment's start is stored at segments\\[2 \\* i\\] and end is stored at segments\\[2 \\* i + 1\\] respectively. |\n\n| Public methods ||\n|---------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| open [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [nextEndBoundary](#nextEndBoundary(kotlin.Int))`(`offset:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Returns the character offset of the next text segment end boundary after the specified character offset, or `DONE` if there are none. |\n| open [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [nextStartBoundary](#nextStartBoundary(kotlin.Int))`(`offset:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Returns the character offset of the next text segment start boundary after the specified character offset, or `DONE` if there are none. |\n| open [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [previousEndBoundary](#previousEndBoundary(kotlin.Int))`(`offset:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Returns the character offset of the previous text segment end boundary before the specified character offset, or `DONE` if there are none. |\n| open [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [previousStartBoundary](#previousStartBoundary(kotlin.Int))`(`offset:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Returns the character offset of the previous text segment start boundary before the specified character offset, or `DONE` if there are none. |\n\nPublic constructors\n-------------------\n\n### PrescribedSegmentFinder\n\nAdded in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nPrescribedSegmentFinder(segments: IntArray)\n```\n\nCreate a SegmentFinder with segments stored in an array, where i-th segment's start is stored at segments\\[2 \\* i\\] and end is stored at segments\\[2 \\* i + 1\\] respectively.\n\nIt is required that segments do not overlap, and are already sorted by their start indices.\n\n| Parameters ||\n|------------|----------------------------------------------------------------------------------------------------------------------------------|\n| `segments` | [IntArray](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int-array/index.html): the array that stores the segment ranges. |\n\n| Exceptions ||\n|--------------------------------------|--------------------------------------------------------------------------------------------------------------------------------|\n| `java.lang.IllegalArgumentException` | if the given segments array's length is not even; the given segments are not sorted or there are segments overlap with others. |\n\nPublic methods\n--------------\n\n### nextEndBoundary\n\nAdded in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen fun nextEndBoundary(offset: Int): Int\n```\n\nReturns the character offset of the next text segment end boundary after the specified character offset, or `DONE` if there are none.\n\n| Parameters ||\n|----------|---------------------------------------------------------------------------------------------------|\n| `offset` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): Value is 0 or greater |\n\n### nextStartBoundary\n\nAdded in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen fun nextStartBoundary(offset: Int): Int\n```\n\nReturns the character offset of the next text segment start boundary after the specified character offset, or `DONE` if there are none.\n\n| Parameters ||\n|----------|---------------------------------------------------------------------------------------------------|\n| `offset` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): Value is 0 or greater |\n\n### previousEndBoundary\n\nAdded in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen fun previousEndBoundary(offset: Int): Int\n```\n\nReturns the character offset of the previous text segment end boundary before the specified character offset, or `DONE` if there are none.\n\n| Parameters ||\n|----------|---------------------------------------------------------------------------------------------------|\n| `offset` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): Value is 0 or greater |\n\n### previousStartBoundary\n\nAdded in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen fun previousStartBoundary(offset: Int): Int\n```\n\nReturns the character offset of the previous text segment start boundary before the specified character offset, or `DONE` if there are none.\n\n| Parameters ||\n|----------|---------------------------------------------------------------------------------------------------|\n| `offset` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): Value is 0 or greater |"]]