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.ParamsNested 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.UTF8Bytesview of the data.intstatic Text[]convertFromStringArray(String[] strings) booleanbooleanhasBytes()Whether anXContentString.UTF8Bytesview of the data is already materialized.inthashCode()booleanWhether aStringview of the data is already materialized.string()Returns aStringview of the data.intReturns 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, waitMethods 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.UTF8Bytesview of the data is already materialized. -
bytes
Description copied from interface:XContentStringReturns an encodedXContentString.UTF8Bytesview of the data.- Specified by:
bytesin interfaceXContentString
-
hasString
public boolean hasString()Whether aStringview of the data is already materialized. -
string
Description copied from interface:XContentStringReturns aStringview of the data.- Specified by:
stringin interfaceXContentString
-
stringLength
public int stringLength()Description copied from interface:XContentStringReturns the number of characters in the represented string.- Specified by:
stringLengthin interfaceXContentString
-
toString
-
hashCode
public int hashCode() -
equals
-
compareTo
- Specified by:
compareToin interfaceComparable<Text>
-
toXContent
public XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params params) throws IOException - Specified by:
toXContentin interfaceToXContent- Throws:
IOException
-