Minor cleanups: added constructors for TokenStream & TokenFilter, made some methods non-final.

git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@149901 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Doug Cutting 2002-12-09 19:02:21 +00:00
parent f8d436784c
commit 3457e879bd
16 changed files with 33 additions and 16 deletions

View File

@ -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;

View File

@ -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 {

View File

@ -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 */

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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;
}

View File

@ -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();

View File

@ -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();

View File

@ -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);
}
}

View File

@ -79,8 +79,8 @@ public final class GermanStemFilter extends TokenFilter
public GermanStemFilter( TokenStream in )
{
super(in);
stemmer = new GermanStemmer();
input = in;
}
/**

View File

@ -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);

View File

@ -69,7 +69,7 @@ public final class RussianLowerCaseFilter extends TokenFilter
public RussianLowerCaseFilter(TokenStream in, char[] charset)
{
input = in;
super(in);
this.charset = charset;
}

View File

@ -77,8 +77,8 @@ public final class RussianStemFilter extends TokenFilter
public RussianStemFilter(TokenStream in, char[] charset)
{
super(in);
stemmer = new RussianStemmer(charset);
input = in;
}
/**

View File

@ -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);

View File

@ -64,7 +64,7 @@ public final class StandardFilter extends TokenFilter
/** Construct filtering <i>in</i>. */
public StandardFilter(TokenStream in) {
input = in;
super(in);
}
private static final String APOSTROPHE_TYPE = tokenImage[APOSTROPHE];

View File

@ -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;