com.monica.javacom.streams
Class MJCReadableIsAOS

java.lang.Object
  |
  +--java.io.OutputStream
        |
        +--com.monica.javacom.streams.MJCReadableIsAOS
All Implemented Interfaces:
MJCReadable

public class MJCReadableIsAOS
extends java.io.OutputStream
implements MJCReadable

Class for enabling to write to the MCJ layer hierarchy using the conventional OutputStream methods. Objects of this class act as OutputStreams, and they forward the data written on them to MJCReaders.


Constructor Summary
MJCReadableIsAOS()
          Default constructor.
 
Method Summary
 void close()
          This method closes the OuputStream.
 void flush()
          Flushes the read buffer to the MJCReader.
 int getAvailable()
          Returns the number of bytes that can be read from this MJCReader.
 java.lang.String getInput()
          Returns the String that can be read from this MJCReader, this means the data that has been written to it as an OutputStream.
 java.lang.String getReadableName()
          Returns the MJC name of the MJCReadable.
 java.lang.String getReadableVersion()
          Returns the MJC version of the MJCReadable.
 MJCReader getReader()
          Gets the MJCReader, which will query data from this object.
 boolean isReadableConnected()
          Returns wether the it could be read from this object.
 void setReader(MJCReader reader)
          Sets the MJCReader, which will query data from this object.
 void write(byte[] b)
          Writes a byte array to the MJCReader.
 void write(byte[] b, int off, int len)
          Writes a part (specified with start offset and length) of a byte array to the MJCReader.
 void write(int b)
          Writes an int (0...255) to the MJCReader.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MJCReadableIsAOS

public MJCReadableIsAOS()
Default constructor.
Method Detail

getReadableName

public java.lang.String getReadableName()
Returns the MJC name of the MJCReadable.
Specified by:
getReadableName in interface MJCReadable
Returns:
String: the MJC name of the MJCReadable

getReadableVersion

public java.lang.String getReadableVersion()
Returns the MJC version of the MJCReadable.
Specified by:
getReadableVersion in interface MJCReadable
Returns:
String: the MJC version of the MJCReadable

setReader

public void setReader(MJCReader reader)
Sets the MJCReader, which will query data from this object.
Specified by:
setReader in interface MJCReadable
Parameters:
MJCReader - reader: the MJCReader that will query data from this object

getReader

public MJCReader getReader()
Gets the MJCReader, which will query data from this object.
Specified by:
getReader in interface MJCReadable
Returns:
MJCReader: the MJCReader that will query data from this object

getAvailable

public int getAvailable()
Returns the number of bytes that can be read from this MJCReader.
Specified by:
getAvailable in interface MJCReadable
Returns:
int: the number of bytes that can be read

getInput

public java.lang.String getInput()
Returns the String that can be read from this MJCReader, this means the data that has been written to it as an OutputStream.
Specified by:
getInput in interface MJCReadable
Returns:
String: the String that can be read

isReadableConnected

public boolean isReadableConnected()
Returns wether the it could be read from this object.
Specified by:
isReadableConnected in interface MJCReadable
Returns:
boolean: wether it could be read from this object

close

public void close()
           throws java.io.IOException
This method closes the OuputStream. After it, nothing can be written on it. If there is still data in the buffer, a readEvent is called for the MJCReader if specified.
Overrides:
close in class java.io.OutputStream
Throws:
IOException: - if something goes wrong

flush

public void flush()
           throws java.io.IOException
Flushes the read buffer to the MJCReader. As reading in the MJC layer hierarchy is asynchronous, the current thread will be suspended after a readEvent is called at the MJCReader till the getInput method of this object is called.
Overrides:
flush in class java.io.OutputStream
Throws:
IOException: - if something goes wrong

write

public void write(int b)
           throws java.io.IOException
Writes an int (0...255) to the MJCReader. Writing is buffered.
Overrides:
write in class java.io.OutputStream
Parameters:
int - b: the int to be written
Throws:
IOException: - if something goes wrong

write

public void write(byte[] b)
           throws java.io.IOException
Writes a byte array to the MJCReader. Writing is buffered.
Overrides:
write in class java.io.OutputStream
Parameters:
byte[] - b: the byte array to be written
Throws:
IOException: - if something goes wrong

write

public void write(byte[] b,
                  int off,
                  int len)
           throws java.io.IOException
Writes a part (specified with start offset and length) of a byte array to the MJCReader. Writing is buffered.
Overrides:
write in class java.io.OutputStream
Parameters:
byte[] - b: the byte array to be written
int - off: the starting offset of the part
int - len: the length of the part
Throws:
IOException: - if something goes wrong