onlyUseNewAPI is a static, so non-instance variable. It is used only to initialize TokenStreams and can be changed after. Because of that the tests in incrementToken()/next()/next(Token) should not use it. It is enough to test for tokenWrapper==null to detect a onlyNewAPI TokenStream instance.

git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@807682 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Uwe Schindler 2009-08-25 15:58:00 +00:00
parent 7dd9b440aa
commit c339c58f4e
1 changed files with 3 additions and 3 deletions

View File

@ -305,7 +305,7 @@ public abstract class TokenStream extends AttributeSource {
* 3.0.</b> * 3.0.</b>
*/ */
public boolean incrementToken() throws IOException { public boolean incrementToken() throws IOException {
assert !onlyUseNewAPI && tokenWrapper != null; assert tokenWrapper != null;
final Token token; final Token token;
if (supportedMethods.hasReusableNext) { if (supportedMethods.hasReusableNext) {
@ -369,7 +369,7 @@ public abstract class TokenStream extends AttributeSource {
public Token next(final Token reusableToken) throws IOException { public Token next(final Token reusableToken) throws IOException {
assert reusableToken != null; assert reusableToken != null;
if (onlyUseNewAPI) if (tokenWrapper == null)
throw new UnsupportedOperationException("This TokenStream only supports the new Attributes API."); throw new UnsupportedOperationException("This TokenStream only supports the new Attributes API.");
if (supportedMethods.hasIncrementToken) { if (supportedMethods.hasIncrementToken) {
@ -393,7 +393,7 @@ public abstract class TokenStream extends AttributeSource {
* method with the new {@link AttributeSource} API. * method with the new {@link AttributeSource} API.
*/ */
public Token next() throws IOException { public Token next() throws IOException {
if (onlyUseNewAPI) if (tokenWrapper == null)
throw new UnsupportedOperationException("This TokenStream only supports the new Attributes API."); throw new UnsupportedOperationException("This TokenStream only supports the new Attributes API.");
if (supportedMethods.hasIncrementToken) { if (supportedMethods.hasIncrementToken) {