Interface CharStream
- All Known Implementing Classes:
StringCharStream
public interface CharStream
This interface produces a sequence of
chars. These can either be "read", which means basically the same as
Reader.read(); or they can be "peeked", which means that the next character is returned, but not consumed,
i.e. the next call to read() or peek() will return that character again.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intA special value for the values returned bypeek()andpeekRead(char)indicating end-of-input. -
Method Summary
Modifier and TypeMethodDescriptionbooleanatEoi()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.intChecks 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.intIf 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.intConsumes the nect character and verifies that it matches one of the characters of the givenString.
-
Field Details
-
EOI
static final int EOIA special value for the values returned bypeek()andpeekRead(char)indicating end-of-input.- See Also:
-
-
Method Details
-
peek
Returns the next character on this stream but does not consume it.- Returns:
EOIThis stream is at end-of-input- Throws:
IOException
-
peek
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:
IOException
-
peek
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:
IOException
-
read
Consumes and returns the next character on this stream.- Throws:
EOFException- This stream is at end-of-inputIOException
-
read
Consumes the next character on this stream and verifies that it equals the given character.- Throws:
EOFException- This stream is at end-of-inputUnexpectedCharacterException- The next character does not equal the given character
-
read
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:
EOFException- This stream is at end-of-inputUnexpectedCharacterException- The next character on this stream is not in the givenStringIOException
-
peekRead
If the next character on this stream equals the given character, it is consumed.- Returns:
trueiff the next character on this stream equals the given character- Throws:
IOException
-
peekRead
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:
IOException
-
atEoi
- Returns:
- Whether this stream is at end-of-input
- Throws:
IOException
-
eoi
- Throws:
UnexpectedCharacterException- This stream is not at end-of-input
-