|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.lucene.util.AttributeImpl
org.apache.lucene.analysis.tokenattributes.TermAttributeImpl
public class TermAttributeImpl
The term text of a Token.
| Constructor Summary | |
|---|---|
TermAttributeImpl()
|
|
| Method Summary | |
|---|---|
void |
clear()
Clears the values in this AttributeImpl and resets it to its default value. |
Object |
clone()
Shallow clone. |
void |
copyTo(AttributeImpl target)
Copies the values from this Attribute into the passed-in target attribute. |
boolean |
equals(Object other)
All values used for computation of AttributeImpl.hashCode()
should be checked here for equality. |
int |
hashCode()
Subclasses must implement this method and should compute a hashCode similar to this: |
char[] |
resizeTermBuffer(int newSize)
Grows the termBuffer to at least size newSize, preserving the existing content. |
void |
setTermBuffer(char[] buffer,
int offset,
int length)
Copies the contents of buffer, starting at offset for length characters, into the termBuffer array. |
void |
setTermBuffer(String buffer)
Copies the contents of buffer into the termBuffer array. |
void |
setTermBuffer(String buffer,
int offset,
int length)
Copies the contents of buffer, starting at offset and continuing for length characters, into the termBuffer array. |
void |
setTermLength(int length)
Set number of valid characters (length of the term) in the termBuffer array. |
String |
term()
Returns the Token's term text. |
char[] |
termBuffer()
Returns the internal termBuffer character array which you can then directly alter. |
int |
termLength()
Return number of valid characters (length of the term) in the termBuffer array. |
String |
toString()
The default implementation of this method accesses all declared fields of this object and prints the values in the following syntax: |
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public TermAttributeImpl()
| Method Detail |
|---|
public String term()
termBuffer() and 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 void setTermBuffer(char[] buffer,
int offset,
int length)
setTermBuffer in interface TermAttributebuffer - the buffer to copyoffset - the index in the buffer of the first character to copylength - the number of characters to copypublic void setTermBuffer(String buffer)
setTermBuffer in interface TermAttributebuffer - the buffer to copy
public void setTermBuffer(String buffer,
int offset,
int length)
setTermBuffer in interface TermAttributebuffer - the buffer to copyoffset - the index in the buffer of the first character to copylength - the number of characters to copypublic char[] termBuffer()
resizeTermBuffer(int) to increase it. After
altering the buffer be sure to call setTermLength(int) to record the number of valid
characters that were placed into the termBuffer.
termBuffer in interface TermAttributepublic char[] resizeTermBuffer(int newSize)
setTermBuffer(char[], int, int),
setTermBuffer(String), or
setTermBuffer(String, int, int)
to optimally combine the resize with the setting of the termBuffer.
resizeTermBuffer in interface TermAttributenewSize - minimum size of the new termBuffer
public int termLength()
termLength in interface TermAttributepublic void setTermLength(int length)
resizeTermBuffer(int) first.
setTermLength in interface TermAttributelength - the truncated lengthpublic int hashCode()
AttributeImpl
public int hashCode() {
int code = startOffset;
code = code * 31 + endOffset;
return code;
}
see also AttributeImpl.equals(Object)
hashCode in class AttributeImplpublic void clear()
AttributeImpl
clear in class AttributeImplpublic Object clone()
AttributeImpl
clone in class AttributeImplpublic boolean equals(Object other)
AttributeImplAttributeImpl.hashCode()
should be checked here for equality.
see also Object.equals(Object)
equals in class AttributeImplpublic String toString()
AttributeImpl
public String toString() {
return "start=" + startOffset + ",end=" + endOffset;
}
This method may be overridden by subclasses.
toString in class AttributeImplpublic 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 | |||||||||