java.lang.Object
com.maroontress.clione.impl.ReaderSource
- All Implemented Interfaces:
Source
This source reads characters from upstream reader, counting the line and
column number.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
getChar()
Returns a newSourceChar
object at the current location of this source or EOF.Returns the current location of this source.void
Pushes back the specifiedSourceChar
object.
-
Constructor Details
-
ReaderSource
Creates a new source.- Parameters:
reader
- The reader from which characters will be read.
-
-
Method Details
-
close
- Specified by:
close
in interfaceSource
- Throws:
IOException
- If an I/O error occurs.
-
getLocation
Returns the current location of this source.- Specified by:
getLocation
in interfaceSource
- Returns:
- The current location.
-
getChar
Returns a newSourceChar
object at the current location of this source or EOF.This method does not change the current location either if the return value represents EOF or is the object that has been pushed back. Otherwise, the current location proceeds the next one.
This method may read two or more characters from the upstream
Source
orReader
. It may also replace one or moreSourceChar
objects with anotherSourceChar
object and return it.The return value representing EOF may differ from
SourceChar.STATIC_EOF
. Do not compare it withSourceChar.STATIC_EOF
, useSourceChar.isEof()
method instead.- Specified by:
getChar
in interfaceSource
- Returns:
- The new
SourceChar
object. - Throws:
IOException
- If an I/O error occurs.- See Also:
-
ungetChar
Pushes back the specifiedSourceChar
object.The
SourceChar
object to push back must not represent EOF.This method does not change the current location.
- Specified by:
ungetChar
in interfaceSource
- Parameters:
c
- TheSourceChar
object to push back.
-