java.lang.Object
org.elasticsearch.xcontent.Text
- All Implemented Interfaces:
Comparable<Text>
,ToXContent
,ToXContentFragment
,XContentString
public final class Text
extends Object
implements XContentString, Comparable<Text>, ToXContentFragment
Both
String
and XContentString.UTF8Bytes
representation of the text. Starts with one of those, and if
the other is requested, caches the other one in a local reference so no additional conversion will be needed.-
Nested Class Summary
Nested classes/interfaces inherited from interface org.elasticsearch.xcontent.ToXContent
ToXContent.DelegatingMapParams, ToXContent.MapParams, ToXContent.Params
Nested classes/interfaces inherited from interface org.elasticsearch.xcontent.XContentString
XContentString.UTF8Bytes
-
Field Summary
FieldsFields inherited from interface org.elasticsearch.xcontent.ToXContent
EMPTY, EMPTY_PARAMS
-
Constructor Summary
ConstructorsConstructorDescriptionText
(XContentString.UTF8Bytes bytes) Construct a Text from encoded UTF8Bytes.Text
(XContentString.UTF8Bytes bytes, int stringLength) Construct a Text from encoded UTF8Bytes and an explicit string length. -
Method Summary
Modifier and TypeMethodDescriptionbytes()
Returns an encodedXContentString.UTF8Bytes
view of the data.int
static Text[]
convertFromStringArray
(String[] strings) boolean
boolean
hasBytes()
Whether anXContentString.UTF8Bytes
view of the data is already materialized.int
hashCode()
boolean
Whether aString
view of the data is already materialized.string()
Returns aString
view of the data.int
Returns the number of characters in the represented string.toString()
toXContent
(XContentBuilder builder, ToXContent.Params params) Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.elasticsearch.xcontent.ToXContentFragment
isFragment
-
Field Details
-
EMPTY_ARRAY
-
-
Constructor Details
-
Text
Construct a Text from encoded UTF8Bytes. Since no string length is specified,stringLength()
will perform a string conversion to measure the string length. -
Text
Construct a Text from encoded UTF8Bytes and an explicit string length. Used to avoid string conversion instringLength()
. The provided stringLength should match the value that would be calculated byText(UTF8Bytes)
. -
Text
-
-
Method Details
-
convertFromStringArray
-
hasBytes
public boolean hasBytes()Whether anXContentString.UTF8Bytes
view of the data is already materialized. -
bytes
Description copied from interface:XContentString
Returns an encodedXContentString.UTF8Bytes
view of the data.- Specified by:
bytes
in interfaceXContentString
-
hasString
public boolean hasString()Whether aString
view of the data is already materialized. -
string
Description copied from interface:XContentString
Returns aString
view of the data.- Specified by:
string
in interfaceXContentString
-
stringLength
public int stringLength()Description copied from interface:XContentString
Returns the number of characters in the represented string.- Specified by:
stringLength
in interfaceXContentString
-
toString
-
hashCode
public int hashCode() -
equals
-
compareTo
- Specified by:
compareTo
in interfaceComparable<Text>
-
toXContent
public XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params params) throws IOException - Specified by:
toXContent
in interfaceToXContent
- Throws:
IOException
-