Class StringCharStream
- java.lang.Object
-
- org.codehaus.janino.util.charstream.StringCharStream
-
- All Implemented Interfaces:
CharStream
public class StringCharStream extends java.lang.Object implements CharStream
Reads from aString. Notice that none of the overridden methods throwIOException.
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.Stringinprivate intpos-
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 booleanatEoi()voideoi()intpeek()Returns the next character on this stream but does not consume it.booleanpeek(char c)Returns whether the character stream is not at end-of-input and the next character on this stream equals the given character.intpeek(java.lang.String chars)Checks whether the next character on this stream equals any of the characters of the givenString.booleanpeekRead(char c)If the next character on this stream equals the given character, it is consumed.intpeekRead(java.lang.String chars)If the next character on this stream is in the givenString, it is consumed.charread()Consumes and returns the next character on this stream.voidread(char c)Consumes the next character on this stream and verifies that it equals the given character.intread(java.lang.String chars)Consumes the nect character and verifies that it matches one of the characters of the givenString.java.lang.StringtoString()
-
-
-
Method Detail
-
peek
public int peek()
Description copied from interface:CharStreamReturns the next character on this stream but does not consume it.- Specified by:
peekin interfaceCharStream- Returns:
CharStream.EOIThis stream is at end-of-input
-
peek
public boolean peek(char c)
Description copied from interface:CharStreamReturns 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:
peekin interfaceCharStream
-
peek
public int peek(java.lang.String chars)
Description copied from interface:CharStreamChecks whether the next character on this stream equals any of the characters of the givenString. Does not consume any characters.- Specified by:
peekin interfaceCharStream- Returns:
- The position of the next character in the given
String, or -1
-
read
public char read() throws java.io.EOFExceptionDescription copied from interface:CharStreamConsumes and returns the next character on this stream.- Specified by:
readin interfaceCharStream- Throws:
java.io.EOFException- This stream is at end-of-input
-
read
public void read(char c) throws java.io.EOFException, UnexpectedCharacterExceptionDescription copied from interface:CharStreamConsumes the next character on this stream and verifies that it equals the given character.- Specified by:
readin interfaceCharStream- Throws:
java.io.EOFException- This stream is at end-of-inputUnexpectedCharacterException- The next character does not equal the given character
-
read
public int read(java.lang.String chars) throws java.io.EOFException, UnexpectedCharacterExceptionDescription copied from interface:CharStreamConsumes the nect character and verifies that it matches one of the characters of the givenString.- Specified by:
readin interfaceCharStream- Returns:
- The position of the next character in the given
String - Throws:
java.io.EOFException- This stream is at end-of-inputUnexpectedCharacterException- The next character on this stream is not in the givenString
-
peekRead
public boolean peekRead(char c)
Description copied from interface:CharStreamIf the next character on this stream equals the given character, it is consumed.- Specified by:
peekReadin interfaceCharStream- Returns:
trueiff the next character on this stream equals the given character
-
peekRead
public int peekRead(java.lang.String chars)
Description copied from interface:CharStreamIf the next character on this stream is in the givenString, it is consumed.- Specified by:
peekReadin interfaceCharStream- Returns:
- The position of the next character in the given
String, or -1
-
eoi
public void eoi() throws UnexpectedCharacterException- Specified by:
eoiin interfaceCharStream- Throws:
UnexpectedCharacterException- This stream is not at end-of-input
-
atEoi
public boolean atEoi()
- Specified by:
atEoiin interfaceCharStream- Returns:
- Whether this stream is at end-of-input
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-