Class 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-23, BSD License, Christian Gruen
    • Field Summary

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

      Constructors 
      Constructor Description
      InputParser​(String input)
      Constructor.
    • Method Summary

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

      • 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 Detail

      • InputParser

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

      • 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