Class ConditionalTokenFilter
java.lang.Object
org.apache.lucene.util.AttributeSource
org.apache.lucene.analysis.TokenStream
org.apache.lucene.analysis.TokenFilter
org.apache.lucene.analysis.miscellaneous.ConditionalTokenFilter
- All Implemented Interfaces:
Closeable,AutoCloseable,Unwrappable<TokenStream>
- Direct Known Subclasses:
ProtectedTermFilter
Allows skipping TokenFilters based on the current set of attributes.
To use, implement the shouldFilter() method. If it returns true, then calling
incrementToken() will use the wrapped TokenFilter(s) to make changes to the tokenstream.
If it returns false, then the wrapped filter(s) will be skipped.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.lucene.util.AttributeSource
AttributeSource.State -
Field Summary
Fields inherited from class org.apache.lucene.analysis.TokenFilter
inputFields inherited from class org.apache.lucene.analysis.TokenStream
DEFAULT_TOKEN_ATTRIBUTE_FACTORY -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedConditionalTokenFilter(TokenStream input, Function<TokenStream, TokenStream> inputFactory) Create a new ConditionalTokenFilter -
Method Summary
Methods inherited from class org.apache.lucene.analysis.TokenFilter
unwrapMethods inherited from class org.apache.lucene.util.AttributeSource
addAttribute, addAttributeImpl, captureState, clearAttributes, cloneAttributes, copyTo, endAttributes, equals, getAttribute, getAttributeClassesIterator, getAttributeFactory, getAttributeImplsIterator, hasAttribute, hasAttributes, hashCode, reflectAsString, reflectWith, removeAllAttributes, restoreState, toString
-
Constructor Details
-
ConditionalTokenFilter
Create a new ConditionalTokenFilter- Parameters:
input- the input TokenStreaminputFactory- a factory function to create the wrapped filter(s)
-
-
Method Details
-
shouldFilter
Whether or not to execute the wrapped TokenFilter(s) for the current token- Throws:
IOException
-
reset
- Overrides:
resetin classTokenFilter- Throws:
IOException
-
end
- Overrides:
endin classTokenFilter- Throws:
IOException
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classTokenFilter- Throws:
IOException
-
incrementToken
- Specified by:
incrementTokenin classTokenStream- Throws:
IOException
-