|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.lucene.analysis.Analyzer
org.apache.lucene.analysis.ReusableAnalyzerBase
public abstract class ReusableAnalyzerBase
An convenience subclass of Analyzer that makes it easy to implement
TokenStream reuse.
ReusableAnalyzerBase is a simplification of Analyzer that supports easy reuse
for the most common use-cases. Analyzers such as
PerFieldAnalyzerWrapper that behave differently depending upon the
field name need to subclass Analyzer directly instead.
To prevent consistency problems, this class does not allow subclasses to
extend reusableTokenStream(String, Reader) or
tokenStream(String, Reader) directly. Instead, subclasses must
implement createComponents(String, Reader).
| Nested Class Summary | |
|---|---|
static class |
ReusableAnalyzerBase.TokenStreamComponents
This class encapsulates the outer components of a token stream. |
| Constructor Summary | |
|---|---|
ReusableAnalyzerBase()
|
|
| Method Summary | |
|---|---|
protected abstract ReusableAnalyzerBase.TokenStreamComponents |
createComponents(String fieldName,
Reader aReader)
Creates a new ReusableAnalyzerBase.TokenStreamComponents instance for this analyzer. |
protected Reader |
initReader(Reader reader)
Override this if you want to add a CharFilter chain. |
TokenStream |
reusableTokenStream(String fieldName,
Reader reader)
This method uses createComponents(String, Reader) to obtain an
instance of ReusableAnalyzerBase.TokenStreamComponents. |
TokenStream |
tokenStream(String fieldName,
Reader reader)
This method uses createComponents(String, Reader) to obtain an
instance of ReusableAnalyzerBase.TokenStreamComponents and returns the sink of the
components. |
| Methods inherited from class org.apache.lucene.analysis.Analyzer |
|---|
close, getOffsetGap, getPositionIncrementGap, getPreviousTokenStream, setPreviousTokenStream |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ReusableAnalyzerBase()
| Method Detail |
|---|
protected abstract ReusableAnalyzerBase.TokenStreamComponents createComponents(String fieldName,
Reader aReader)
ReusableAnalyzerBase.TokenStreamComponents instance for this analyzer.
fieldName - the name of the fields content passed to the
ReusableAnalyzerBase.TokenStreamComponents sink as a readeraReader - the reader passed to the Tokenizer constructor
ReusableAnalyzerBase.TokenStreamComponents for this analyzer.
public final TokenStream reusableTokenStream(String fieldName,
Reader reader)
throws IOException
createComponents(String, Reader) to obtain an
instance of ReusableAnalyzerBase.TokenStreamComponents. It returns the sink of the
components and stores the components internally. Subsequent calls to this
method will reuse the previously stored components if and only if the
ReusableAnalyzerBase.TokenStreamComponents.reset(Reader) method returned
true. Otherwise a new instance of
ReusableAnalyzerBase.TokenStreamComponents is created.
reusableTokenStream in class AnalyzerfieldName - the name of the field the created TokenStream is used forreader - the reader the streams source reads from
IOException
public final TokenStream tokenStream(String fieldName,
Reader reader)
createComponents(String, Reader) to obtain an
instance of ReusableAnalyzerBase.TokenStreamComponents and returns the sink of the
components. Each calls to this method will create a new instance of
ReusableAnalyzerBase.TokenStreamComponents. Created TokenStream instances are
never reused.
tokenStream in class AnalyzerfieldName - the name of the field the created TokenStream is used forreader - the reader the streams source reads fromprotected Reader initReader(Reader reader)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||