public class Source extends Object implements AutoCloseable
The framework class that represents the source program.
Copyright (c) 2009 by Ronald Mak
For instructional purposes only. No warranties.
Constructor and Description |
---|
Source(EventDispatcher eventDispatcher,
Reader reader)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
boolean |
atEof() |
boolean |
atEol() |
void |
close()
Close the source.
|
char |
currentChar()
Return the source character at the current position.
|
String |
getCurrentLine() |
EventDispatcher |
getEventDispatcher() |
int |
getLineNum()
Getter.
|
int |
getPosition()
Getter.
|
char |
nextChar()
Consume the current source character and return the next character.
|
char |
peekAhead(int pos)
Looks ahead 'pos' positions
|
char |
peekChar()
Return the source character following the current character without
consuming the current character.
|
void |
skipToNextLine()
Skip the rest of the current input line by forcing the next read to read
a new line.
|
public static final char EOL
public static final char EOF
public Source(EventDispatcher eventDispatcher, Reader reader)
reader
- the reader for the source programIOException
- if an I/O error occurredpublic EventDispatcher getEventDispatcher()
public int getLineNum()
public int getPosition()
public char currentChar() throws IOException
Exception
- if an error occurred.IOException
public char nextChar() throws IOException
Exception
- if an error occurred.IOException
public char peekChar() throws IOException
Exception
- if an error occurred.IOException
public char peekAhead(int pos) throws IOException
pos
- Excepion
IOException
public boolean atEol() throws IOException
Exception
- if an error occurred.IOException
public boolean atEof() throws IOException
Exception
- if an error occurred.IOException
public void skipToNextLine() throws IOException
IOException
- if an error occurred.public String getCurrentLine()
public void close() throws IOException
close
in interface AutoCloseable
Exception
- if an error occurred.IOException
Copyright © 2010–2015. All rights reserved.