Class StringCharStream
java.lang.Object
org.codehaus.janino.util.charstream.StringCharStream
- All Implemented Interfaces:
CharStream
Reads from a
String
. Notice that none of the overridden methods throw IOException
.-
Field Summary
FieldsFields inherited from interface org.codehaus.janino.util.charstream.CharStream
EOI
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
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
Checks whether the next character on this stream equals any of the characters of the givenString
.boolean
peekRead
(char c) If the next character on this stream equals the given character, it is consumed.int
If the next character on this stream is in the givenString
, 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
Consumes the nect character and verifies that it matches one of the characters of the givenString
.toString()
-
Field Details
-
in
-
pos
private int pos
-
-
Constructor Details
-
StringCharStream
-
-
Method Details
-
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 interfaceCharStream
- 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 interfaceCharStream
-
peek
Description copied from interface:CharStream
Checks whether the next character on this stream equals any of the characters of the givenString
. Does not consume any characters.- Specified by:
peek
in interfaceCharStream
- Returns:
- The position of the next character in the given
String
, or -1
-
read
Description copied from interface:CharStream
Consumes and returns the next character on this stream.- Specified by:
read
in interfaceCharStream
- Throws:
EOFException
- This stream is at end-of-input
-
read
Description copied from interface:CharStream
Consumes the next character on this stream and verifies that it equals the given character.- Specified by:
read
in interfaceCharStream
- Throws:
EOFException
- This stream is at end-of-inputUnexpectedCharacterException
- The next character does not equal the given character
-
read
Description copied from interface:CharStream
Consumes the nect character and verifies that it matches one of the characters of the givenString
.- Specified by:
read
in interfaceCharStream
- Returns:
- The position of the next character in the given
String
- Throws:
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:CharStream
If the next character on this stream equals the given character, it is consumed.- Specified by:
peekRead
in interfaceCharStream
- Returns:
true
iff the next character on this stream equals the given character
-
peekRead
Description copied from interface:CharStream
If the next character on this stream is in the givenString
, it is consumed.- Specified by:
peekRead
in interfaceCharStream
- Returns:
- The position of the next character in the given
String
, or -1
-
eoi
- Specified by:
eoi
in interfaceCharStream
- Throws:
UnexpectedCharacterException
- This stream is not at end-of-input
-
atEoi
public boolean atEoi()- Specified by:
atEoi
in interfaceCharStream
- Returns:
- Whether this stream is at end-of-input
-
toString
-