org.apache.lucene.analysis
Class TokenStream
- java.lang.Object
-
- org.apache.lucene.analysis.TokenStream
-
- Direct Known Subclasses:
- TokenFilter, Tokenizer
public abstract class TokenStream extends java.lang.ObjectA TokenStream enumerates the sequence of tokens, either from fields of a document or from query text.This is an abstract class. Concrete subclasses are:
Tokenizer, a TokenStream whose input is a Reader; andTokenFilter, a TokenStream whose input is another TokenStream.
next()ornext(Token).
-
-
Constructor Summary
Constructors Constructor and Description TokenStream()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidclose()Releases resources associated with this stream.Tokennext()Returns the next token in the stream, or null at EOS.Tokennext(Token result)Returns the next token in the stream, or null at EOS.voidreset()Resets this stream to the beginning.
-
-
-
Method Detail
-
next
public Token next() throws java.io.IOException
Returns the next token in the stream, or null at EOS. The returned Token is a "full private copy" (not re-used across calls to next()) but will be slower than callingnext(Token)instead..- Throws:
java.io.IOException
-
next
public Token next(Token result) throws java.io.IOException
Returns the next token in the stream, or null at EOS. When possible, the input Token should be used as the returned Token (this gives fastest tokenization performance), but this is not required and a new Token may be returned. Callers may re-use a single Token instance for successive calls to this method.This implicitly defines a "contract" between consumers (callers of this method) and producers (implementations of this method that are the source for tokens):
- A consumer must fully consume the previously returned Token before calling this method again.
- A producer must call
Token.clear()before setting the fields in it & returning it
TokenFilteris considered a consumer.- Parameters:
result- a Token that may or may not be used to return- Returns:
- next token in the stream or null if end-of-stream was hit
- Throws:
java.io.IOException
-
reset
public void reset() throws java.io.IOExceptionResets this stream to the beginning. This is an optional operation, so subclasses may or may not implement this method. Reset() is not needed for the standard indexing process. However, if the Tokens of a TokenStream are intended to be consumed more than once, it is necessary to implement reset().- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOExceptionReleases resources associated with this stream.- Throws:
java.io.IOException
-
-
DataMelt 3.0 © DataMelt by jWork.ORG