Class InputParser

java.lang.Object
org.basex.util.InputParser
Direct Known Subclasses:
JsonParser, QueryParser

public class InputParser extends Object
Abstract class for parsing various inputs, such as database commands or queries.
Author:
BaseX Team 2005-21, BSD License, Christian Gruen
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    File reference.
    final String
    Input to be parsed.
    final int
    Query length.
    int
    Marked input position.
    int
    Current input position.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    final char
    Consumes the next character.
    final boolean
    consume(int ch)
    Peeks forward and consumes the character if it equals the specified one.
    final boolean
    consume(String string)
    Peeks forward and consumes the string if it equals the specified one.
    final char
    Returns the current character.
    final boolean
    curr(int ch)
    Checks if the current character equals the specified one.
    protected final byte[]
    Returns a "found" string, containing the current character.
    final InputInfo
    Creates input information.
    protected final void
    Remembers the current position.
    final boolean
    Checks if more characters are found.
    protected final char
    Returns the next character.
    protected static boolean
    quote(int ch)
    Checks if the specified character is a quote.
    protected final String
    Returns a maximum of 15 remaining characters that have not yet been parsed.

    Methods inherited from class java.lang.Object

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

    • input

      public final String input
      Input to be parsed.
    • length

      public final int length
      Query length.
    • file

      public String file
      File reference.
    • pos

      public int pos
      Current input position.
    • mark

      public int mark
      Marked input position.
  • Constructor Details

    • InputParser

      public InputParser(String input)
      Constructor.
      Parameters:
      input - input
  • Method Details

    • more

      public final boolean more()
      Checks if more characters are found.
      Returns:
      current character
    • curr

      public final char curr()
      Returns the current character.
      Returns:
      current character
    • curr

      public final boolean curr(int ch)
      Checks if the current character equals the specified one.
      Parameters:
      ch - character to be checked
      Returns:
      result of check
    • mark

      protected final void mark()
      Remembers the current position.
    • next

      protected final char next()
      Returns the next character.
      Returns:
      next character, or 0 if string is exhausted
    • consume

      public final char consume()
      Consumes the next character.
      Returns:
      next character, or 0 if string is exhausted
    • consume

      public final boolean consume(int ch)
      Peeks forward and consumes the character if it equals the specified one.
      Parameters:
      ch - character to consume
      Returns:
      true if character was found
    • quote

      protected static boolean quote(int ch)
      Checks if the specified character is a quote.
      Parameters:
      ch - character to be checked
      Returns:
      result
    • consume

      public final boolean consume(String string)
      Peeks forward and consumes the string if it equals the specified one.
      Parameters:
      string - string to consume
      Returns:
      true if string was found
    • found

      protected final byte[] found()
      Returns a "found" string, containing the current character.
      Returns:
      completion
    • remaining

      protected final String remaining()
      Returns a maximum of 15 remaining characters that have not yet been parsed.
      Returns:
      query substring
    • info

      public final InputInfo info()
      Creates input information.
      Returns:
      input information