LUCENE-1616: switch to single setOffset API

git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@769543 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael McCandless 2009-04-28 21:17:38 +00:00
parent e4d9711c97
commit 888a897063
11 changed files with 19 additions and 32 deletions

View File

@ -41,7 +41,7 @@
<property name="name" value="${ant.project.name}"/>
<property name="Name" value="Lucene"/>
<property name="version" value="2.9-dev"/>
<property name="compatibility.tag" value="lucene_2_4_back_compat_tests_20090415"/>
<property name="compatibility.tag" value="lucene_2_4_back_compat_tests_20090428"/>
<property name="spec.version" value="${version}"/>
<property name="year" value="2000-${current.year}"/>
<property name="final.name" value="lucene-${name}-${version}"/>

View File

@ -90,8 +90,7 @@ public abstract class CharTokenizer extends Tokenizer {
}
termAtt.setTermLength(length);
offsetAtt.setStartOffset(start);
offsetAtt.setEndOffset(start+length);
offsetAtt.setOffset(start, start+length);
return true;
}

View File

@ -59,8 +59,7 @@ public class KeywordTokenizer extends Tokenizer {
buffer = termAtt.resizeTermBuffer(1+buffer.length);
}
termAtt.setTermLength(upto);
offsetAtt.setStartOffset(0);
offsetAtt.setEndOffset(upto);
offsetAtt.setOffset(0, upto);
return true;
}
return false;

View File

@ -161,8 +161,7 @@ public class StandardTokenizer extends Tokenizer {
posIncrAtt.setPositionIncrement(posIncr);
scanner.getText(termAtt);
final int start = scanner.yychar();
offsetAtt.setStartOffset(start);
offsetAtt.setEndOffset(start+termAtt.termLength());
offsetAtt.setOffset(start, start+termAtt.termLength());
// This 'if' should be removed in the next release. For now, it converts
// invalid acronyms to HOST. When removed, only the 'else' part should
// remain.

View File

@ -43,11 +43,14 @@ public class OffsetAttribute extends Attribute implements Cloneable, Serializabl
return startOffset;
}
/** Set the starting offset.
@see #startOffset() */
public void setStartOffset(int offset) {
this.startOffset = offset;
/** Set the starting and ending offset.
@see #startOffset() and #endOffset()*/
public void setOffset(int startOffset, int endOffset) {
this.startOffset = startOffset;
this.endOffset = endOffset;
}
/** Returns this Token's ending offset, one greater than the position of the
last character corresponding to this token in the source text. The length
@ -56,11 +59,6 @@ public class OffsetAttribute extends Attribute implements Cloneable, Serializabl
return endOffset;
}
/** Set the ending offset.
@see #endOffset() */
public void setEndOffset(int offset) {
this.endOffset = offset;
}
public void clear() {
startOffset = 0;
@ -92,7 +90,6 @@ public class OffsetAttribute extends Attribute implements Cloneable, Serializabl
public void copyTo(Attribute target) {
OffsetAttribute t = (OffsetAttribute) target;
t.setStartOffset(startOffset);
t.setEndOffset(endOffset);
t.setOffset(startOffset, endOffset);
}
}

View File

@ -53,8 +53,7 @@ final class DocInverterPerThread extends DocFieldConsumerPerThread {
public void reinit(String stringValue, int startOffset, int endOffset) {
termAttribute.setTermBuffer(stringValue);
offsetAttribute.setStartOffset(startOffset);
offsetAttribute.setEndOffset(endOffset);
offsetAttribute.setOffset(startOffset, endOffset);
}
}

View File

@ -51,8 +51,7 @@ public class TestCachingTokenFilter extends LuceneTestCase {
return false;
} else {
termAtt.setTermBuffer(tokens[index++]);
offsetAtt.setStartOffset(0);
offsetAtt.setEndOffset(0);
offsetAtt.setOffset(0,0);
return true;
}
}

View File

@ -137,8 +137,7 @@ public class TestTermVectorsReader extends LuceneTestCase {
else {
final TestToken testToken = tokens[tokenUpto++];
termAtt.setTermBuffer(testToken.text);
offsetAtt.setStartOffset(testToken.startOffset);
offsetAtt.setEndOffset(testToken.endOffset);
offsetAtt.setOffset(testToken.startOffset, testToken.endOffset);
if (tokenUpto > 1) {
posIncrAtt.setPositionIncrement(testToken.pos - tokens[tokenUpto-2].pos);
} else {

View File

@ -163,8 +163,7 @@ public class TestMultiAnalyzer extends LuceneTestCase {
public final boolean incrementToken() throws java.io.IOException {
if (multiToken > 0) {
termAtt.setTermBuffer("multi"+(multiToken+1));
offsetAtt.setStartOffset(prevStartOffset);
offsetAtt.setEndOffset(prevEndOffset);
offsetAtt.setOffset(prevStartOffset, prevEndOffset);
typeAtt.setType(prevType);
posIncrAtt.setPositionIncrement(0);
multiToken--;

View File

@ -85,8 +85,7 @@ public class TestQueryParser extends LuceneTestCase {
if (inPhrase) {
inPhrase = false;
termAtt.setTermBuffer("phrase2");
offsetAtt.setStartOffset(savedStart);
offsetAtt.setEndOffset(savedEnd);
offsetAtt.setOffset(savedStart, savedEnd);
return true;
} else
while (input.incrementToken()) {
@ -95,8 +94,7 @@ public class TestQueryParser extends LuceneTestCase {
savedStart = offsetAtt.startOffset();
savedEnd = offsetAtt.endOffset();
termAtt.setTermBuffer("phrase1");
offsetAtt.setStartOffset(savedStart);
offsetAtt.setEndOffset(savedEnd);
offsetAtt.setOffset(savedStart, savedEnd);
return true;
} else if (!termAtt.term().equals("stop"))
return true;

View File

@ -59,8 +59,7 @@ public class TestPositionIncrement extends LuceneTestCase {
if (i == TOKENS.length)
return false;
termAtt.setTermBuffer(TOKENS[i]);
offsetAtt.setStartOffset(i);
offsetAtt.setEndOffset(i);
offsetAtt.setOffset(i,i);
posIncrAtt.setPositionIncrement(INCREMENTS[i]);
i++;
return true;