org.apache.lucene.analysis.miscellaneous

## Class PrefixAwareTokenFilter

- java.lang.Object
- - org.apache.lucene.util.AttributeSource
  - - org.apache.lucene.analysis.TokenStream
    - - org.apache.lucene.analysis.miscellaneous.PrefixAwareTokenFilter

- All Implemented Interfaces:
    Closeable, AutoCloseable

      public class PrefixAwareTokenFilter
      extends TokenStream

  Joins two token streams and leaves the last token of the first stream available to be used when updating the token values in the second stream based on that token. The default implementation adds last prefix token end offset to the suffix token start and end offsets.

  NOTE: This filter might not behave correctly if used with custom Attributes, i.e. Attributes other than the ones located in org.apache.lucene.analysis.tokenattributes.

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

      `DEFAULT_TOKEN_ATTRIBUTE_FACTORY`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `PrefixAwareTokenFilter(TokenStream prefix, TokenStream suffix)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `close()`
    `void` | `end()`
    `TokenStream` | `getPrefix()`
    `TokenStream` | `getSuffix()`
    `boolean` | `incrementToken()`
    `void` | `reset()`
    `void` | `setPrefix(TokenStream prefix)`
    `void` | `setSuffix(TokenStream suffix)`
    `Token` | `updateSuffixToken(Token suffixToken, Token lastPrefixToken)` The default implementation adds last prefix token end offset to the suffix token start and end offsets.

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

    - #### PrefixAwareTokenFilter

          public PrefixAwareTokenFilter(TokenStream prefix,
                                        TokenStream suffix)

  - ### Method Detail

    - #### incrementToken

          public final boolean incrementToken()
                                       throws IOException

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

    - #### updateSuffixToken

          public Token updateSuffixToken(Token suffixToken,
                                         Token lastPrefixToken)

      The default implementation adds last prefix token end offset to the suffix token start and end offsets.
      Parameters:
        `suffixToken` - a token from the suffix stream
        `lastPrefixToken` - the last token from the prefix stream
      Returns:
        consumer token

    - #### end

          public void end()
                   throws IOException

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

    - #### close

          public void close()
                     throws IOException

      Specified by:
        `close` in interface `Closeable`
      Specified by:
        `close` in interface `AutoCloseable`
      Overrides:
        `close` in class `TokenStream`
      Throws:
        `IOException`

    - #### reset

          public void reset()
                     throws IOException

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

    - #### getPrefix

          public TokenStream getPrefix()

    - #### setPrefix

          public void setPrefix(TokenStream prefix)

    - #### getSuffix

          public TokenStream getSuffix()

    - #### setSuffix

          public void setSuffix(TokenStream suffix)

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