Documentation of 'org.apache.lucene.analysis.TokenStream' Java class
TokenStream
org.apache.lucene.analysis

Class TokenStream

  • Direct Known Subclasses:
    TokenFilter, Tokenizer


    public abstract class TokenStream
    extends java.lang.Object
    A 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; and
    • TokenFilter, a TokenStream whose input is another TokenStream.
    NOTE: subclasses must override at least one of next() or next(Token).
    • Constructor Summary

      Constructors 
      Constructor and Description
      TokenStream() 
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      void close()
      Releases resources associated with this stream.
      Token next()
      Returns the next token in the stream, or null at EOS.
      Token next(Token result)
      Returns the next token in the stream, or null at EOS.
      void reset()
      Resets this stream to the beginning.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • TokenStream

        public TokenStream()
    • 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 calling next(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
        Note that a TokenFilter is 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.IOException
        Resets 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.IOException
        Releases resources associated with this stream.
        Throws:
        java.io.IOException

DataMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.