Interface CharTermAttribute
-
- All Superinterfaces:
Appendable
,Attribute
,CharSequence
- All Known Implementing Classes:
CharTermAttributeImpl
,PackedTokenAttributeImpl
public interface CharTermAttribute extends Attribute, CharSequence, Appendable
The term text of a Token.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description CharTermAttribute
append(char c)
CharTermAttribute
append(CharSequence csq)
CharTermAttribute
append(CharSequence csq, int start, int end)
CharTermAttribute
append(String s)
Appends the specifiedString
to this character sequence.CharTermAttribute
append(StringBuilder sb)
Appends the specifiedStringBuilder
to this character sequence.CharTermAttribute
append(CharTermAttribute termAtt)
Appends the contents of the otherCharTermAttribute
to this character sequence.char[]
buffer()
Returns the internal termBuffer character array which you can then directly alter.void
copyBuffer(char[] buffer, int offset, int length)
Copies the contents of buffer, starting at offset for length characters, into the termBuffer array.char[]
resizeBuffer(int newSize)
Grows the termBuffer to at least size newSize, preserving the existing content.CharTermAttribute
setEmpty()
Sets the length of the termBuffer to zero.CharTermAttribute
setLength(int length)
Set number of valid characters (length of the term) in the termBuffer array.-
Methods inherited from interface java.lang.CharSequence
charAt, chars, codePoints, length, subSequence, toString
-
-
-
-
Method Detail
-
copyBuffer
void copyBuffer(char[] buffer, int offset, int length)
Copies the contents of buffer, starting at offset for length characters, into the termBuffer array.- Parameters:
buffer
- the buffer to copyoffset
- the index in the buffer of the first character to copylength
- the number of characters to copy
-
buffer
char[] buffer()
Returns the internal termBuffer character array which you can then directly alter. If the array is too small for your token, useresizeBuffer(int)
to increase it. After altering the buffer be sure to callsetLength(int)
to record the number of valid characters that were placed into the termBuffer.NOTE: The returned buffer may be larger than the valid
CharSequence.length()
.
-
resizeBuffer
char[] resizeBuffer(int newSize)
Grows the termBuffer to at least size newSize, preserving the existing content.- Parameters:
newSize
- minimum size of the new termBuffer- Returns:
- newly created termBuffer with
length >= newSize
-
setLength
CharTermAttribute setLength(int length)
Set number of valid characters (length of the term) in the termBuffer array. Use this to truncate the termBuffer or to synchronize with external manipulation of the termBuffer. Note: to grow the size of the array, useresizeBuffer(int)
first.- Parameters:
length
- the truncated length
-
setEmpty
CharTermAttribute setEmpty()
Sets the length of the termBuffer to zero. Use this method before appending contents using theAppendable
interface.
-
append
CharTermAttribute append(CharSequence csq)
- Specified by:
append
in interfaceAppendable
-
append
CharTermAttribute append(CharSequence csq, int start, int end)
- Specified by:
append
in interfaceAppendable
-
append
CharTermAttribute append(char c)
- Specified by:
append
in interfaceAppendable
-
append
CharTermAttribute append(String s)
Appends the specifiedString
to this character sequence.The characters of the
String
argument are appended, in order, increasing the length of this sequence by the length of the argument. If argument isnull
, then the four characters"null"
are appended.
-
append
CharTermAttribute append(StringBuilder sb)
Appends the specifiedStringBuilder
to this character sequence.The characters of the
StringBuilder
argument are appended, in order, increasing the length of this sequence by the length of the argument. If argument isnull
, then the four characters"null"
are appended.
-
append
CharTermAttribute append(CharTermAttribute termAtt)
Appends the contents of the otherCharTermAttribute
to this character sequence.The characters of the
CharTermAttribute
argument are appended, in order, increasing the length of this sequence by the length of the argument. If argument isnull
, then the four characters"null"
are appended.
-
-