TermBufferpublic final class TermBuffer extends Object implements CloneableCopyright 2004 The Apache Software Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License. |
Fields Summary |
---|
private static final char[] | NO_CHARS | private String | field | private char[] | text | private int | textLength | private Term | term |
Methods Summary |
---|
protected java.lang.Object | clone()
TermBuffer clone = null;
try {
clone = (TermBuffer)super.clone();
} catch (CloneNotSupportedException e) {}
clone.text = new char[text.length];
System.arraycopy(text, 0, clone.text, 0, textLength);
return clone;
| private static final int | compareChars(char[] v1, int len1, char[] v2, int len2)
int end = Math.min(len1, len2);
for (int k = 0; k < end; k++) {
char c1 = v1[k];
char c2 = v2[k];
if (c1 != c2) {
return c1 - c2;
}
}
return len1 - len2;
| public final int | compareTo(org.apache.lucene.index.TermBuffer other) // cached
if (field == other.field) // fields are interned
return compareChars(text, textLength, other.text, other.textLength);
else
return field.compareTo(other.field);
| public final void | read(org.apache.lucene.store.IndexInput input, org.apache.lucene.index.FieldInfos fieldInfos)
this.term = null; // invalidate cache
int start = input.readVInt();
int length = input.readVInt();
int totalLength = start + length;
setTextLength(totalLength);
input.readChars(this.text, start, length);
this.field = fieldInfos.fieldName(input.readVInt());
| public void | reset()
this.field = null;
this.textLength = 0;
this.term = null;
| public final void | set(org.apache.lucene.index.Term term)
if (term == null) {
reset();
return;
}
// copy text into the buffer
setTextLength(term.text().length());
term.text().getChars(0, term.text().length(), text, 0);
this.field = term.field();
this.term = term;
| public final void | set(org.apache.lucene.index.TermBuffer other)
setTextLength(other.textLength);
System.arraycopy(other.text, 0, text, 0, textLength);
this.field = other.field;
this.term = other.term;
| private final void | setTextLength(int newLength)
if (text.length < newLength) {
char[] newText = new char[newLength];
System.arraycopy(text, 0, newText, 0, textLength);
text = newText;
}
textLength = newLength;
| public org.apache.lucene.index.Term | toTerm()
if (field == null) // unset
return null;
if (term == null)
term = new Term(field, new String(text, 0, textLength), false);
return term;
|
|