|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object sleep.bridges.io.IOObject
public class IOObject
The IOObject is the parent class for all IO Source objects that are compatible with Sleep's I/O API.
When an IOObject is created, calling openRead() with the appropriate input stream will initialize this IOObject to work with IO functions that read data. Calling openWrite() has the same effect for print functions. It is the responsibility of the IOObject child class to invoke openRead and openWrite. This is usually done in the constructor.
The pipeline for reading data looks like this:
... <- DataInputStream <- BufferedInputStream <- Original Input Stream
The pipeline for writing data is:
... -> DataOutputStream -> Original Output Stream
Field Summary | |
---|---|
protected java.io.InputStream |
in
|
protected java.io.OutputStream |
out
|
protected java.io.BufferedInputStream |
reader
|
protected java.io.DataInputStream |
readerb
|
protected java.io.InputStreamReader |
readeru
|
protected java.lang.Thread |
thread
|
protected Scalar |
token
|
protected java.io.DataOutputStream |
writerb
|
protected java.io.OutputStreamWriter |
writeru
|
Constructor Summary | |
---|---|
IOObject()
|
Method Summary | |
---|---|
void |
close()
Closes all of the reader's / writer's opened by this IOObject. |
static IOObject |
getConsole(ScriptEnvironment environment)
returns an IOObject that represents stdin/stdout to Sleep's I/O API. |
java.io.BufferedInputStream |
getInputBuffer()
Returns the ascii data reader |
java.io.InputStream |
getInputStream()
Returns the latest hooking point into the input stream |
java.io.OutputStream |
getOutputStream()
Returns the latest hooking point into the output stream |
java.io.DataInputStream |
getReader()
Returns the binary data reader |
java.lang.Object |
getSource()
return the actual source of this IO for scripters to query using HOES |
java.lang.Thread |
getThread()
returns the thread associated with this IOObject |
Scalar |
getToken()
returns a scalar token associated with this IOObject. |
java.io.DataOutputStream |
getWriter()
Returns the binary data writer |
boolean |
isEOF()
Returns true if the reader is closed |
void |
openRead(java.io.InputStream _in)
Initializes a binary reader (a DataInputStream) and a text reader (a BufferedReader) against this input stream. |
void |
openWrite(java.io.OutputStream _out)
Initializes a binary writer (a DataOutputStream) and a text writer (a PrintWriter) against this input stream. |
void |
print(java.lang.String text)
Prints out a line of text with no newline character appended |
void |
printLine(java.lang.String text)
Prints out a line of text with a newline character appended |
java.lang.String |
readCharacter()
Reads in a character of text and returns as a string. |
java.lang.String |
readLine()
Reads in a line of text |
void |
sendEOF()
Closes down the output streams effectively sending an end of file message to the reading end. |
static void |
setConsole(ScriptEnvironment environment,
IOObject object)
sets the stdin/stdout for this script environment. |
void |
setEncoding(java.lang.String name)
set the charset to be used for all unicode aware reads/writes from/to this stream |
void |
setThread(java.lang.Thread t)
set the thread used for this IOObject (currently used to allow a script to wait() on the threads completion) |
void |
setToken(Scalar t)
sets the scalar token associated with this IOObject. |
Scalar |
wait(ScriptEnvironment env,
long timeout)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected java.io.InputStreamReader readeru
protected java.io.DataInputStream readerb
protected java.io.BufferedInputStream reader
protected java.io.InputStream in
protected java.io.OutputStreamWriter writeru
protected java.io.DataOutputStream writerb
protected java.io.OutputStream out
protected java.lang.Thread thread
protected Scalar token
Constructor Detail |
---|
public IOObject()
Method Detail |
---|
public java.lang.Object getSource()
public void setEncoding(java.lang.String name) throws java.io.UnsupportedEncodingException
java.io.UnsupportedEncodingException
public void setThread(java.lang.Thread t)
public java.lang.Thread getThread()
public Scalar wait(ScriptEnvironment env, long timeout)
public Scalar getToken()
public void setToken(Scalar t)
&wait
function.
public static void setConsole(ScriptEnvironment environment, IOObject object)
public static IOObject getConsole(ScriptEnvironment environment)
public java.io.InputStream getInputStream()
public java.io.OutputStream getOutputStream()
public void openRead(java.io.InputStream _in)
public void openWrite(java.io.OutputStream _out)
public void close()
public java.lang.String readLine()
public java.lang.String readCharacter()
public boolean isEOF()
public void sendEOF()
public java.io.BufferedInputStream getInputBuffer()
public java.io.DataInputStream getReader()
public java.io.DataOutputStream getWriter()
public void printLine(java.lang.String text)
public void print(java.lang.String text)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |