|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectewe.util.Errorable
ewe.io.BasicStreamObject
ewe.io.BlockingStreamObject
A BlockingStreamObject is a full implementation of a Stream but where there are no actual non-blocking methods. That is, the nonBlocking() methods will still be there but they actually will block the calling thread.
The only methods you need to override are:
int read(byte[] buffer,int offset,int length) throws IOException;
void write(byte[] buffer,int offset,int length) throws IOException;
boolean closeStream() throws IOException;
boolean flushStream() throws IOException;
| Field Summary |
| Fields inherited from class ewe.io.BasicStreamObject |
closed |
| Fields inherited from class ewe.util.Errorable |
error |
| Constructor Summary | |
BlockingStreamObject()
|
|
| Method Summary | |
boolean |
close()
Closes the stream. |
boolean |
closeStream()
This is non-blocking. |
void |
flush()
Flush all buffered bytes out to the destination. |
boolean |
flushStream()
This is non-blocking. |
boolean |
isOpen()
Returns if the stream is open or not. |
int |
nonBlockingRead(byte[] data,
int offset,
int length)
This is the non-blocking read operation. |
int |
nonBlockingWrite(byte[] data,
int offset,
int length)
This is the non-blocking write operation. |
int |
read(byte[] data,
int offset,
int length)
Reads bytes into a buffer. |
int |
readBytes(byte[] data,
int offset,
int length)
Reads bytes from the stream. |
IOHandle |
readBytes(byte[] data,
int offset,
int length,
IOHandle h,
boolean readAll)
This reads bytes from the stream asynchronously. |
void |
write(byte[] data,
int offset,
int length)
Writes bytes from a buffer to the Stream. |
int |
writeBytes(byte[] data,
int offset,
int length)
Writes bytes to the the stream. |
IOHandle |
writeBytes(byte[] data,
int offset,
int length,
IOHandle h)
This writes bytes to the stream asynchronously. |
| Methods inherited from class ewe.io.BasicStreamObject |
getException, getName, read, read, throwIOException, toInputStream, toOutputStream, toStream, write, write |
| Methods inherited from class ewe.util.Errorable |
returnError, returnError, returnError |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, toString |
| Constructor Detail |
public BlockingStreamObject()
| Method Detail |
public int read(byte[] data,
int offset,
int length)
throws IOException
Stream
offset - The offset index in the destination array to accept the data.length - The maximum number of bytes to read.
IOException - if an error occurs reading the stream.
public void write(byte[] data,
int offset,
int length)
throws IOException
Stream
offset - The start index in the array of the data bytes.length - The number of bytes to write.
IOException - if an error occurs writing to the stream.public final boolean close()
BasicStream
public final void flush()
throws IOException
Stream
IOException - if an error occured.
public final int nonBlockingRead(byte[] data,
int offset,
int length)
BasicStream
data - Destination byte array to hold incoming data.offset - Starting index in buff for incoming data.length - Maximum number of bytes to read - should never be zero.
public final int nonBlockingWrite(byte[] data,
int offset,
int length)
BasicStream
data - Source byte array holding data to be written.offset - Starting index in buff for data to be written.length - Number of bytes to write - should never be zero.
public boolean isOpen()
BasicStream
public boolean flushStream()
throws IOException
BasicStream
IOException
public boolean closeStream()
throws IOException
BasicStream
IOException
public final int readBytes(byte[] data,
int offset,
int length)
Stream
data - Destination byte array to hold incoming data.offset - Starting index in buff for incoming data.length - Maximum number of bytes to read.
public final int writeBytes(byte[] data,
int offset,
int length)
Stream
data - Source byte array holding data to be written.offset - Starting index in buff for data to be written.length - Number of bytes to write.
public final IOHandle readBytes(byte[] data,
int offset,
int length,
IOHandle h,
boolean readAll)
Stream
data - Destination byte array to hold incoming data.offset - Starting index in buff for incoming data.length - Maximum number of bytes to read.h - An existing IOHandle for the operation to use and return. If this is null then a
new one will be created and returned.readAll - Set this to be true if you require the full number of count bytes
to be read.
public final IOHandle writeBytes(byte[] data,
int offset,
int length,
IOHandle h)
Stream
data - Source byte array holding data to be written.offset - Starting index in buff for data to be written.length - Number of bytes to write.h - An existing IOHandle for the operation to use and return. If this is null then a
new one will be created and returned.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||