TextSelection.Builder


public static final class TextSelection.Builder
extends Object

java.lang.Object
   ↳ android.view.textclassifier.TextSelection.Builder


Builder used to build TextSelection objects.

Summary

Public constructors

Builder(int startIndex, int endIndex)

Creates a builder used to build TextSelection objects.

Public methods

TextSelection build()

Builds and returns TextSelection object.

TextSelection.Builder setEntityType(String type, float confidenceScore)

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

TextSelection.Builder setExtras(Bundle extras)

Sets the extended data.

TextSelection.Builder setId(String id)

Sets an id for the TextSelection object.

TextSelection.Builder setTextClassification(TextClassification textClassification)

Sets the text classification result of the suggested selection.

Inherited methods

Object clone()

Creates and returns a copy of this object.

boolean equals(Object obj)

Indicates whether some other object is "equal to" this one.

void finalize()

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.

final Class<?> getClass()

Returns the runtime class of this Object.

int hashCode()

Returns a hash code value for the object.

final void notify()

Wakes up a single thread that is waiting on this object's monitor.

final void notifyAll()

Wakes up all threads that are waiting on this object's monitor.

String toString()

Returns a string representation of the object.

final void wait(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(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()

Causes the current thread to wait until it is awakened, typically by being notified or interrupted.

Public constructors

Builder

Added in API level 26
public Builder (int startIndex, 
                int endIndex)

Creates a builder used to build TextSelection objects.

Parameters
startIndex int: the start index of the text selection. Value is 0 or greater

endIndex int: the end index of the text selection. Must be greater than startIndex Value is 0 or greater

Public methods

build

Added in API level 26
public TextSelection build ()

Builds and returns TextSelection object.

Returns
TextSelection This value cannot be null.

setEntityType

Added in API level 26
public TextSelection.Builder setEntityType (String type, 
                float confidenceScore)

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

Parameters
type String: This value cannot be null. Value is TextClassifier.TYPE_UNKNOWN, TextClassifier.TYPE_OTHER, TextClassifier.TYPE_EMAIL, TextClassifier.TYPE_PHONE, TextClassifier.TYPE_ADDRESS, TextClassifier.TYPE_URL, TextClassifier.TYPE_DATE, TextClassifier.TYPE_DATE_TIME, TextClassifier.TYPE_FLIGHT_NUMBER, android.view.textclassifier.TextClassifier.TYPE_DICTIONARY, or TextClassifier.TYPE_OTP

confidenceScore float: 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. Value is between 0.0 and 1.0 inclusive

Returns
TextSelection.Builder This value cannot be null.

setExtras

Added in API level 29
public TextSelection.Builder setExtras (Bundle extras)

Sets the extended data.

Parameters
extras Bundle: This value may be null.

Returns
TextSelection.Builder this builder This value cannot be null.

setId

Added in API level 28
public TextSelection.Builder setId (String id)

Sets an id for the TextSelection object.

Parameters
id String: This value may be null.

Returns
TextSelection.Builder This value cannot be null.

setTextClassification

Added in API level 31
public TextSelection.Builder setTextClassification (TextClassification textClassification)

Sets the text classification result of the suggested selection. If Request.shouldIncludeTextClassification() is true, set this value. Otherwise this value may be set to null. The intention of this method is to avoid doing expensive work if the client is not interested in such result.

Parameters
textClassification TextClassification: This value may be null.

Returns
TextSelection.Builder this builder