Package org.apache.lucene.analysis.morph

# Class Token

java.lang.Object
org.apache.lucene.analysis.morph.Token

public abstract class Token extends Object
Analyzed token with morphological data.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `protected final int`
  `endOffset`
  `protected final int`
  `length`
  `protected final int`
  `offset`
  `protected int`
  `posIncr`
  `protected int`
  `posLen`
  `protected final int`
  `startOffset`
  `protected final char[]`
  `surfaceForm`
  `protected final TokenType`
  `type`

- ## Constructor Summary

  Constructors
  Modifier
  Constructor
  Description
  `protected`
  `Token(char[] surfaceForm, int offset, int length, int startOffset, int endOffset, TokenType type)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `int`
  `getEndOffset()`
  Get the end offset of the term in the analyzed text.
  `int`
  `getLength()`
  `int`
  `getOffset()`
  `int`
  `getPositionIncrement()`
  `int`
  `getPositionLength()`
  Get the length (in tokens) of this token.
  `int`
  `getStartOffset()`
  Get the start offset of the term in the analyzed text.
  `char[]`
  `getSurfaceForm()`
  `String`
  `getSurfaceFormString()`
  `TokenType`
  `getType()`
  Returns the type of this token
  `void`
  `setPositionIncrement(int posIncr)`
  `void`
  `setPositionLength(int posLen)`
  Set the position length (in tokens) of this token.

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

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### surfaceForm

    protected final char[] surfaceForm

  - ### offset

    protected final int offset

  - ### length

    protected final int length

  - ### startOffset

    protected final int startOffset

  - ### endOffset

    protected final int endOffset

  - ### posIncr

    protected int posIncr

  - ### posLen

    protected int posLen

  - ### type

    protected final TokenType type

- ## Constructor Details

  - ### Token

    protected Token(char[] surfaceForm, int offset, int length, int startOffset, int endOffset, TokenType type)

- ## Method Details

  - ### getSurfaceForm

    public char[] getSurfaceForm()
    Returns:
      surfaceForm

  - ### getOffset

    public int getOffset()
    Returns:
      offset into surfaceForm

  - ### getLength

    public int getLength()
    Returns:
      length of surfaceForm

  - ### getSurfaceFormString

    public String getSurfaceFormString()
    Returns:
      surfaceForm as a String

  - ### getStartOffset

    public int getStartOffset()
    Get the start offset of the term in the analyzed text.

  - ### getEndOffset

    public int getEndOffset()
    Get the end offset of the term in the analyzed text.

  - ### setPositionIncrement

    public void setPositionIncrement(int posIncr)

  - ### getPositionIncrement

    public int getPositionIncrement()

  - ### setPositionLength

    public void setPositionLength(int posLen)
    Set the position length (in tokens) of this token. For normal tokens this is 1; for compound tokens it's > 1.

  - ### getPositionLength

    public int getPositionLength()
    Get the length (in tokens) of this token. For normal tokens this is 1; for compound tokens it's > 1.

  - ### getType

    public TokenType getType()
    Returns the type of this token