Class ByteArraySingleTerminatorSerializer

All Implemented Interfaces:
Aware, ApplicationEventPublisherAware, Deserializer<byte[]>, Serializer<byte[]>
Direct Known Subclasses:
ByteArrayLfSerializer

public class ByteArraySingleTerminatorSerializer extends AbstractPooledBufferByteArraySerializer
Reads data in an InputStream to a byte[]; data must be terminated by a single byte (not included in resulting byte[]). Writes a byte[] to an OutputStream and adds the terminator.
Since:
2.2
Author:
Gary Russell, Artem Bilan
  • Constructor Details

    • ByteArraySingleTerminatorSerializer

      public ByteArraySingleTerminatorSerializer(byte delimiter)
  • Method Details

    • doDeserialize

      protected byte[] doDeserialize(InputStream inputStream, byte[] buffer) throws IOException
      Reads the data in the inputStream to a byte[]. Data must be terminated by a single byte. Throws a SoftEndOfStreamException if the stream is closed immediately after the terminator (i.e. no data is in the process of being read).
      Specified by:
      doDeserialize in class AbstractPooledBufferByteArraySerializer
      Parameters:
      inputStream - the input stream.
      buffer - the raw working buffer (maxMessageSize).
      Returns:
      the decoded bytes.
      Throws:
      IOException - an io exception.
    • serialize

      public void serialize(byte[] bytes, OutputStream outputStream) throws IOException
      Writes the byte[] to the stream and appends the terminator.
      Throws:
      IOException