Class ByteArrayStxEtxSerializer

All Implemented Interfaces:
Aware, ApplicationEventPublisherAware, Deserializer<byte[]>, 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
Author:
Gary Russell, Artem Bilan
  • Field Details

  • Constructor Details

    • ByteArrayStxEtxSerializer

      public ByteArrayStxEtxSerializer()
  • Method Details

    • doDeserialize

      public byte[] doDeserialize(InputStream inputStream, byte[] buffer) throws IOException
      Reads 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 a SoftEndOfStreamException if the stream is closed immediately before the STX (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, prefixed by an ASCII STX character and terminated with an ASCII ETX character.
      Throws:
      IOException