Class Text

java.lang.Object
org.elasticsearch.common.text.Text
All Implemented Interfaces:
java.lang.Comparable<Text>, org.elasticsearch.common.xcontent.ToXContent, org.elasticsearch.common.xcontent.ToXContentFragment

public final class Text
extends java.lang.Object
implements java.lang.Comparable<Text>, org.elasticsearch.common.xcontent.ToXContentFragment
Both String and BytesReference representation of the text. Starts with one of those, and if the other is requests, 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.common.xcontent.ToXContent

    org.elasticsearch.common.xcontent.ToXContent.DelegatingMapParams, org.elasticsearch.common.xcontent.ToXContent.MapParams, org.elasticsearch.common.xcontent.ToXContent.Params
  • Field Summary

    Fields
    Modifier and Type Field Description
    static Text[] EMPTY_ARRAY  

    Fields inherited from interface org.elasticsearch.common.xcontent.ToXContent

    EMPTY_PARAMS
  • Constructor Summary

    Constructors
    Constructor Description
    Text​(java.lang.String text)  
    Text​(BytesReference bytes)  
  • Method Summary

    Modifier and Type Method Description
    BytesReference bytes()
    Returns a BytesReference view of the data.
    int compareTo​(Text text)  
    static Text[] convertFromStringArray​(java.lang.String[] strings)  
    boolean equals​(java.lang.Object obj)  
    boolean hasBytes()
    Whether a BytesReference view of the data is already materialized.
    int hashCode()  
    boolean hasString()
    Whether a String view of the data is already materialized.
    java.lang.String string()
    Returns a String view of the data.
    java.lang.String toString()  
    org.elasticsearch.common.xcontent.XContentBuilder toXContent​(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params)  

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait

    Methods inherited from interface org.elasticsearch.common.xcontent.ToXContentFragment

    isFragment
  • Field Details

    • EMPTY_ARRAY

      public static final Text[] EMPTY_ARRAY
  • Constructor Details

    • Text

      public Text​(BytesReference bytes)
    • Text

      public Text​(java.lang.String text)
  • Method Details

    • convertFromStringArray

      public static Text[] convertFromStringArray​(java.lang.String[] strings)
    • hasBytes

      public boolean hasBytes()
      Whether a BytesReference view of the data is already materialized.
    • bytes

      public BytesReference bytes()
      Returns a BytesReference view of the data.
    • hasString

      public boolean hasString()
      Whether a String view of the data is already materialized.
    • string

      public java.lang.String string()
      Returns a String view of the data.
    • toString

      public java.lang.String toString()
      Overrides:
      toString in class java.lang.Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class java.lang.Object
    • equals

      public boolean equals​(java.lang.Object obj)
      Overrides:
      equals in class java.lang.Object
    • compareTo

      public int compareTo​(Text text)
      Specified by:
      compareTo in interface java.lang.Comparable<Text>
    • toXContent

      public org.elasticsearch.common.xcontent.XContentBuilder toXContent​(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params) throws java.io.IOException
      Specified by:
      toXContent in interface org.elasticsearch.common.xcontent.ToXContent
      Throws:
      java.io.IOException