## org.apache.lucene.analysis
Class CachingTokenFilter

    java.lang.Object
      org.apache.lucene.analysis.TokenStream
          org.apache.lucene.analysis.TokenFilter
              org.apache.lucene.analysis.CachingTokenFilter

    public class CachingTokenFilter

extends TokenFilter

This class can be used if the Tokens of a TokenStream are intended to be consumed more than once. It caches all Tokens locally in a List. CachingTokenFilter implements the optional method `TokenStream.reset()`, which repositions the stream to the first Token.

Field Summary

Fields inherited from class org.apache.lucene.analysis.TokenFilter
`input`

Constructor Summary
`CachingTokenFilter(TokenStream input)`

Method Summary
`Token` `next()` Returns the next token in the stream, or null at EOS.
`void` `reset()` Resets this stream to the beginning.

Methods inherited from class org.apache.lucene.analysis.TokenFilter
`close`

Methods inherited from class org.apache.lucene.analysis.TokenStream
`next`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### CachingTokenFilter

    public CachingTokenFilter(TokenStream input)

Method Detail

### next

    public Token next()
               throws IOException

  Description copied from class: `TokenStream`
  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 `TokenStream.next(Token)` instead..

  Overrides:
    `next` in class `TokenStream`
  Throws:
    `IOException`

### reset

    public void reset()
               throws IOException

  Description copied from class: `TokenStream`
  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().

  Overrides:
    `reset` in class `TokenStream`
  Throws:
    `IOException`

Copyright © 2000-2008 Apache Software Foundation. All Rights Reserved.