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

      Fields 
      Modifier and Type Field Description
      String file
      File reference.
      int[] input
      Codepoints of normalized input string.
      int length
      Input length.
      int mark
      Marked input position.
      int pos
      Current input position.
    • Constructor Summary

      Constructors 
      Constructor Description
      InputParser​(String input)
      Constructor.
    • Field Detail

      • input

        public final int[] input
        Codepoints of normalized input string.
      • length

        public final int length
        Input 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
      • current

        public final int current()
        Returns the current character.
        Returns:
        current character
      • current

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

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

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

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

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

        protected static boolean quote​(int cp)
        Checks if the specified character is a quote.
        Parameters:
        cp - 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
      • substring

        public final TokenBuilder substring​(int s,
                                            int e)
        Returns an input substring.
        Parameters:
        s - start index
        e - end index
        Returns:
        substring
      • currentAsString

        protected final String currentAsString()
        Returns the current character as string.
        Returns:
        current character
      • info

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