ProtectedTermFilter (Lucene 10.5.0 common API)
Description: declaration: package: org.apache.lucene.analysis.miscellaneous, class: ProtectedTermFilter

Package org.apache.lucene.analysis.miscellaneous

# Class ProtectedTermFilter

java.lang.Object
org.apache.lucene.util.AttributeSource
org.apache.lucene.analysis.TokenStream
org.apache.lucene.analysis.TokenFilter
org.apache.lucene.analysis.miscellaneous.ConditionalTokenFilter
org.apache.lucene.analysis.miscellaneous.ProtectedTermFilter

All Implemented Interfaces:
  `Closeable`, `AutoCloseable`, `Unwrappable<TokenStream>`

public class ProtectedTermFilter extends ConditionalTokenFilter
A ConditionalTokenFilter that only applies its wrapped filters to tokens that are not contained in a protected set.

- ## 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
  Description
  `ProtectedTermFilter(CharArraySet protectedTerms, TokenStream input, Function<TokenStream,TokenStream> inputFactory)`
  Creates a new ProtectedTermFilter

- ## Method Summary

  Modifier and Type
  Method
  Description
  `protected boolean`
  `shouldFilter()`
  Whether or not to execute the wrapped TokenFilter(s) for the current token

  ### Methods inherited from class org.apache.lucene.analysis.miscellaneous.ConditionalTokenFilter

  `close, end, incrementToken, reset`

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

  `unwrap`

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

  - ### ProtectedTermFilter

    public ProtectedTermFilter(CharArraySet protectedTerms, TokenStream input, Function<TokenStream,TokenStream> inputFactory)
    Creates a new ProtectedTermFilter
    Parameters:
      `protectedTerms` - the set of terms to skip the wrapped filters for
      `input` - the input TokenStream
      `inputFactory` - a factory function to create the wrapped filter(s)

- ## Method Details

  - ### shouldFilter

    protected boolean shouldFilter()
    Description copied from class: `ConditionalTokenFilter`
    Whether or not to execute the wrapped TokenFilter(s) for the current token
    Specified by:
      `shouldFilter` in class `ConditionalTokenFilter`