diff --git a/src/java/org/apache/lucene/analysis/CharTokenizer.java b/src/java/org/apache/lucene/analysis/CharTokenizer.java index c365c3ef255..a6cf5590d03 100644 --- a/src/java/org/apache/lucene/analysis/CharTokenizer.java +++ b/src/java/org/apache/lucene/analysis/CharTokenizer.java @@ -59,7 +59,7 @@ import java.io.Reader; /** An abstract base class for simple, character-oriented tokenizers.*/ public abstract class CharTokenizer extends Tokenizer { public CharTokenizer(Reader input) { - this.input = input; + super(input); } private int offset = 0, bufferIndex=0, dataLen=0; diff --git a/src/java/org/apache/lucene/analysis/LowerCaseFilter.java b/src/java/org/apache/lucene/analysis/LowerCaseFilter.java index a215cb7a94d..023963ceef8 100644 --- a/src/java/org/apache/lucene/analysis/LowerCaseFilter.java +++ b/src/java/org/apache/lucene/analysis/LowerCaseFilter.java @@ -58,7 +58,7 @@ package org.apache.lucene.analysis; public final class LowerCaseFilter extends TokenFilter { public LowerCaseFilter(TokenStream in) { - input = in; + super(in); } public final Token next() throws java.io.IOException { diff --git a/src/java/org/apache/lucene/analysis/PorterStemFilter.java b/src/java/org/apache/lucene/analysis/PorterStemFilter.java index 09c62d7dd03..1deb4cb6d17 100644 --- a/src/java/org/apache/lucene/analysis/PorterStemFilter.java +++ b/src/java/org/apache/lucene/analysis/PorterStemFilter.java @@ -79,8 +79,8 @@ public final class PorterStemFilter extends TokenFilter { private PorterStemmer stemmer; public PorterStemFilter(TokenStream in) { - stemmer = new PorterStemmer(); - input = in; + super(in); + stemmer = new PorterStemmer(); } /** Returns the next input Token, after being stemmed */ diff --git a/src/java/org/apache/lucene/analysis/SimpleAnalyzer.java b/src/java/org/apache/lucene/analysis/SimpleAnalyzer.java index df40d4bbf3c..9a7c74303b2 100644 --- a/src/java/org/apache/lucene/analysis/SimpleAnalyzer.java +++ b/src/java/org/apache/lucene/analysis/SimpleAnalyzer.java @@ -59,7 +59,7 @@ import java.io.Reader; /** An Analyzer that filters LetterTokenizer with LowerCaseFilter. */ public final class SimpleAnalyzer extends Analyzer { - public final TokenStream tokenStream(String fieldName, Reader reader) { + public TokenStream tokenStream(String fieldName, Reader reader) { return new LowerCaseTokenizer(reader); } } diff --git a/src/java/org/apache/lucene/analysis/StopAnalyzer.java b/src/java/org/apache/lucene/analysis/StopAnalyzer.java index af285d2205f..e9573da981f 100644 --- a/src/java/org/apache/lucene/analysis/StopAnalyzer.java +++ b/src/java/org/apache/lucene/analysis/StopAnalyzer.java @@ -83,7 +83,7 @@ public final class StopAnalyzer extends Analyzer { } /** Filters LowerCaseTokenizer with StopFilter. */ - public final TokenStream tokenStream(String fieldName, Reader reader) { + public TokenStream tokenStream(String fieldName, Reader reader) { return new StopFilter(new LowerCaseTokenizer(reader), stopTable); } } diff --git a/src/java/org/apache/lucene/analysis/StopFilter.java b/src/java/org/apache/lucene/analysis/StopFilter.java index 16fe8851188..15f2a73a974 100644 --- a/src/java/org/apache/lucene/analysis/StopFilter.java +++ b/src/java/org/apache/lucene/analysis/StopFilter.java @@ -66,14 +66,14 @@ public final class StopFilter extends TokenFilter { /** Constructs a filter which removes words from the input TokenStream that are named in the array of words. */ public StopFilter(TokenStream in, String[] stopWords) { - input = in; + super(in); table = makeStopTable(stopWords); } /** Constructs a filter which removes words from the input TokenStream that are named in the Hashtable. */ public StopFilter(TokenStream in, Hashtable stopTable) { - input = in; + super(in); table = stopTable; } diff --git a/src/java/org/apache/lucene/analysis/TokenFilter.java b/src/java/org/apache/lucene/analysis/TokenFilter.java index 7d15e14e363..eba4b885dc7 100644 --- a/src/java/org/apache/lucene/analysis/TokenFilter.java +++ b/src/java/org/apache/lucene/analysis/TokenFilter.java @@ -65,6 +65,15 @@ public abstract class TokenFilter extends TokenStream { /** The source of tokens for this filter. */ protected TokenStream input; + /** Call TokenFilter(TokenStream) instead. + * @deprecated */ + protected TokenFilter() {} + + /** Construct a token stream filtering the given input. */ + protected TokenFilter(TokenStream input) { + this.input = input; + } + /** Close the input TokenStream. */ public void close() throws IOException { input.close(); diff --git a/src/java/org/apache/lucene/analysis/Tokenizer.java b/src/java/org/apache/lucene/analysis/Tokenizer.java index eaae6ec8ddd..cc8bbeeadcf 100644 --- a/src/java/org/apache/lucene/analysis/Tokenizer.java +++ b/src/java/org/apache/lucene/analysis/Tokenizer.java @@ -66,6 +66,14 @@ public abstract class Tokenizer extends TokenStream { /** The text source for this Tokenizer. */ protected Reader input; + /** Construct a tokenizer with null input. */ + protected Tokenizer() {} + + /** Construct a token stream processing the given input. */ + protected Tokenizer(Reader input) { + this.input = input; + } + /** By default, closes the input Reader. */ public void close() throws IOException { input.close(); diff --git a/src/java/org/apache/lucene/analysis/WhitespaceAnalyzer.java b/src/java/org/apache/lucene/analysis/WhitespaceAnalyzer.java index 2d2da7c9607..0bfb73346a7 100644 --- a/src/java/org/apache/lucene/analysis/WhitespaceAnalyzer.java +++ b/src/java/org/apache/lucene/analysis/WhitespaceAnalyzer.java @@ -59,7 +59,7 @@ import java.io.Reader; /** An Analyzer that uses WhitespaceTokenizer. */ public final class WhitespaceAnalyzer extends Analyzer { - public final TokenStream tokenStream(String fieldName, Reader reader) { + public TokenStream tokenStream(String fieldName, Reader reader) { return new WhitespaceTokenizer(reader); } } diff --git a/src/java/org/apache/lucene/analysis/de/GermanStemFilter.java b/src/java/org/apache/lucene/analysis/de/GermanStemFilter.java index 2dd78ebcf1e..e1e678cd24d 100644 --- a/src/java/org/apache/lucene/analysis/de/GermanStemFilter.java +++ b/src/java/org/apache/lucene/analysis/de/GermanStemFilter.java @@ -79,8 +79,8 @@ public final class GermanStemFilter extends TokenFilter public GermanStemFilter( TokenStream in ) { + super(in); stemmer = new GermanStemmer(); - input = in; } /** diff --git a/src/java/org/apache/lucene/analysis/ru/RussianAnalyzer.java b/src/java/org/apache/lucene/analysis/ru/RussianAnalyzer.java index 3ce47c1be08..19ddd59ba7b 100644 --- a/src/java/org/apache/lucene/analysis/ru/RussianAnalyzer.java +++ b/src/java/org/apache/lucene/analysis/ru/RussianAnalyzer.java @@ -280,7 +280,7 @@ public final class RussianAnalyzer extends Analyzer * @return A TokenStream build from a RussianLetterTokenizer filtered with * RussianLowerCaseFilter, StopFilter, and RussianStemFilter */ - public final TokenStream tokenStream(String fieldName, Reader reader) + public TokenStream tokenStream(String fieldName, Reader reader) { TokenStream result = new RussianLetterTokenizer(reader, charset); result = new RussianLowerCaseFilter(result, charset); diff --git a/src/java/org/apache/lucene/analysis/ru/RussianLowerCaseFilter.java b/src/java/org/apache/lucene/analysis/ru/RussianLowerCaseFilter.java index 85318dddc03..1abc3212116 100644 --- a/src/java/org/apache/lucene/analysis/ru/RussianLowerCaseFilter.java +++ b/src/java/org/apache/lucene/analysis/ru/RussianLowerCaseFilter.java @@ -69,7 +69,7 @@ public final class RussianLowerCaseFilter extends TokenFilter public RussianLowerCaseFilter(TokenStream in, char[] charset) { - input = in; + super(in); this.charset = charset; } diff --git a/src/java/org/apache/lucene/analysis/ru/RussianStemFilter.java b/src/java/org/apache/lucene/analysis/ru/RussianStemFilter.java index bd629146923..319e1443669 100644 --- a/src/java/org/apache/lucene/analysis/ru/RussianStemFilter.java +++ b/src/java/org/apache/lucene/analysis/ru/RussianStemFilter.java @@ -77,8 +77,8 @@ public final class RussianStemFilter extends TokenFilter public RussianStemFilter(TokenStream in, char[] charset) { + super(in); stemmer = new RussianStemmer(charset); - input = in; } /** diff --git a/src/java/org/apache/lucene/analysis/standard/StandardAnalyzer.java b/src/java/org/apache/lucene/analysis/standard/StandardAnalyzer.java index 4661a57a78e..659bf7435d5 100644 --- a/src/java/org/apache/lucene/analysis/standard/StandardAnalyzer.java +++ b/src/java/org/apache/lucene/analysis/standard/StandardAnalyzer.java @@ -85,7 +85,7 @@ public class StandardAnalyzer extends Analyzer { /** Constructs a {@link StandardTokenizer} filtered by a {@link StandardFilter}, a {@link LowerCaseFilter} and a {@link StopFilter}. */ - public final TokenStream tokenStream(String fieldName, Reader reader) { + public TokenStream tokenStream(String fieldName, Reader reader) { TokenStream result = new StandardTokenizer(reader); result = new StandardFilter(result); result = new LowerCaseFilter(result); diff --git a/src/java/org/apache/lucene/analysis/standard/StandardFilter.java b/src/java/org/apache/lucene/analysis/standard/StandardFilter.java index 16b5e69f249..ecb354cc68d 100644 --- a/src/java/org/apache/lucene/analysis/standard/StandardFilter.java +++ b/src/java/org/apache/lucene/analysis/standard/StandardFilter.java @@ -64,7 +64,7 @@ public final class StandardFilter extends TokenFilter /** Construct filtering in. */ public StandardFilter(TokenStream in) { - input = in; + super(in); } private static final String APOSTROPHE_TYPE = tokenImage[APOSTROPHE]; diff --git a/src/test/org/apache/lucene/queryParser/TestQueryParser.java b/src/test/org/apache/lucene/queryParser/TestQueryParser.java index 957a8cef9f0..5435e7c2093 100644 --- a/src/test/org/apache/lucene/queryParser/TestQueryParser.java +++ b/src/test/org/apache/lucene/queryParser/TestQueryParser.java @@ -82,7 +82,7 @@ public class TestQueryParser extends TestCase { * token 'phrase' into 'phrase1 phrase2' */ public QPTestFilter(TokenStream in) { - input = in; + super(in); } boolean inPhrase = false;