|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectCompilerIO
public class CompilerIO
This class handles all IO for the compiler application. Several streams are managed by this class.
Field Summary | |
---|---|
private java.io.PrintWriter |
buf
the temporary buffer |
private java.io.PrintWriter |
dst
the current output Writer, either the obj file or the buffer. |
private boolean |
echoing
|
private java.lang.String |
echoPrefix
|
private java.io.PrintWriter |
obj
the output file |
private java.io.BufferedReader |
src
the input file |
private java.io.StringWriter |
sw
the underlying StringWriter used in implementing the buffer |
Constructor Summary | |
---|---|
CompilerIO(java.lang.String srcName,
java.lang.String objX)
Create a new CompilerIO object, using the file name given for the input file, and creating the output file name based on the input file name. |
|
CompilerIO(java.lang.String srcName,
java.lang.String objName,
java.lang.String objX)
Create a new CompilerIO object, using the file names given for the input file and the output file. |
Method Summary | |
---|---|
void |
closeAll()
Close the input, output, and temporary streams. |
void |
closeBuffer()
Close the temporary Writer that we've been using to buffer the output and switch back to the output file as the target of all the emit methods. |
void |
emit(java.lang.String s)
Write a string to the currently active output Writer. |
void |
emitBuffer()
Write the contents of the temporary buffer to the output file. |
void |
emitFile(java.lang.String fileName)
Copy an entire file to the currently active output Writer. |
void |
emitWithPrefix(java.lang.String s)
Write the prefix and then the given string to the currently active output Writer. |
boolean |
getEchoing()
Get the current state of the echoing property. |
java.lang.String |
getEchoPrefix()
Get the echo prefix string. |
static void |
main(java.lang.String[] arg)
Run a simple test of this CompilerIO class. |
void |
openBuffer()
Create a new temporary Writer for buffering and set it to be the target of all the emit methods. |
java.lang.String |
readSrcLine()
Read one line of input from the input file. |
void |
setEchoing(boolean e)
Set the echoing property. |
void |
setEchoPrefix(java.lang.String p)
Set the echo prefix that is written out before each echoed line or other String written with emitWithPrefix. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private java.io.BufferedReader src
private java.io.PrintWriter dst
private java.io.PrintWriter obj
private java.io.PrintWriter buf
private java.io.StringWriter sw
private boolean echoing
private java.lang.String echoPrefix
Constructor Detail |
---|
public CompilerIO(java.lang.String srcName, java.lang.String objX) throws java.io.IOException
srcName
- the name of the input fileobjX
- the extension to use for the output file. Does
not include the dot that separates the name from the extension.
java.io.IOException
- If any input or output exception occurs while
opening the files.public CompilerIO(java.lang.String srcName, java.lang.String objName, java.lang.String objX) throws java.io.IOException
srcName
- the name of the input fileobjName
- the name of the output fileobjX
- the extension to use for the output file. Does
not include the dot that separates the name from the extension.
java.io.IOException
- If any input or output exception occurs while
opening the files.Method Detail |
---|
public java.lang.String readSrcLine() throws java.io.IOException
java.io.IOException
- If an I/O error occurs while readingpublic void emit(java.lang.String s)
s
- The String to write out.public void emitBuffer()
public void emitWithPrefix(java.lang.String s)
s
- The String to write out.public void emitFile(java.lang.String fileName) throws java.io.IOException
fileName
- the name of the file to copy
java.io.IOException
- If an IO error occurspublic void setEchoing(boolean e)
e
- true or false.public boolean getEchoing()
public void setEchoPrefix(java.lang.String p)
p
- the String prefixpublic java.lang.String getEchoPrefix()
public void openBuffer()
public void closeBuffer()
public void closeAll() throws java.io.IOException
java.io.IOException
- If an I/O error occurs while closingpublic static void main(java.lang.String[] arg) throws java.io.IOException
arg
- java.io.IOException
- If an IO error occurs while processing
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |