Class ByteArrayStxEtxSerializer
java.lang.Object
org.springframework.integration.ip.tcp.serializer.AbstractByteArraySerializer
org.springframework.integration.ip.tcp.serializer.AbstractPooledBufferByteArraySerializer
org.springframework.integration.ip.tcp.serializer.ByteArrayStxEtxSerializer
- All Implemented Interfaces:
org.springframework.beans.factory.Aware,org.springframework.context.ApplicationEventPublisherAware,org.springframework.core.serializer.Deserializer<byte[]>,org.springframework.core.serializer.Serializer<byte[]>
public class ByteArrayStxEtxSerializer extends AbstractPooledBufferByteArraySerializer
Reads data in an InputStream to a byte[]; data must be prefixed by <stx> and
terminated by <etx> (not included in resulting byte[]).
Writes a byte[] to an OutputStream prefixed by <stx> terminated by <etx>
- Since:
- 2.0
-
Field Summary
Fields Modifier and Type Field Description static intETXstatic ByteArrayStxEtxSerializerINSTANCEA single reusable instance.static intSTXFields inherited from class org.springframework.integration.ip.tcp.serializer.AbstractByteArraySerializer
DEFAULT_MAX_MESSAGE_SIZE, logger -
Constructor Summary
Constructors Constructor Description ByteArrayStxEtxSerializer() -
Method Summary
Modifier and Type Method Description byte[]doDeserialize(java.io.InputStream inputStream, byte[] buffer)Reads the data in the inputStream to a byte[].voidserialize(byte[] bytes, java.io.OutputStream outputStream)Writes the byte[] to the stream, prefixed by an ASCII STX character and terminated with an ASCII ETX character.Methods inherited from class org.springframework.integration.ip.tcp.serializer.AbstractPooledBufferByteArraySerializer
copyToSizedArray, deserialize, setPoolSize, setPoolWaitTimeoutMethods inherited from class org.springframework.integration.ip.tcp.serializer.AbstractByteArraySerializer
checkClosure, getMaxMessageSize, publishEvent, setApplicationEventPublisher, setMaxMessageSizeMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Field Details
-
INSTANCE
A single reusable instance. -
STX
public static final int STX- See Also:
- Constant Field Values
-
ETX
public static final int ETX- See Also:
- Constant Field Values
-
-
Constructor Details
-
ByteArrayStxEtxSerializer
public ByteArrayStxEtxSerializer()
-
-
Method Details
-
doDeserialize
public byte[] doDeserialize(java.io.InputStream inputStream, byte[] buffer) throws java.io.IOExceptionReads the data in the inputStream to a byte[]. Data must be prefixed with an ASCII STX character, and terminated with an ASCII ETX character. Throws aSoftEndOfStreamExceptionif the stream is closed immediately before the STX (i.e. no data is in the process of being read).- Specified by:
doDeserializein classAbstractPooledBufferByteArraySerializer- Parameters:
inputStream- the input stream.buffer- the raw working buffer (maxMessageSize).- Returns:
- the decoded bytes.
- Throws:
java.io.IOException- an io exception.
-
serialize
public void serialize(byte[] bytes, java.io.OutputStream outputStream) throws java.io.IOExceptionWrites the byte[] to the stream, prefixed by an ASCII STX character and terminated with an ASCII ETX character.- Throws:
java.io.IOException
-