TextSelection.Builder


public final class TextSelection.Builder


Builder used to build TextSelection objects.

Summary

Public constructors

Builder(@IntRange(from = 0) int startIndex, @IntRange(from = 0) int endIndex)

Creates a builder used to build TextSelection objects.

Public methods

@NonNull TextSelection

Builds and returns TextSelection object.

@NonNull TextSelection.Builder
setEntityType(
    @NonNull String type,
    @FloatRange(from = 0.0, to = 1.0) float confidenceScore
)

Sets an entity type for the classified text and assigns a confidence score.

@NonNull TextSelection.Builder

Sets the extended, vendor specific data.

@NonNull TextSelection.Builder

Sets an id for the TextSelection object.

Public constructors

Builder

public Builder(@IntRange(from = 0) int startIndex, @IntRange(from = 0) int endIndex)

Creates a builder used to build TextSelection objects.

Parameters
@IntRange(from = 0) int startIndex

the start index of the text selection.

@IntRange(from = 0) int endIndex

the end index of the text selection. Must be greater than startIndex

Public methods

build

public @NonNull TextSelection build()

Builds and returns TextSelection object.

setEntityType

public @NonNull TextSelection.Builder setEntityType(
    @NonNull String type,
    @FloatRange(from = 0.0, to = 1.0) float confidenceScore
)

Sets an entity type for the classified text and assigns a confidence score.

Parameters
@FloatRange(from = 0.0, to = 1.0) float confidenceScore

a value from 0 (low confidence) to 1 (high confidence). 0 implies the entity does not exist for the classified text. Values greater than 1 are clamped to 1.

setExtras

public @NonNull TextSelection.Builder setExtras(@Nullable Bundle extras)

Sets the extended, vendor specific data.

setId

public @NonNull TextSelection.Builder setId(@Nullable String id)

Sets an id for the TextSelection object.