## org.apache.lucene.analysis.miscellaneous
Class TrimFilter

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

All Implemented Interfaces:
  Closeable

    public final class TrimFilter

extends TokenFilter

Trims leading and trailing whitespace from Tokens in the stream.

As of Lucene 4.4, this filter does not support updateOffsets=true anymore as it can lead to broken token streams.

Nested Class Summary

Nested classes/interfaces inherited from class org.apache.lucene.util.AttributeSource
`AttributeSource.AttributeFactory, AttributeSource.State`

Field Summary

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

Constructor Summary
`TrimFilter(Version version, TokenStream in)` Create a new `TrimFilter` on top of `in`.
`TrimFilter(Version version, TokenStream in, boolean updateOffsets)` Deprecated. Offset updates are not supported anymore as of Lucene 4.4.

Method Summary
`boolean` `incrementToken()`

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

Methods inherited from class org.apache.lucene.util.AttributeSource
`addAttribute, addAttributeImpl, captureState, clearAttributes, cloneAttributes, copyTo, equals, getAttribute, getAttributeClassesIterator, getAttributeFactory, getAttributeImplsIterator, hasAttribute, hasAttributes, hashCode, reflectAsString, reflectWith, restoreState`

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

Constructor Detail

### TrimFilter

    @Deprecated
    public TrimFilter(Version version,
                                 TokenStream in,
                                 boolean updateOffsets)

  Deprecated. Offset updates are not supported anymore as of Lucene 4.4.

  Create a new `TrimFilter`.

  Parameters:
    `version` - the Lucene match version
    `in` - the stream to consume
    `updateOffsets` - whether to update offsets

### TrimFilter

    public TrimFilter(Version version,
                      TokenStream in)

  Create a new `TrimFilter` on top of `in`.

Method Detail

### incrementToken

    public boolean incrementToken()
                           throws IOException

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

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