Class TokenParser

java.lang.Object
org.basex.util.TokenParser

public class TokenParser extends Object

This class can be used to iterate through all codepoints of a token.

Author:
BaseX Team 2005-21, BSD License, Christian Gruen
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final byte[]
    Token to be parsed.
  • Constructor Summary

    Constructors
    Constructor
    Description
    TokenParser(byte[] token)
    Constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    final boolean
    consume(int ch)
    Tries to consume the specified codepoint.
    final boolean
    Checks if the parser will return more codepoints.
    final int
    Returns the current codepoint and advances the cursor.
    final void
    Resets the cursor position.
    final int[]
    Returns an array with all codepoints.
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • token

      protected final byte[] token
      Token to be parsed.
  • Constructor Details

    • TokenParser

      public TokenParser(byte[] token)
      Constructor.
      Parameters:
      token - token
  • Method Details

    • reset

      public final void reset()
      Resets the cursor position.
    • more

      public final boolean more()
      Checks if the parser will return more codepoints.
      Returns:
      result of check
    • next

      public final int next()
      Returns the current codepoint and advances the cursor.
      Returns:
      current codepoint, or -1
    • consume

      public final boolean consume(int ch)
      Tries to consume the specified codepoint.
      Parameters:
      ch - codepoint to be consumed
      Returns:
      indicates if the codepoint was consumed
    • toArray

      public final int[] toArray()
      Returns an array with all codepoints.
      Returns:
      array
    • toString

      public String toString()
      Overrides:
      toString in class Object