org.elasticsearch.common.text
Class StringAndBytesText

java.lang.Object
  extended by org.elasticsearch.common.text.StringAndBytesText
All Implemented Interfaces:
Text

public class StringAndBytesText
extends Object
implements Text

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.


Field Summary
static Text[] EMPTY_ARRAY
           
 
Constructor Summary
StringAndBytesText(BytesReference bytes)
           
StringAndBytesText(String text)
           
 
Method Summary
 BytesReference bytes()
          The UTF8 bytes representing the the text, might be converted on the fly, see Text.hasBytes()
static Text[] convertFromStringArray(String[] strings)
           
 boolean hasBytes()
          Are bytes available without the need to be converted into bytes when calling Text.bytes().
 boolean hasString()
          Is there a String representation of the text.
 String string()
          Returns the string representation of the text, might be converted to a string on the fly.
 String toString()
          Returns the string representation of the text, might be converted to a string on the fly.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

EMPTY_ARRAY

public static final Text[] EMPTY_ARRAY
Constructor Detail

StringAndBytesText

public StringAndBytesText(BytesReference bytes)

StringAndBytesText

public StringAndBytesText(String text)
Method Detail

convertFromStringArray

public static Text[] convertFromStringArray(String[] strings)

hasBytes

public boolean hasBytes()
Description copied from interface: Text
Are bytes available without the need to be converted into bytes when calling Text.bytes().

Specified by:
hasBytes in interface Text

bytes

public BytesReference bytes()
Description copied from interface: Text
The UTF8 bytes representing the the text, might be converted on the fly, see Text.hasBytes()

Specified by:
bytes in interface Text

hasString

public boolean hasString()
Description copied from interface: Text
Is there a String representation of the text. If not, then it Text.hasBytes().

Specified by:
hasString in interface Text

string

public String string()
Description copied from interface: Text
Returns the string representation of the text, might be converted to a string on the fly.

Specified by:
string in interface Text

toString

public String toString()
Description copied from interface: Text
Returns the string representation of the text, might be converted to a string on the fly.

Specified by:
toString in interface Text
Overrides:
toString in class Object


Copyright © 2009-2012. All Rights Reserved.