Class ByteArrayCrLfSerializer
java.lang.Object
org.springframework.integration.ip.tcp.serializer.AbstractByteArraySerializer
org.springframework.integration.ip.tcp.serializer.AbstractPooledBufferByteArraySerializer
org.springframework.integration.ip.tcp.serializer.ByteArrayCrLfSerializer
- All Implemented Interfaces:
Aware
,ApplicationEventPublisherAware
,Deserializer<byte[]>
,Serializer<byte[]>
public class ByteArrayCrLfSerializer extends AbstractPooledBufferByteArraySerializer
Reads data in an InputStream to a byte[]; data must be terminated by \r\n
(not included in resulting byte[]).
Writes a byte[] to an OutputStream and adds \r\n.
- Since:
- 2.0
- Author:
- Gary Russell, Artem Bilan
-
Field Summary
Fields Modifier and Type Field Description static ByteArrayCrLfSerializer
INSTANCE
A single reusable instance.Fields inherited from class org.springframework.integration.ip.tcp.serializer.AbstractByteArraySerializer
DEFAULT_MAX_MESSAGE_SIZE, logger
-
Constructor Summary
Constructors Constructor Description ByteArrayCrLfSerializer()
-
Method Summary
Modifier and Type Method Description byte[]
doDeserialize(InputStream inputStream, byte[] buffer)
Reads the data in the inputStream to a byte[].int
fillToCrLf(InputStream inputStream, byte[] buffer)
void
serialize(byte[] bytes, OutputStream outputStream)
Writes the byte[] to the stream and appends \r\n.Methods inherited from class org.springframework.integration.ip.tcp.serializer.AbstractPooledBufferByteArraySerializer
copyToSizedArray, deserialize, setPoolSize, setPoolWaitTimeout
Methods inherited from class org.springframework.integration.ip.tcp.serializer.AbstractByteArraySerializer
checkClosure, getMaxMessageSize, publishEvent, setApplicationEventPublisher, setMaxMessageSize
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.core.serializer.Deserializer
deserializeFromByteArray
Methods inherited from interface org.springframework.core.serializer.Serializer
serializeToByteArray
-
Field Details
-
INSTANCE
A single reusable instance.
-
-
Constructor Details
-
ByteArrayCrLfSerializer
public ByteArrayCrLfSerializer()
-
-
Method Details
-
doDeserialize
Reads the data in the inputStream to a byte[]. Data must be terminated by CRLF (\r\n). Throws aSoftEndOfStreamException
if the stream is closed immediately after the \r\n (i.e. no data is in the process of being read).- Specified by:
doDeserialize
in classAbstractPooledBufferByteArraySerializer
- Parameters:
inputStream
- the input stream.buffer
- the raw working buffer (maxMessageSize).- Returns:
- the decoded bytes.
- Throws:
IOException
- an io exception.
-
fillToCrLf
- Throws:
IOException
-
serialize
Writes the byte[] to the stream and appends \r\n.- Throws:
IOException
-