|
Spring Integration | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.integration.ip.tcp.serializer.AbstractByteArraySerializer org.springframework.integration.ip.tcp.serializer.ByteArrayLengthHeaderSerializer
public class ByteArrayLengthHeaderSerializer
Reads data in an InputStream to a byte[]; data must be preceded by
a binary length (network byte order, not included in resulting byte[]).
Writes a byte[] to an OutputStream after a binary length.
The length field contains the length of data following the length
field. (network byte order).
The default length field is a 4 byte signed integer. During deserialization,
negative values will be rejected.
Other options are an unsigned byte, and unsigned short.
For other header formats, override readHeader(InputStream)
and
writeHeader(OutputStream, int)
.
Field Summary | |
---|---|
static int |
HEADER_SIZE_INT
Default length-header field, allows for data up to 2**31-1 bytes. |
static int |
HEADER_SIZE_UNSIGNED_BYTE
A single unsigned byte, for data up to 255 bytes. |
static int |
HEADER_SIZE_UNSIGNED_SHORT
An unsigned short, for data up to 2**16 bytes. |
Fields inherited from class org.springframework.integration.ip.tcp.serializer.AbstractByteArraySerializer |
---|
maxMessageSize |
Constructor Summary | |
---|---|
ByteArrayLengthHeaderSerializer()
Constructs the serializer using HEADER_SIZE_INT |
|
ByteArrayLengthHeaderSerializer(int headerSize)
Constructs the serializer using the supplied header size. |
Method Summary | |
---|---|
byte[] |
deserialize(java.io.InputStream inputStream)
Reads the header from the stream and then reads the provided length from the stream and returns the data in a byte[]. |
protected int |
read(java.io.InputStream inputStream,
byte[] buffer,
boolean header)
Reads data from the socket and puts the data in buffer. |
protected int |
readHeader(java.io.InputStream inputStream)
Reads the header and returns the length of the data part. |
void |
serialize(byte[] bytes,
java.io.OutputStream outputStream)
Writes the byte[] to the output stream, preceded by a 4 byte length in network byte order (big endian). |
protected void |
writeHeader(java.io.OutputStream outputStream,
int length)
Writes the header, according to the header format. |
Methods inherited from class org.springframework.integration.ip.tcp.serializer.AbstractByteArraySerializer |
---|
checkClosure, getMaxMessageSize, setMaxMessageSize |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int HEADER_SIZE_INT
public static final int HEADER_SIZE_UNSIGNED_BYTE
public static final int HEADER_SIZE_UNSIGNED_SHORT
Constructor Detail |
---|
public ByteArrayLengthHeaderSerializer()
HEADER_SIZE_INT
public ByteArrayLengthHeaderSerializer(int headerSize)
HEADER_SIZE_INT
(default),
HEADER_SIZE_UNSIGNED_BYTE
and HEADER_SIZE_UNSIGNED_SHORT
headerSize
- Method Detail |
---|
public byte[] deserialize(java.io.InputStream inputStream) throws java.io.IOException
SoftEndOfStreamException
if the stream
is closed between messages.
java.io.IOException
public void serialize(byte[] bytes, java.io.OutputStream outputStream) throws java.io.IOException
java.io.IOException
protected int read(java.io.InputStream inputStream, byte[] buffer, boolean header) throws java.io.IOException
buffer
- header
- true if we are reading the header
java.io.IOException
protected void writeHeader(java.io.OutputStream outputStream, int length) throws java.io.IOException
outputStream
- length
-
java.io.IOException
protected int readHeader(java.io.InputStream inputStream) throws java.io.IOException
inputStream
-
IOException,
- SoftEndOfStreamException
if socket closes
before any length data read.
java.io.IOException
|
Spring Integration | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |