org.apache.lucene.analysis.util

## Class CharTokenizer

- java.lang.Object
- - org.apache.lucene.util.AttributeSource
  - - org.apache.lucene.analysis.TokenStream
    - - org.apache.lucene.analysis.Tokenizer
      - - org.apache.lucene.analysis.util.CharTokenizer

- All Implemented Interfaces:
    Closeable, AutoCloseable
  Direct Known Subclasses:
    LetterTokenizer, UnicodeWhitespaceTokenizer, WhitespaceTokenizer

      public abstract class CharTokenizer
      extends Tokenizer

  An abstract base class for simple, character-oriented tokenizers.

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

      `input`

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

      `DEFAULT_TOKEN_ATTRIBUTE_FACTORY`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `CharTokenizer()` Creates a new `CharTokenizer` instance
    `CharTokenizer(AttributeFactory factory)` Creates a new `CharTokenizer` instance

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `end()`
    `boolean` | `incrementToken()`
    `protected abstract boolean` | `isTokenChar(int c)` Returns true iff a codepoint should be included in a token.
    `protected int` | `normalize(int c)` Called on each token character to normalize it before it is added to the token.
    `void` | `reset()`

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

      `close, correctOffset, setReader`

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

    - #### CharTokenizer

          public CharTokenizer()

      Creates a new `CharTokenizer` instance

    - #### CharTokenizer

          public CharTokenizer(AttributeFactory factory)

      Creates a new `CharTokenizer` instance
      Parameters:
        `factory` - the attribute factory to use for this `Tokenizer`

  - ### Method Detail

    - #### isTokenChar

          protected abstract boolean isTokenChar(int c)

      Returns true iff a codepoint should be included in a token. This tokenizer generates as tokens adjacent sequences of codepoints which satisfy this predicate. Codepoints for which this is false are used to define token boundaries and are not included in tokens.

    - #### normalize

          protected int normalize(int c)

      Called on each token character to normalize it before it is added to the token. The default implementation does nothing. Subclasses may use this to, e.g., lowercase tokens.

    - #### incrementToken

          public final boolean incrementToken()
                                       throws IOException

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

    - #### end

          public final void end()
                         throws IOException

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

    - #### reset

          public void reset()
                     throws IOException

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

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