# TextNode

Artifact: [androidx.appsearch:appsearch](https://developer.android.com/jetpack/androidx/releases/appsearch) [View Source](https://cs.android.com/search?q=file:androidx/appsearch/ast/TextNode.java+class:androidx.appsearch.ast.TextNode) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appsearch#1.1.0)

*** ** * ** ***


```
@ExperimentalAppSearchApi
class TextNode : Node
```

<br />

*** ** * ** ***

`https://developer.android.com/reference/kotlin/androidx/appsearch/ast/Node` that stores text.

Text may represent a string or number. For example in the query \`hello AND "world peace" -cat price:49.99\`

- hello and cat are strings.
- "world peace" is a verbatim string, i.e. a quoted string that can be represented by setting mVerbatim to true. Because it is a verbatim string, it will be treated as a single term "world peace" instead of terms "world" and "peace".
- 49.99 is a number. `https://developer.android.com/reference/kotlin/androidx/appsearch/ast/TextNode`s may represent integers or doubles and treat numbers as terms.
- price is NOT a string but a property path as part of a `https://developer.android.com/reference/kotlin/androidx/appsearch/ast/operators/PropertyRestrictNode`.

The node will be segmented and normalized based on the flags set in the Node. For example, if the node containing the string "foo" has both mPrefix and mVerbatim set to true, then the resulting tree will be treated as the query \`"foo"\*\` i.e. the prefix of the quoted string "foo".

`https://developer.android.com/reference/kotlin/androidx/appsearch/ast/TextNode`s is guaranteed to not have child nodes.

This API may change in response to feedback and additional changes.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/appsearch/ast/TextNode#TextNode(androidx.appsearch.ast.TextNode)(original: https://developer.android.com/reference/kotlin/androidx/appsearch/ast/TextNode)` Copy constructor that takes in `https://developer.android.com/reference/kotlin/androidx/appsearch/ast/TextNode`. |
| `https://developer.android.com/reference/kotlin/androidx/appsearch/ast/TextNode#TextNode(java.lang.String)(value: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)` Public constructor for `https://developer.android.com/reference/kotlin/androidx/appsearch/ast/TextNode` representing text passed into the constructor as a string. |

| ### Public functions |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/appsearch/ast/TextNode#equals(java.lang.Object)(o: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html!)` |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | `https://developer.android.com/reference/kotlin/androidx/appsearch/ast/TextNode#getValue()()` Retrieve the string value that the TextNode holds. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/appsearch/ast/TextNode#hashCode()()` |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/appsearch/ast/TextNode#isPrefix()()` Whether or not a TextNode represents a query term that will match indexed tokens when the query term is a prefix of the token. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/appsearch/ast/TextNode#isVerbatim()()` Whether or not a TextNode represents a quoted string. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/appsearch/ast/TextNode#setPrefix(boolean)(isPrefix: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)` Set whether or not the `https://developer.android.com/reference/kotlin/androidx/appsearch/ast/TextNode` represents a prefix. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/appsearch/ast/TextNode#setValue(java.lang.String)(value: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)` Set the text value that the `https://developer.android.com/reference/kotlin/androidx/appsearch/ast/TextNode` holds. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/appsearch/ast/TextNode#setVerbatim(boolean)(isVerbatim: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)` Set whether or not the `https://developer.android.com/reference/kotlin/androidx/appsearch/ast/TextNode` represents a quoted string, i.e. verbatim. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | `https://developer.android.com/reference/kotlin/androidx/appsearch/ast/TextNode#toString()()` Get the query string representation of `https://developer.android.com/reference/kotlin/androidx/appsearch/ast/TextNode`. |

| ### Inherited functions |
|---|
| From [androidx.appsearch.ast.Node](https://developer.android.com/reference/kotlin/androidx/appsearch/ast/Node) |---|---| | `(https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-list/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/kotlin/androidx/appsearch/ast/Node!>` | `https://developer.android.com/reference/kotlin/androidx/appsearch/ast/Node#getChildren()()` Get a list of the node's child `https://developer.android.com/reference/kotlin/androidx/appsearch/ast/Node`s. | |

## Public constructors

### TextNode

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appsearch#1.1.0)

```
TextNode(original: TextNode)
```

Copy constructor that takes in `https://developer.android.com/reference/kotlin/androidx/appsearch/ast/TextNode`.

| Parameters |
|---|---|
| `original: https://developer.android.com/reference/kotlin/androidx/appsearch/ast/TextNode` | The `https://developer.android.com/reference/kotlin/androidx/appsearch/ast/TextNode` to copy and return another `https://developer.android.com/reference/kotlin/androidx/appsearch/ast/TextNode`. |

### TextNode

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appsearch#1.1.0)

```
TextNode(value: String)
```

Public constructor for `https://developer.android.com/reference/kotlin/androidx/appsearch/ast/TextNode` representing text passed into the constructor as a string.

By default `https://developer.android.com/reference/kotlin/androidx/appsearch/ast/TextNode#mPrefix()` and `https://developer.android.com/reference/kotlin/androidx/appsearch/ast/TextNode#mVerbatim()` are both false. In other words the `https://developer.android.com/reference/kotlin/androidx/appsearch/ast/TextNode` represents a term that is not the prefix of a potentially longer term that could be matched against and not a quoted string to be treated as a single term.

| Parameters |
|---|---|
| `value: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | The text value that `https://developer.android.com/reference/kotlin/androidx/appsearch/ast/TextNode` holds. |

## Public functions

### equals

```
fun equals(o: Any!): Boolean
```

### getValue

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appsearch#1.1.0)

```
fun getValue(): String
```

Retrieve the string value that the TextNode holds.

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | A string representing the text that the TextNode holds. |

### hashCode

```
fun hashCode(): Int
```

### isPrefix

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appsearch#1.1.0)

```
fun isPrefix(): Boolean
```

Whether or not a TextNode represents a query term that will match indexed tokens when the query term is a prefix of the token.

For example, if the value of the TextNode is "foo" and mPrefix is set to true, then the TextNode represents the query \`foo\*\`, and will match against tokens like "foo", "foot", and "football".

If mPrefix and mVerbatim are both true, then the TextNode represents the prefix of the quoted string. For example if the value of the TextNode is "foo bar" and both mPrefix and mVerbatim are set to true, then the TextNode represents the query \`"foo bar"\*\`.

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | True, if the TextNode represents a query term that will match indexed tokens when the query term is a prefix of the token. False, if the TextNode represents a query term that will only match exact tokens in the index. |

### isVerbatim

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appsearch#1.1.0)

```
fun isVerbatim(): Boolean
```

Whether or not a TextNode represents a quoted string.

For example, if the value of the TextNode is "foo bar" and mVerbatim is set to true, then the TextNode represents the query \`"foo bar"\`. "foo bar" will be treated as a single token and match documents that have a property marked as verbatim and exactly contain "foo bar".

If mVerbatim and mPrefix are both true, then the TextNode represents the prefix of the quoted string. For example if the value of the TextNode is "foo bar" and both mPrefix and mVerbatim are set to true, then the TextNode represents the query \`"foo bar"\*\`.

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | True, if the TextNode represents a quoted string. For example, if the value of TextNode is "foo bar", then the query represented is \`"foo bar"\`. This means "foo bar" will be treated as one term, matching documents that have a property marked as verbatim and contains exactly "foo bar". False, if the TextNode does not represent a quoted string. For example, if the value of TextNode is "foo bar", then the query represented is \`foo bar\`. This means that "foo" and "bar" will be treated as separate terms instead of one term and implicitly ANDed, matching documents that contain both "foo" and "bar". |

### setPrefix

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appsearch#1.1.0)

```
fun setPrefix(isPrefix: Boolean): Unit
```

Set whether or not the `https://developer.android.com/reference/kotlin/androidx/appsearch/ast/TextNode` represents a prefix. If true, the `https://developer.android.com/reference/kotlin/androidx/appsearch/ast/TextNode` represents a prefix match for `value`.

| Parameters |
|---|---|
| `isPrefix: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | Whether or not the `https://developer.android.com/reference/kotlin/androidx/appsearch/ast/TextNode` represents a prefix. If true, it represents a query term that will match against indexed tokens when the query term is a prefix of token. |

### setValue

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appsearch#1.1.0)

```
fun setValue(value: String): Unit
```

Set the text value that the `https://developer.android.com/reference/kotlin/androidx/appsearch/ast/TextNode` holds.

| Parameters |
|---|---|
| `value: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | The string that the `https://developer.android.com/reference/kotlin/androidx/appsearch/ast/TextNode` will hold. |

### setVerbatim

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appsearch#1.1.0)

```
fun setVerbatim(isVerbatim: Boolean): Unit
```

Set whether or not the `https://developer.android.com/reference/kotlin/androidx/appsearch/ast/TextNode` represents a quoted string, i.e. verbatim. If true, the `https://developer.android.com/reference/kotlin/androidx/appsearch/ast/TextNode` represents a quoted string.

| Parameters |
|---|---|
| `isVerbatim: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | Whether or not the `https://developer.android.com/reference/kotlin/androidx/appsearch/ast/TextNode` represents a quoted string. If true, it represents a quoted string. |

### toString

```
fun toString(): String
```

Get the query string representation of `https://developer.android.com/reference/kotlin/androidx/appsearch/ast/TextNode`.

If no flags are set, then the string representation is just the value held by `https://developer.android.com/reference/kotlin/androidx/appsearch/ast/TextNode`. Otherwise the value will be formatted depending on the combination of flags set.

The string representation of `https://developer.android.com/reference/kotlin/androidx/appsearch/ast/TextNode` maybe different from `https://developer.android.com/reference/kotlin/androidx/appsearch/ast/TextNode#mValue()` if it contains operators that need to be escaped for the query string to be treated as a string rather than a query.