Top Description Fields Methods
org.codehaus.janino.util.charstream

public Interface CharStream

Known Direct Implementers
org.codehaus.janino.util.charstream.StringCharStream
Imports
java.io.EOFException, .IOException, .Reader

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

Modifier and TypeField and Description
public static final int
EOI

A special value for the values returned by peek() and peekRead(char) indicating end-of-input.

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

Whether this stream is at end-of-input
atEoi
()

public void
eoi()

public int

Returns:

EOI This stream is at end-of-input
peek
()

Returns the next character on this stream but does not consume it.

public 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.

public int

Returns:

The position of the next character in the given String, or -1
peek
(String chars)

Checks whether the next character on this stream equals any of the characters of the given String.

public boolean

Returns:

true iff the next character on this stream equals the given character
peekRead
(char c)

If the next character on this stream equals the given character, it is consumed.

public int

Returns:

The position of the next character in the given String, or -1
peekRead
(String chars)

If the next character on this stream is in the given String, it is consumed.

public char
read()

Consumes and returns the next character on this stream.

public void
read(char c)

Consumes the next character on this stream and verifies that it equals the given character.

public int

Returns:

The position of the next character in the given String
read
(String chars)

Consumes the nect character and verifies that it matches one of the characters of the given String.

Field Detail

EOIback to summary
public static final int EOI

A special value for the values returned by peek() and peekRead(char) indicating end-of-input.

Method Detail

atEoiback to summary
public boolean atEoi() throws IOException
Returns:boolean

Whether this stream is at end-of-input

eoiback to summary
public void eoi() throws UnexpectedCharacterException
Exceptions
UnexpectedCharacterException:
This stream is not at end-of-input
peekback to summary
public int peek() throws IOException

Returns the next character on this stream but does not consume it.

Returns:int

EOI This stream is at end-of-input

peekback to summary
public boolean peek(char c) throws 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.

peekback to summary
public int peek(String chars) throws IOException

Checks whether the next character on this stream equals any of the characters of the given String. Does not consume any characters.

Returns:int

The position of the next character in the given String, or -1

peekReadback to summary
public boolean peekRead(char c) throws IOException

If the next character on this stream equals the given character, it is consumed.

Returns:boolean

true iff the next character on this stream equals the given character

peekReadback to summary
public int peekRead(String chars) throws IOException

If the next character on this stream is in the given String, it is consumed.

Returns:int

The position of the next character in the given String, or -1

readback to summary
public char read() throws EOFException, IOException

Consumes and returns the next character on this stream.

Exceptions
EOFException:
This stream is at end-of-input
readback to summary
public void read(char c) throws EOFException, UnexpectedCharacterException

Consumes the next character on this stream and verifies that it equals the given character.

Exceptions
EOFException:
This stream is at end-of-input
UnexpectedCharacterException:
The next character does not equal the given character
readback to summary
public int read(String chars) throws EOFException, IOException, UnexpectedCharacterException

Consumes the nect character and verifies that it matches one of the characters of the given String.

Returns:int

The position of the next character in the given String

Exceptions
EOFException:
This stream is at end-of-input
UnexpectedCharacterException:
The next character on this stream is not in the given String