Class PeekingReader

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean peek​(char c)
      Peek ahead in the stream to see if the next character matches this one.
      boolean peek​(char c1, char c2)
      Peek ahead in the stream to see if the next character matches either of these.
      String peek​(int numChars)
      Peek ahead in the stream to look at this number of characters ahead in the reader.
      String peek​(int numChars, boolean peekMultipleLines)
      Peek ahead in the stream to look at this number of characters ahead in the reader.
      boolean peek​(String str)
      Peek ahead in the stream to see if the next characters match this string exactly.
      boolean peekKeywordPart​(ParserContext context)
      Peek ahead in the stream to see if the next character could be a character part of a keyword or identifier.
      char peekNextNonWhitespace()
      Return the next non-whitespace character
      boolean peekNumeric()
      Peek ahead in the stream to see if the next character is numeric.
      boolean peekWhitespace()
      Peek ahead in the stream to see if the next character is whitespace.
      int read()  
      String readKeywordPart​(Delimiter delimiter, ParserContext context)
      Reads all characters in this stream as long as they can be part of a keyword.
      String readNumeric()
      Reads all characters in this stream as long as they can be part of a numeric constant.
      String readUntilExcluding​(char delimiter1, char delimiter2)
      Reads all characters in this stream until any of these delimiting characters has been encountered.
      String readUntilExcluding​(String... strings)
      Reads all characters in this stream until any of the delimiting strings is encountered.
      String readUntilExcludingWithEscape​(char delimiter, boolean selfEscape)
      Reads all characters in this stream until this delimiting character has been encountered, taking into account this escape character for the delimiting character.
      String readUntilExcludingWithEscape​(char delimiter, boolean selfEscape, char escape)
      Reads all characters in this stream until this delimiting character has been encountered, taking into account this escape character for the delimiting character.
      String readUntilIncluding​(char delimiter)
      Reads all characters in this stream until any of this delimiting character has been encountered.
      String readUntilIncluding​(String delimiterSequence)
      Reads all characters in this stream until the delimiting sequence is encountered.
      String readWhitespace()
      Reads all characters in this stream as long as they are whitespace.
      void swallow()
      Swallows the next character.
      void swallow​(int n)
      Swallows the next n characters.
      void swallowUntilExcluding​(char delimiter1, char delimiter2)
      Swallows all characters in this stream until any of these delimiting characters has been encountered.
      void swallowUntilExcluding​(String str)
      Swallows all characters in this stream until this delimiting string has been encountered.
      void swallowUntilIncludingWithEscape​(char delimiter, boolean selfEscape)
      Swallows all characters in this stream until this delimiting character has been encountered, taking into account this escape character for the delimiting character.
      void swallowUntilIncludingWithEscape​(char delimiter, boolean selfEscape, char escape)
      Swallows all characters in this stream until this delimiting character has been encountered, taking into account this escape character for the delimiting character.
    • Method Detail

      • swallow

        public void swallow​(int n)
                     throws IOException
        Swallows the next n characters.
        Throws:
        IOException
      • peek

        public boolean peek​(char c)
                     throws IOException
        Peek ahead in the stream to see if the next character matches this one.
        Parameters:
        c - The character to match.
        Returns:
        true if it does, false if not.
        Throws:
        IOException
      • peek

        public boolean peek​(char c1,
                            char c2)
                     throws IOException
        Peek ahead in the stream to see if the next character matches either of these.
        Parameters:
        c1 - The first character to match.
        c2 - The second character to match.
        Returns:
        true if it does, false if not.
        Throws:
        IOException
      • peekNumeric

        public boolean peekNumeric()
                            throws IOException
        Peek ahead in the stream to see if the next character is numeric.
        Returns:
        true if it is, false if not.
        Throws:
        IOException
      • peekWhitespace

        public boolean peekWhitespace()
                               throws IOException
        Peek ahead in the stream to see if the next character is whitespace.
        Returns:
        true if it is, false if not.
        Throws:
        IOException
      • peekKeywordPart

        public boolean peekKeywordPart​(ParserContext context)
                                throws IOException
        Peek ahead in the stream to see if the next character could be a character part of a keyword or identifier.
        Returns:
        true if it is, false if not.
        Throws:
        IOException
      • peek

        public boolean peek​(String str)
                     throws IOException
        Peek ahead in the stream to see if the next characters match this string exactly.
        Parameters:
        str - The string to match.
        Returns:
        true if they do, false if not.
        Throws:
        IOException
      • peek

        public String peek​(int numChars)
                    throws IOException
        Peek ahead in the stream to look at this number of characters ahead in the reader.
        Parameters:
        numChars - The number of characters.
        Returns:
        The characters.
        Throws:
        IOException
      • peek

        public String peek​(int numChars,
                           boolean peekMultipleLines)
                    throws IOException
        Peek ahead in the stream to look at this number of characters ahead in the reader.
        Parameters:
        numChars - The number of characters.
        peekMultipleLines - Whether the peek should go across lines or not
        Returns:
        The characters.
        Throws:
        IOException
      • peekNextNonWhitespace

        public char peekNextNonWhitespace()
                                   throws IOException
        Return the next non-whitespace character
        Returns:
        The character
        Throws:
        IOException
      • swallowUntilExcluding

        public void swallowUntilExcluding​(char delimiter1,
                                          char delimiter2)
                                   throws IOException
        Swallows all characters in this stream until any of these delimiting characters has been encountered.
        Parameters:
        delimiter1 - The first delimiting character.
        delimiter2 - The second delimiting character.
        Throws:
        IOException
      • readUntilExcluding

        public String readUntilExcluding​(char delimiter1,
                                         char delimiter2)
                                  throws IOException
        Reads all characters in this stream until any of these delimiting characters has been encountered.
        Parameters:
        delimiter1 - The first delimiting character.
        delimiter2 - The second delimiting character.
        Returns:
        The string read, without the delimiting characters.
        Throws:
        IOException
      • swallowUntilIncludingWithEscape

        public void swallowUntilIncludingWithEscape​(char delimiter,
                                                    boolean selfEscape)
                                             throws IOException
        Swallows all characters in this stream until this delimiting character has been encountered, taking into account this escape character for the delimiting character.
        Parameters:
        delimiter - The delimiting character.
        selfEscape - Whether the delimiter can escape itself by being present twice.
        Throws:
        IOException
      • swallowUntilIncludingWithEscape

        public void swallowUntilIncludingWithEscape​(char delimiter,
                                                    boolean selfEscape,
                                                    char escape)
                                             throws IOException
        Swallows all characters in this stream until this delimiting character has been encountered, taking into account this escape character for the delimiting character.
        Parameters:
        delimiter - The delimiting character.
        selfEscape - Whether the delimiter can escape itself by being present twice.
        escape - A separate escape character.
        Throws:
        IOException
      • readUntilExcludingWithEscape

        public String readUntilExcludingWithEscape​(char delimiter,
                                                   boolean selfEscape)
                                            throws IOException
        Reads all characters in this stream until this delimiting character has been encountered, taking into account this escape character for the delimiting character.
        Parameters:
        delimiter - The delimiting character.
        selfEscape - Whether the delimiter can escape itself by being present twice.
        Returns:
        The string read, without the delimiting character.
        Throws:
        IOException
      • readUntilExcludingWithEscape

        public String readUntilExcludingWithEscape​(char delimiter,
                                                   boolean selfEscape,
                                                   char escape)
                                            throws IOException
        Reads all characters in this stream until this delimiting character has been encountered, taking into account this escape character for the delimiting character.
        Parameters:
        delimiter - The delimiting character.
        selfEscape - Whether the delimiter can escape itself by being present twice.
        escape - A separate escape character.
        Returns:
        The string read, without the delimiting character.
        Throws:
        IOException
      • swallowUntilExcluding

        public void swallowUntilExcluding​(String str)
                                   throws IOException
        Swallows all characters in this stream until this delimiting string has been encountered.
        Parameters:
        str - The delimiting string.
        Throws:
        IOException
      • readUntilExcluding

        public String readUntilExcluding​(String... strings)
                                  throws IOException
        Reads all characters in this stream until any of the delimiting strings is encountered.
        Parameters:
        strings - The delimiting strings.
        Returns:
        The string read, without the delimiting string.
        Throws:
        IOException
      • readUntilIncluding

        public String readUntilIncluding​(char delimiter)
                                  throws IOException
        Reads all characters in this stream until any of this delimiting character has been encountered.
        Parameters:
        delimiter - The delimiting character.
        Returns:
        The string read, including the delimiting characters.
        Throws:
        IOException
      • readUntilIncluding

        public String readUntilIncluding​(String delimiterSequence)
                                  throws IOException
        Reads all characters in this stream until the delimiting sequence is encountered.
        Parameters:
        delimiterSequence - The delimiting sequence.
        Returns:
        The string read, including the delimiting characters.
        Throws:
        IOException
      • readKeywordPart

        public String readKeywordPart​(Delimiter delimiter,
                                      ParserContext context)
                               throws IOException
        Reads all characters in this stream as long as they can be part of a keyword.
        Parameters:
        delimiter - The current delimiter.
        Returns:
        The string read.
        Throws:
        IOException
      • readNumeric

        public String readNumeric()
                           throws IOException
        Reads all characters in this stream as long as they can be part of a numeric constant.
        Returns:
        The string read.
        Throws:
        IOException
      • readWhitespace

        public String readWhitespace()
                              throws IOException
        Reads all characters in this stream as long as they are whitespace.
        Returns:
        The string read.
        Throws:
        IOException