mirror of https://github.com/apache/lucene.git
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:
parent
7dd9b440aa
commit
c339c58f4e
|
@ -305,7 +305,7 @@ public abstract class TokenStream extends AttributeSource {
|
|||
* 3.0.</b>
|
||||
*/
|
||||
public boolean incrementToken() throws IOException {
|
||||
assert !onlyUseNewAPI && tokenWrapper != null;
|
||||
assert tokenWrapper != null;
|
||||
|
||||
final Token token;
|
||||
if (supportedMethods.hasReusableNext) {
|
||||
|
@ -369,7 +369,7 @@ public abstract class TokenStream extends AttributeSource {
|
|||
public Token next(final Token reusableToken) throws IOException {
|
||||
assert reusableToken != null;
|
||||
|
||||
if (onlyUseNewAPI)
|
||||
if (tokenWrapper == null)
|
||||
throw new UnsupportedOperationException("This TokenStream only supports the new Attributes API.");
|
||||
|
||||
if (supportedMethods.hasIncrementToken) {
|
||||
|
@ -393,7 +393,7 @@ public abstract class TokenStream extends AttributeSource {
|
|||
* method with the new {@link AttributeSource} API.
|
||||
*/
|
||||
public Token next() throws IOException {
|
||||
if (onlyUseNewAPI)
|
||||
if (tokenWrapper == null)
|
||||
throw new UnsupportedOperationException("This TokenStream only supports the new Attributes API.");
|
||||
|
||||
if (supportedMethods.hasIncrementToken) {
|
||||
|
|
Loading…
Reference in New Issue