Class StringCharStream

  • All Implemented Interfaces:
    CharStream

    public class StringCharStream
    extends java.lang.Object
    implements CharStream
    Reads from a String. Notice that none of the overridden methods throw IOException.
    • Field Summary

      • Fields inherited from interface org.codehaus.janino.util.charstream.CharStream

        EOI
    • Constructor Summary

      Constructors 
      Constructor Description
      StringCharStream​(java.lang.String in)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean atEoi()  
      void eoi()  
      int peek()
      Returns the next character on this stream but does not consume it.
      boolean peek​(char c)
      Returns whether the character stream is not at end-of-input and the next character on this stream equals the given character.
      int peek​(java.lang.String chars)
      Checks whether the next character on this stream equals any of the characters of the given String.
      boolean peekRead​(char c)
      If the next character on this stream equals the given character, it is consumed.
      int peekRead​(java.lang.String chars)
      If the next character on this stream is in the given String, it is consumed.
      char read()
      Consumes and returns the next character on this stream.
      void read​(char c)
      Consumes the next character on this stream and verifies that it equals the given character.
      int read​(java.lang.String chars)
      Consumes the nect character and verifies that it matches one of the characters of the given String.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • StringCharStream

        public StringCharStream​(java.lang.String in)
    • Method Detail

      • peek

        public int peek()
        Description copied from interface: CharStream
        Returns the next character on this stream but does not consume it.
        Specified by:
        peek in interface CharStream
        Returns:
        CharStream.EOI This stream is at end-of-input
      • peek

        public boolean peek​(char c)
        Description copied from interface: CharStream
        Returns whether the character stream is not at end-of-input and the next character on this stream equals the given character. Does not consume any characters.
        Specified by:
        peek in interface CharStream
      • peek

        public int peek​(java.lang.String chars)
        Description copied from interface: CharStream
        Checks whether the next character on this stream equals any of the characters of the given String. Does not consume any characters.
        Specified by:
        peek in interface CharStream
        Returns:
        The position of the next character in the given String, or -1
      • read

        public char read()
                  throws java.io.EOFException
        Description copied from interface: CharStream
        Consumes and returns the next character on this stream.
        Specified by:
        read in interface CharStream
        Throws:
        java.io.EOFException - This stream is at end-of-input
      • read

        public void read​(char c)
                  throws java.io.EOFException,
                         UnexpectedCharacterException
        Description copied from interface: CharStream
        Consumes the next character on this stream and verifies that it equals the given character.
        Specified by:
        read in interface CharStream
        Throws:
        java.io.EOFException - This stream is at end-of-input
        UnexpectedCharacterException - The next character does not equal the given character
      • read

        public int read​(java.lang.String chars)
                 throws java.io.EOFException,
                        UnexpectedCharacterException
        Description copied from interface: CharStream
        Consumes the nect character and verifies that it matches one of the characters of the given String.
        Specified by:
        read in interface CharStream
        Returns:
        The position of the next character in the given String
        Throws:
        java.io.EOFException - This stream is at end-of-input
        UnexpectedCharacterException - The next character on this stream is not in the given String
      • peekRead

        public boolean peekRead​(char c)
        Description copied from interface: CharStream
        If the next character on this stream equals the given character, it is consumed.
        Specified by:
        peekRead in interface CharStream
        Returns:
        true iff the next character on this stream equals the given character
      • peekRead

        public int peekRead​(java.lang.String chars)
        Description copied from interface: CharStream
        If the next character on this stream is in the given String, it is consumed.
        Specified by:
        peekRead in interface CharStream
        Returns:
        The position of the next character in the given String, or -1
      • atEoi

        public boolean atEoi()
        Specified by:
        atEoi in interface CharStream
        Returns:
        Whether this stream is at end-of-input
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object