Interface CharStream
-
- All Known Implementing Classes:
StringCharStream
public interface CharStream
-
-
Field Summary
Fields Modifier and Type Field Description static int
EOI
A special value for the values returned bypeek()
andpeekRead(char)
indicating end-of-input.
-
Method Summary
All Methods Instance Methods Abstract 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 givenString
.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 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
read(java.lang.String chars)
Consumes the nect character and verifies that it matches one of the characters of the givenString
.
-
-
-
Field Detail
-
EOI
static final int EOI
A special value for the values returned bypeek()
andpeekRead(char)
indicating end-of-input.- See Also:
- Constant Field Values
-
-
Method Detail
-
peek
int peek() throws java.io.IOException
Returns the next character on this stream but does not consume it.- Returns:
EOI
This stream is at end-of-input- Throws:
java.io.IOException
-
peek
boolean peek(char c) throws java.io.IOException
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.- Throws:
java.io.IOException
-
peek
int peek(java.lang.String chars) throws java.io.IOException
Checks whether the next character on this stream equals any of the characters of the givenString
. Does not consume any characters.- Returns:
- The position of the next character in the given
String
, or -1 - Throws:
java.io.IOException
-
read
char read() throws java.io.EOFException, java.io.IOException
Consumes and returns the next character on this stream.- Throws:
java.io.EOFException
- This stream is at end-of-inputjava.io.IOException
-
read
void read(char c) throws java.io.EOFException, UnexpectedCharacterException
Consumes the next character on this stream and verifies that it equals the given character.- Throws:
java.io.EOFException
- This stream is at end-of-inputUnexpectedCharacterException
- The next character does not equal the given character
-
read
int read(java.lang.String chars) throws java.io.EOFException, java.io.IOException, UnexpectedCharacterException
Consumes the nect character and verifies that it matches one of the characters of the givenString
.- 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
java.io.IOException
-
peekRead
boolean peekRead(char c) throws java.io.IOException
If the next character on this stream equals the given character, it is consumed.- Returns:
true
iff the next character on this stream equals the given character- Throws:
java.io.IOException
-
peekRead
int peekRead(java.lang.String chars) throws java.io.IOException
If the next character on this stream is in the givenString
, it is consumed.- Returns:
- The position of the next character in the given
String
, or -1 - Throws:
java.io.IOException
-
atEoi
boolean atEoi() throws java.io.IOException
- Returns:
- Whether this stream is at end-of-input
- Throws:
java.io.IOException
-
eoi
void eoi() throws UnexpectedCharacterException
- Throws:
UnexpectedCharacterException
- This stream is not at end-of-input
-
-