|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.lucene.util.AttributeImpl org.apache.lucene.analysis.tokenattributes.CharTermAttributeImpl
public class CharTermAttributeImpl
The term text of a Token.
Field Summary |
---|
Fields inherited from class org.apache.lucene.util.AttributeImpl |
---|
enableBackwards |
Constructor Summary | |
---|---|
CharTermAttributeImpl()
|
Method Summary | |
---|---|
CharTermAttribute |
append(char c)
|
CharTermAttribute |
append(CharSequence csq)
|
CharTermAttribute |
append(CharSequence csq,
int start,
int end)
|
CharTermAttribute |
append(CharTermAttribute ta)
Appends the contents of the other CharTermAttribute to this character sequence. |
CharTermAttribute |
append(String s)
Appends the specified String to this character sequence. |
CharTermAttribute |
append(StringBuilder s)
Appends the specified StringBuilder to this character sequence. |
char[] |
buffer()
Returns the internal termBuffer character array which you can then directly alter. |
char |
charAt(int index)
|
void |
clear()
Clears the values in this AttributeImpl and resets it to its default value. |
Object |
clone()
Shallow clone. |
void |
copyBuffer(char[] buffer,
int offset,
int length)
Copies the contents of buffer, starting at offset for length characters, into the termBuffer array. |
void |
copyTo(AttributeImpl target)
Copies the values from this Attribute into the passed-in target attribute. |
boolean |
equals(Object other)
|
int |
hashCode()
|
int |
length()
|
void |
reflectWith(AttributeReflector reflector)
This method is for introspection of attributes, it should simply add the key/values this attribute holds to the given AttributeReflector . |
char[] |
resizeBuffer(int newSize)
Grows the termBuffer to at least size newSize, preserving the existing content. |
char[] |
resizeTermBuffer(int newSize)
Deprecated. |
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. |
void |
setTermBuffer(char[] buffer,
int offset,
int length)
Deprecated. |
void |
setTermBuffer(String buffer)
Deprecated. |
void |
setTermBuffer(String buffer,
int offset,
int length)
Deprecated. |
void |
setTermLength(int length)
Deprecated. |
CharSequence |
subSequence(int start,
int end)
|
String |
term()
Deprecated. |
char[] |
termBuffer()
Deprecated. |
int |
termLength()
Deprecated. |
String |
toString()
Returns solely the term text as specified by the CharSequence interface. |
Methods inherited from class org.apache.lucene.util.AttributeImpl |
---|
reflectAsString |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public CharTermAttributeImpl()
Method Detail |
---|
@Deprecated public String term()
TermAttribute
TermAttribute.termBuffer()
and TermAttribute.termLength()
directly instead. If you really need a
String, use this method, which is nothing more than
a convenience call to new String(token.termBuffer(), 0, token.termLength())
term
in interface TermAttribute
public final void copyBuffer(char[] buffer, int offset, int length)
CharTermAttribute
copyBuffer
in interface CharTermAttribute
buffer
- the buffer to copyoffset
- the index in the buffer of the first character to copylength
- the number of characters to copy@Deprecated public void setTermBuffer(char[] buffer, int offset, int length)
TermAttribute
setTermBuffer
in interface TermAttribute
buffer
- the buffer to copyoffset
- the index in the buffer of the first character to copylength
- the number of characters to copy@Deprecated public void setTermBuffer(String buffer)
TermAttribute
setTermBuffer
in interface TermAttribute
buffer
- the buffer to copy@Deprecated public void setTermBuffer(String buffer, int offset, int length)
TermAttribute
setTermBuffer
in interface TermAttribute
buffer
- the buffer to copyoffset
- the index in the buffer of the first character to copylength
- the number of characters to copypublic final char[] buffer()
CharTermAttribute
CharTermAttribute.resizeBuffer(int)
to increase it. After
altering the buffer be sure to call CharTermAttribute.setLength(int)
to record the number of valid
characters that were placed into the termBuffer.
buffer
in interface CharTermAttribute
@Deprecated public char[] termBuffer()
TermAttribute
TermAttribute.resizeTermBuffer(int)
to increase it. After
altering the buffer be sure to call TermAttribute.setTermLength(int)
to record the number of valid
characters that were placed into the termBuffer.
termBuffer
in interface TermAttribute
public final char[] resizeBuffer(int newSize)
CharTermAttribute
resizeBuffer
in interface CharTermAttribute
newSize
- minimum size of the new termBuffer
@Deprecated public char[] resizeTermBuffer(int newSize)
TermAttribute
TermAttribute.setTermBuffer(char[], int, int)
,
TermAttribute.setTermBuffer(String)
, or
TermAttribute.setTermBuffer(String, int, int)
to optimally combine the resize with the setting of the termBuffer.
resizeTermBuffer
in interface TermAttribute
newSize
- minimum size of the new termBuffer
@Deprecated public int termLength()
TermAttribute
termLength
in interface TermAttribute
public final CharTermAttribute setLength(int length)
CharTermAttribute
CharTermAttribute.resizeBuffer(int)
first.
setLength
in interface CharTermAttribute
length
- the truncated lengthpublic final CharTermAttribute setEmpty()
CharTermAttribute
Appendable
interface.
setEmpty
in interface CharTermAttribute
@Deprecated public void setTermLength(int length)
TermAttribute
TermAttribute.resizeTermBuffer(int)
first.
setTermLength
in interface TermAttribute
length
- the truncated lengthpublic final int length()
length
in interface CharSequence
public final char charAt(int index)
charAt
in interface CharSequence
public final CharSequence subSequence(int start, int end)
subSequence
in interface CharSequence
public final CharTermAttribute append(CharSequence csq)
append
in interface Appendable
append
in interface CharTermAttribute
public final CharTermAttribute append(CharSequence csq, int start, int end)
append
in interface Appendable
append
in interface CharTermAttribute
public final CharTermAttribute append(char c)
append
in interface Appendable
append
in interface CharTermAttribute
public final CharTermAttribute append(String s)
CharTermAttribute
String
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 is null
, then the four
characters "null"
are appended.
append
in interface CharTermAttribute
public final CharTermAttribute append(StringBuilder s)
CharTermAttribute
StringBuilder
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 is null
, then the four
characters "null"
are appended.
append
in interface CharTermAttribute
public final CharTermAttribute append(CharTermAttribute ta)
CharTermAttribute
CharTermAttribute
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 is null
, then the four
characters "null"
are appended.
append
in interface CharTermAttribute
public int hashCode()
hashCode
in class Object
public void clear()
AttributeImpl
clear
in class AttributeImpl
public Object clone()
AttributeImpl
clone
in class AttributeImpl
public boolean equals(Object other)
equals
in class Object
public String toString()
CharSequence
interface.
This method changed the behavior with Lucene 3.1,
before it returned a String representation of the whole
term with all attributes.
This affects especially the
Token
subclass.
toString
in interface CharSequence
toString
in class AttributeImpl
public void reflectWith(AttributeReflector reflector)
AttributeImpl
AttributeReflector
.
The default implementation calls AttributeReflector.reflect(java.lang.Class extends org.apache.lucene.util.Attribute>, java.lang.String, java.lang.Object)
for all
non-static fields from the implementing class, using the field name as key
and the field value as value. The Attribute class is also determined by reflection.
Please note that the default implementation can only handle single-Attribute
implementations.
Custom implementations look like this (e.g. for a combined attribute implementation):
public void reflectWith(AttributeReflector reflector) { reflector.reflect(CharTermAttribute.class, "term", term()); reflector.reflect(PositionIncrementAttribute.class, "positionIncrement", getPositionIncrement()); }
If you implement this method, make sure that for each invocation, the same set of Attribute
interfaces and keys are passed to AttributeReflector.reflect(java.lang.Class extends org.apache.lucene.util.Attribute>, java.lang.String, java.lang.Object)
in the same order, but possibly
different values. So don't automatically exclude e.g. null
properties!
reflectWith
in class AttributeImpl
AttributeImpl.reflectAsString(boolean)
public void copyTo(AttributeImpl target)
AttributeImpl
copyTo
in class AttributeImpl
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |