org.apache.lucene.analysis.util

## Class FilteringTokenFilter

- java.lang.Object
- - org.apache.lucene.util.AttributeSource
  - - org.apache.lucene.analysis.TokenStream
    - - org.apache.lucene.analysis.TokenFilter
      - - org.apache.lucene.analysis.util.FilteringTokenFilter

- All Implemented Interfaces:
    Closeable, AutoCloseable
  Direct Known Subclasses:
    CodepointCountFilter, DateRecognizerFilter, KeepWordFilter, LengthFilter, StopFilter, TypeTokenFilter

      public abstract class FilteringTokenFilter
      extends TokenFilter

  Abstract base class for TokenFilters that may remove tokens. You have to implement `accept()` and return a boolean if the current token should be preserved. `incrementToken()` uses this method to decide if a token should be passed to the caller.

- - ### 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

      `input`

    - ### Fields inherited from class org.apache.lucene.analysis.TokenStream

      `DEFAULT_TOKEN_ATTRIBUTE_FACTORY`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `FilteringTokenFilter(TokenStream in)` Create a new `FilteringTokenFilter`.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected abstract boolean` | `accept()` Override this method and return if the current input token should be returned by `incrementToken()`.
    `void` | `end()`
    `boolean` | `incrementToken()`
    `void` | `reset()`

    - ### Methods inherited from class org.apache.lucene.analysis.TokenFilter

      `close`

    - ### Methods 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`

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### FilteringTokenFilter

          public FilteringTokenFilter(TokenStream in)

      Create a new `FilteringTokenFilter`.
      Parameters:
        `in` - the `TokenStream` to consume

  - ### Method Detail

    - #### accept

          protected abstract boolean accept()
                                     throws IOException

      Override this method and return if the current input token should be returned by `incrementToken()`.
      Throws:
        `IOException`

    - #### incrementToken

          public final boolean incrementToken()
                                       throws IOException

      Specified by:
        `incrementToken` in class `TokenStream`
      Throws:
        `IOException`

    - #### reset

          public void reset()
                     throws IOException

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

    - #### end

          public void end()
                   throws IOException

      Overrides:
        `end` in class `TokenFilter`
      Throws:
        `IOException`

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