public abstract class AbstractByteProtocol extends Object implements TcpProtocol
Note that the raw write method has changed name from write to
writeByteArray. This is to remove ambiguity from the code. In almost
all cases it is possible to call write(java.io.OutputStream, Object) which
will, via write(java.io.OutputStream, Object), dispatch to
writeByteArray(java.io.OutputStream, byte[]).
| Modifier and Type | Field and Description |
|---|---|
static int |
EOF |
static boolean |
NO_STREAM |
static boolean |
STREAM_OK |
| Constructor and Description |
|---|
AbstractByteProtocol(boolean streamOk) |
| Modifier and Type | Method and Description |
|---|---|
protected int |
copy(InputStream source,
byte[] buffer,
OutputStream dest)
Make a single transfer from source to dest via a byte array buffer
|
protected int |
copy(InputStream source,
byte[] buffer,
OutputStream dest,
int size)
Make a single transfer from source to dest via a byte array buffer
|
ResponseOutputStream |
createResponse(Socket socket)
This lets protocols encode a response stream.
|
protected byte[] |
nullEmptyArray(byte[] data) |
protected int |
safeRead(InputStream is,
byte[] buffer)
Manage non-blocking reads and handle errors
|
protected int |
safeRead(InputStream is,
byte[] buffer,
int size)
Manage non-blocking reads and handle errors
|
void |
write(OutputStream os,
Object data)
Write the specified message to the output stream.
|
protected void |
writeByteArray(OutputStream os,
byte[] data) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitreadpublic static final int EOF
public static final boolean STREAM_OK
public static final boolean NO_STREAM
public void write(OutputStream os, Object data) throws IOException
TcpProtocolwrite in interface TcpProtocolos - the output stream to write todata - the data to writeIOException - if an exception occursprotected void writeByteArray(OutputStream os, byte[] data) throws IOException
IOExceptionprotected int safeRead(InputStream is, byte[] buffer) throws IOException
is - The input stream to read frombuffer - The buffer to read intoIOException - other than socket exceptionsprotected int safeRead(InputStream is, byte[] buffer, int size) throws IOException
is - The input stream to read frombuffer - The buffer to read intosize - The amount of data (upper bound) to readIOException - other than socket exceptionsprotected int copy(InputStream source, byte[] buffer, OutputStream dest) throws IOException
source - Source of databuffer - Buffer array for transferdest - Destination of dataIOException - On non-socket errorprotected int copy(InputStream source, byte[] buffer, OutputStream dest, int size) throws IOException
source - Source of databuffer - Buffer array for transferdest - Destination of datasize - The amount of data (upper bound) to readIOException - On non-socket errorprotected byte[] nullEmptyArray(byte[] data)
public ResponseOutputStream createResponse(Socket socket) throws IOException
TcpProtocolcreateResponse in interface TcpProtocolsocket - The destination to write toIOExceptionCopyright © 2003-2012 MuleSource, Inc.. All Rights Reserved.