Interface IParser

All Known Implementing Classes:
LineParser, Parser, StringParser

public interface IParser
Character-level parser with lookahead, used by the text readers to peek at, match and consume their input.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
     
    void
     
    void
    consume(int count)
     
    void
     
    void
    consumeWhitespace(char[] exception)
    Skips whitespace at the current position, stopping where the given string (such as a field separator) begins.
    void
    consumeWhitespace(int exception)
    Skips spaces and tabs at the current position, stopping early at the given character.
    void
    Skips whitespace at the current position, stopping where the given string (such as a field separator) begins.
    exception(Throwable exception)
    Wraps the exception in a DataException and adds the parser's buffer and position as properties.
    long
    Returns the number of characters consumed so far (within the current line for LineParser).
    void
    match(char expectedChar)
    Consumes the next character, throwing a DataException if it is not the expected one.
    void
    match(char[] expectedString)
    Consumes the expected string, throwing a DataException at the first character that differs.
    void
    match(char[] expectedString, String failureMessage)
    Consumes the expected string, throwing a DataException prefixed with failureMessage at the first character that differs.
    void
    match(char expectedChar, String failureMessage)
    Consumes the next character, throwing a DataException prefixed with failureMessage if it is not the expected one.
    void
    match(CharSequence expectedString)
    Consumes the expected string, throwing a DataException at the first character that differs.
    void
    match(CharSequence expectedString, String failureMessage)
    Consumes the expected string, throwing a DataException prefixed with failureMessage at the first character that differs.
    matchUntil(char terminatingChar)
    Consumes and returns the text before the terminating character, then consumes the terminator; throws a DataException if the input ends first.
    matchUntil(char terminatingChar, String failureMessage)
    Consumes and returns the text before the terminating character, then consumes the terminator; throws a DataException prefixed with failureMessage if the input ends first.
    Consumes and returns all remaining characters (of the current line for LineParser).
    int
    peek(int index)
    Returns the character at the given 0-based offset ahead without consuming it, or EOF past the end of the input.
    peekSequence(int offset, int length)
    Returns up to length characters starting at the given lookahead offset without consuming them; fewer if the input ends first.
    boolean
    peekString(char[] lookahead)
    Indicates if the upcoming characters match the given string, without consuming them.
    boolean
    Indicates if the upcoming characters match the given string, without consuming them.
    int
    peekStringArray(char[][] lookahead)
    Returns the index of the first string that matches the upcoming characters or -1 if none do, without consuming them.
    int
    peekStringArray(char[][] lookahead, int offset)
    Returns the index of the first string that matches the characters at the given lookahead offset or -1 if none do.
    int
    Returns the index of the first string that matches the upcoming characters or -1 if none do, without consuming them.
    int
    peekStringArray(CharSequence[] lookahead, int offset)
    Returns the index of the first string that matches the characters at the given lookahead offset or -1 if none do.
    boolean
    peekStringOffset(char[] lookahead, int offset)
    Indicates if the characters starting at the given lookahead offset match the given string, without consuming them.
    boolean
    peekStringOffset(CharSequence lookahead, int offset)
    Indicates if the characters starting at the given lookahead offset match the given string, without consuming them.
    int
    Returns the number of consecutive whitespace characters starting at the given 0-based lookahead offset.
    int
    pop()
    Consumes and returns the next character, or EOF at the end of the input.
    boolean
     
  • Field Details

  • Method Details

    • exception

      DataException exception(Throwable exception)
      Wraps the exception in a DataException and adds the parser's buffer and position as properties.
    • ready

      boolean ready() throws IOException
      Throws:
      IOException
    • getColumn

      long getColumn()
      Returns the number of characters consumed so far (within the current line for LineParser).
    • peek

      int peek(int index)
      Returns the character at the given 0-based offset ahead without consuming it, or EOF past the end of the input.
    • peekWhitespaceLength

      int peekWhitespaceLength(int index)
      Returns the number of consecutive whitespace characters starting at the given 0-based lookahead offset.
    • peekSequence

      CharSequence peekSequence(int offset, int length)
      Returns up to length characters starting at the given lookahead offset without consuming them; fewer if the input ends first.
    • peekString

      boolean peekString(CharSequence lookahead)
      Indicates if the upcoming characters match the given string, without consuming them.
    • peekString

      boolean peekString(char[] lookahead)
      Indicates if the upcoming characters match the given string, without consuming them.
    • peekStringOffset

      boolean peekStringOffset(CharSequence lookahead, int offset)
      Indicates if the characters starting at the given lookahead offset match the given string, without consuming them.
    • peekStringOffset

      boolean peekStringOffset(char[] lookahead, int offset)
      Indicates if the characters starting at the given lookahead offset match the given string, without consuming them.
    • peekStringArray

      int peekStringArray(CharSequence... lookahead)
      Returns the index of the first string that matches the upcoming characters or -1 if none do, without consuming them.
    • peekStringArray

      int peekStringArray(char[][] lookahead)
      Returns the index of the first string that matches the upcoming characters or -1 if none do, without consuming them.
    • peekStringArray

      int peekStringArray(CharSequence[] lookahead, int offset)
      Returns the index of the first string that matches the characters at the given lookahead offset or -1 if none do.
    • peekStringArray

      int peekStringArray(char[][] lookahead, int offset)
      Returns the index of the first string that matches the characters at the given lookahead offset or -1 if none do.
    • pop

      int pop()
      Consumes and returns the next character, or EOF at the end of the input.
    • match

      void match(char expectedChar, String failureMessage)
      Consumes the next character, throwing a DataException prefixed with failureMessage if it is not the expected one.
    • match

      void match(char expectedChar)
      Consumes the next character, throwing a DataException if it is not the expected one.
    • match

      void match(CharSequence expectedString, String failureMessage)
      Consumes the expected string, throwing a DataException prefixed with failureMessage at the first character that differs.
    • match

      void match(char[] expectedString, String failureMessage)
      Consumes the expected string, throwing a DataException prefixed with failureMessage at the first character that differs.
    • match

      void match(CharSequence expectedString)
      Consumes the expected string, throwing a DataException at the first character that differs.
    • match

      void match(char[] expectedString)
      Consumes the expected string, throwing a DataException at the first character that differs.
    • matchUntil

      StringBuilder matchUntil(char terminatingChar)
      Consumes and returns the text before the terminating character, then consumes the terminator; throws a DataException if the input ends first.
    • matchUntil

      StringBuilder matchUntil(char terminatingChar, String failureMessage)
      Consumes and returns the text before the terminating character, then consumes the terminator; throws a DataException prefixed with failureMessage if the input ends first.
    • matchUntilEof

      StringBuilder matchUntilEof()
      Consumes and returns all remaining characters (of the current line for LineParser).
    • consume

      void consume()
    • consume

      void consume(int count)
    • consumeWhitespace

      void consumeWhitespace()
    • consumeWhitespace

      void consumeWhitespace(int exception)
      Skips spaces and tabs at the current position, stopping early at the given character.
    • consumeWhitespace

      void consumeWhitespace(CharSequence exception)
      Skips whitespace at the current position, stopping where the given string (such as a field separator) begins.
    • consumeWhitespace

      void consumeWhitespace(char[] exception)
      Skips whitespace at the current position, stopping where the given string (such as a field separator) begins.
    • close

      void close()