com.twitter.common.text.token.attribute
Interface CharSequenceTermAttribute

All Superinterfaces:
org.apache.lucene.util.Attribute
All Known Implementing Classes:
CharSequenceTermAttributeImpl

public interface CharSequenceTermAttribute
extends org.apache.lucene.util.Attribute

TermAttribute backed by a larger CharSequence that does not change as TokenStream.incrementToken() is called. Instead, the offset and character length are updated to reference a new span with respect to the underlying CharSequence.


Method Summary
 CharSequence getCharSequence()
          Provides access to the encapsulated CharSequence.
 int getLength()
          The length is the length in characters of the span referenced by this CharSequenceTermAttribute.
 int getOffset()
          The offset is the character index, with respect to the underlying CharSequence, of the first character in the span referenced by this CharSequenceTermAttribute.
 CharSequence getTermCharSequence()
          Returns the term text as a CharSequence, without needing to construct a String.
 String getTermString()
          Returns the term text as a String.
 void setCharSequence(CharSequence originalCharSequence)
          Sets the encapsulated CharSequence.
 void setLength(int length)
          Assigns the length to the specified value.
 void setOffset(int offset)
          Assigns the offset to the specified value.
 void setTermBuffer(CharSequence seq)
          Assigns the backing CharSequence for this attribute to the specified CharSequence.
 void setTermBuffer(CharSequence seq, int offset, int length)
          Assigns the backing CharSequence for this attribute to the specified CharSequence.
 

Method Detail

getOffset

int getOffset()
The offset is the character index, with respect to the underlying CharSequence, of the first character in the span referenced by this CharSequenceTermAttribute. The offset may point to the end of the underlying CharSequence when length is zero.

Returns:
the current offset

getLength

int getLength()
The length is the length in characters of the span referenced by this CharSequenceTermAttribute.

Returns:
the current length

setOffset

void setOffset(int offset)
Assigns the offset to the specified value.

Parameters:
offset - new value for the offset, which must be at least zero, and less than or equal to the length of the underlying CharSequence
Throws:
IndexOutOfBoundsException - if the specified offset is out of bounds

setLength

void setLength(int length)
Assigns the length to the specified value.

Parameters:
length - new value for the length, which must be at least zero, and at most equal to the length of the underlying CharSequence
Throws:
IndexOutOfBoundsException - if the specified length is out of bounds

setCharSequence

void setCharSequence(CharSequence originalCharSequence)
Sets the encapsulated CharSequence.

Parameters:
originalCharSequence - CharSequence encapsulated by this CharSequenceAttribute

getCharSequence

CharSequence getCharSequence()
Provides access to the encapsulated CharSequence.

Returns:
the underlying CharSequence object

setTermBuffer

void setTermBuffer(CharSequence seq)
Assigns the backing CharSequence for this attribute to the specified CharSequence. The start character index is set to zero, and the end character index is set to the length of the specified CharSequence.

Parameters:
seq - CharSequence that will become the new underlying CharSequence for this attribute.

setTermBuffer

void setTermBuffer(CharSequence seq,
                   int offset,
                   int length)
Assigns the backing CharSequence for this attribute to the specified CharSequence. The start character index is set to specified offset, and the end character index is set to offset plus length.

Parameters:
seq - CharSequence that will become the new underlying CharSequence for this attribute.
offset - character index with respect to the specified CharSequence that will become the new start character index for this attribute.
length - this value will be added to the specified offset value, and the result will become the new end character index for this attribute.

getTermCharSequence

CharSequence getTermCharSequence()
Returns the term text as a CharSequence, without needing to construct a String. This method is preferred over getTermString().

Returns:
CharSequence representing the term text.

getTermString

String getTermString()
Returns the term text as a String. getTermCharSequence() is preferred over this method.

Returns:
String representing the term text.