Class ByteArraySequence

java.lang.Object
org.refcodes.serial.ByteArraySequence
All Implemented Interfaces:
Iterable<Byte>, org.refcodes.mixin.Clearable, org.refcodes.mixin.InputStreamAccessor, org.refcodes.mixin.LengthAccessor, org.refcodes.mixin.OutputStreamAccessor, Sequence

public class ByteArraySequence extends Object implements Sequence
A ByteArraySequence implements the Sequence interface by using chunks of byte arrays, therewith reducing array copy operations when working with byte fields. A ByteArraySequence is a one dimensional representation of a byte array of byte arrays (a two dimensional byte array). Each byte array inside the byte array (of byte arrays) is called a chunk. Using this technique we easily can create our Sequence instances consisting of many chunks while reducing the copying and concatenating efforts (and buffer allocations), providing for a low memory footprint.
  • Constructor Details

    • ByteArraySequence

      public ByteArraySequence()
      Constructs an empty ByteArraySequence.
    • ByteArraySequence

      public ByteArraySequence(byte aByte)
      Constructs a ByteArraySequence from the provided byte.
      Parameters:
      aByte - The only byte out of which the ByteArraySequence consists.
    • ByteArraySequence

      public ByteArraySequence(byte... aBytes)
      Constructs a ByteArraySequence from the provided byte chunk.
      Parameters:
      aBytes - The only chunk out of which the ByteArraySequence consists.
    • ByteArraySequence

      public ByteArraySequence(byte[]... aBytes)
      Constructs a ByteArraySequence from the provided byte chunks.
      Parameters:
      aBytes - The byte chunks (a two dimensional byte array) out of which the ByteArraySequence consists.
    • ByteArraySequence

      public ByteArraySequence(byte[] aBytes, int aOffset, int aLength)
      Constructs a ByteArraySequence from the provided byte chunk.
      Parameters:
      aBytes - The only chunk out of which the ByteArraySequence consists.
      aOffset - The offset from where to take the chunk data.
      aLength - The number of bytes to take, beginning at the provided offset.
    • ByteArraySequence

      public ByteArraySequence(byte[][]... aBytes)
      Constructs a ByteArraySequence from the provided byte chunks.
      Parameters:
      aBytes - The byte chunks (many two dimensional byte arrays) out of which the ByteArraySequence consists.
    • ByteArraySequence

      public ByteArraySequence(InputStream aInputStream) throws IOException
      Constructs the ByteArraySequence from the content of the provided InputStream.
      Parameters:
      aInputStream - The InputStream from which's data to construct this instance.
      Throws:
      IOException - thrown in case reading from the InputStream caused problems.
    • ByteArraySequence

      public ByteArraySequence(int aLength)
      Constructs a ByteArraySequence of the given initial length.
      Parameters:
      aLength - The initial length of the Sequence.
    • ByteArraySequence

      public ByteArraySequence(Sequence aSequence)
      Creates a new Sequence with the bytes from given Sequence.
      Parameters:
      aSequence - The Sequence from which to take the data.
  • Method Details

    • append

      public void append(byte[] aBytes, int aOffset, int aLength)
      Appends the given bytes to the end of this Sequence. Beware: This Sequence is modified! If you do not wish to modify this Sequence, please use Sequence.toAppend(byte[], int, int).
      Specified by:
      append in interface Sequence
      Parameters:
      aBytes - The bytes to be appended.
      aOffset - The offset from where to start collecting the bytes.
      aLength - The number of bytes to be appended.
    • append

      public void append(Sequence aSequence)
      Appends the given Sequence to the end of this Sequence. Beware: This Sequence is modified! If you do not wish to modify this Sequence, please use Sequence.toAppend(Sequence).
      Specified by:
      append in interface Sequence
      Parameters:
      aSequence - The Sequence to be appended.
    • empty

      public void empty()
      Empties the Sequence to end up being of length 0.
      Specified by:
      empty in interface Sequence
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • getByteAt

      public byte getByteAt(int aIndex) throws IndexOutOfBoundsException
      Returns the byte at the given index in the Sequence.
      Specified by:
      getByteAt in interface Sequence
      Parameters:
      aIndex - The index of the byte to retrieve.
      Returns:
      The byte being retrieved.
      Throws:
      IndexOutOfBoundsException - thrown in case the given index is out of bounds.
    • getLength

      public int getLength()
      Specified by:
      getLength in interface org.refcodes.mixin.LengthAccessor
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • iterator

      public Iterator<Byte> iterator()
      Specified by:
      iterator in interface Iterable<Byte>
    • prepend

      public void prepend(byte[] aBytes, int aOffset, int aLength)
      Prepends the given bytes to the beginning of this Sequence. Beware: This Sequence is modified! If you do not wish to modify this Sequence, please use Sequence.toPrepend(byte[], int, int).
      Specified by:
      prepend in interface Sequence
      Parameters:
      aBytes - The bytes to be prepended.
      aOffset - The offset from where to start collecting the bytes.
      aLength - The number of bytes to be prepended.
    • prepend

      public void prepend(Sequence aSequence)
      Prepends the given Sequence to the beginning of this Sequence. Beware: This Sequence is modified! If you do not wish to modify this Sequence, please use Sequence.toPrepend(Sequence).
      Specified by:
      prepend in interface Sequence
      Parameters:
      aSequence - The Sequence to be prepended.
    • replace

      public void replace(byte[] aBytes)
      Replaces the content of this Sequence with the content of the given byte array.
      Specified by:
      replace in interface Sequence
      Parameters:
      aBytes - The byte array with which to replace the content.
    • replace

      public void replace(Sequence aSequence)
      Replaces the content of this Sequence with the content of the given Sequence.
      Specified by:
      replace in interface Sequence
      Parameters:
      aSequence - The Sequence with which to replace the content.
    • replace

      public void replace(byte[] aBytes, int aOffset, int aLength)
      Replaces the given bytes with this byte array. CAUTION: If possible, this method avoids array copying, so if the offset is 0 and the length the same as the byte array's length, then the given byte array is used internally!
      Specified by:
      replace in interface Sequence
      Parameters:
      aBytes - The byte array where to copy the bytes from.
      aOffset - The offset in the byte array where to start copying.
      aLength - The number of bytes to be copied.
    • replace

      public void replace(Sequence aSequence, int aOffset, int aLength)
      Replaces the given bytes with this Sequence.
      Specified by:
      replace in interface Sequence
      Parameters:
      aSequence - The given Sequence where to copy the bytes from.
      aOffset - The offset in the byte array where to start copying.
      aLength - The number of bytes to be copied.
    • setByteAt

      public void setByteAt(int aIndex, byte aByte) throws IndexOutOfBoundsException
      Sets the byte at the given index in the Sequence.
      Specified by:
      setByteAt in interface Sequence
      Parameters:
      aIndex - The index of the byte to set.
      aByte - The byte to set at the given index.
      Throws:
      IndexOutOfBoundsException - thrown in case the given index is out of bounds.
    • toAppend

      public ByteArraySequence toAppend(byte... aBytes)
      Appends the given bytes to the end of this Sequence. This Sequence is not modified and a new Sequence is returned.
      Specified by:
      toAppend in interface Sequence
      Parameters:
      aBytes - The bytes to be appended.
      Returns:
      The according Sequence.
    • toAppend

      public ByteArraySequence toAppend(byte[] aBytes, int aOffset, int aLength)
      Appends the given bytes to the end of this Sequence. This Sequence is not modified and a new Sequence is returned.
      Specified by:
      toAppend in interface Sequence
      Parameters:
      aBytes - The bytes to be appended.
      aOffset - The offset from where to start collecting the bytes.
      aLength - The number of bytes to be appended.
      Returns:
      The according Sequence.
    • toAppend

      public ByteArraySequence toAppend(Sequence aSequence)
      Appends the given Sequence to the end of this Sequence. This Sequence is not modified and a new Sequence is returned.
      Specified by:
      toAppend in interface Sequence
      Parameters:
      aSequence - The Sequence to be appended.
      Returns:
      The according Sequence.
    • toClone

      public ByteArraySequence toClone()
      Creates a deep clone of this Sequence.
      Specified by:
      toClone in interface Sequence
      Returns:
      The deep clone.
    • toConcatenate

      public ByteArraySequence toConcatenate(org.refcodes.mixin.ConcatenateMode aConcatenateMode, byte... aBytes)
      Concatenates the given bytes with this Sequence according to the provided ConcatenateMode. This Sequence is not modified and a new Sequence is returned.
      Specified by:
      toConcatenate in interface Sequence
      Parameters:
      aConcatenateMode - The concatenation mode to be used.
      aBytes - The bytes to be concatenated with.
      Returns:
      The according Sequence.
    • toConcatenate

      public ByteArraySequence toConcatenate(Sequence aSequence, org.refcodes.mixin.ConcatenateMode aConcatenateMode)
      Concatenates the given Sequence with this Sequence according to the provided ConcatenateMode. This Sequence is not modified and a new Sequence is returned.
      Specified by:
      toConcatenate in interface Sequence
      Parameters:
      aSequence - The Sequence to be concatenated with.
      aConcatenateMode - The concatenation mode to be used.
      Returns:
      The according Sequence.
    • toCrcBytes

      public byte[] toCrcBytes(org.refcodes.numerical.CrcAlgorithm aCrcAlgorithm, org.refcodes.numerical.Endianess aEndianess)
      Calculates the CRC checksum as byte array for this Sequence.
      Specified by:
      toCrcBytes in interface Sequence
      Parameters:
      aCrcAlgorithm - The CrcAlgorithm to be used when calculating the CRC checksum.
      aEndianess - The Endianess (little endian or big endian) to be used for the byte array representation of the CRC checksum.
      Returns:
      The CRC checksum of the Sequence.
    • toCrcBytes

      public byte[] toCrcBytes(long aCrcChecksum, org.refcodes.numerical.CrcAlgorithm aCrcAlgorithm, org.refcodes.numerical.Endianess aEndianess)
      Calculates the CRC checksum as byte array for this Sequence.
      Specified by:
      toCrcBytes in interface Sequence
      Parameters:
      aCrcChecksum - The CRC checksum from which to continue calculating the checksum,
      aCrcAlgorithm - The CrcAlgorithm to be used when calculating the CRC checksum.
      aEndianess - The Endianess (little endian or big endian) to be used for the byte array representation of the CRC checksum.
      Returns:
      The CRC checksum of the Sequence.
    • toCrcChecksum

      public long toCrcChecksum(org.refcodes.numerical.CrcAlgorithm aCrcAlgorithm)
      Calculates the CRC checksum for this Sequence.
      Specified by:
      toCrcChecksum in interface Sequence
      Parameters:
      aCrcAlgorithm - The CrcAlgorithm to be used when calculating the CRC checksum.
      Returns:
      The CRC checksum of the Sequence.
    • toCrcChecksum

      public long toCrcChecksum(long aCrcChecksum, org.refcodes.numerical.CrcAlgorithm aCrcAlgorithm)
      Calculates the CRC checksum for this Sequence.
      Specified by:
      toCrcChecksum in interface Sequence
      Parameters:
      aCrcChecksum - The CRC checksum from which to continue calculating the checksum,
      aCrcAlgorithm - The CrcAlgorithm to be used when calculating the CRC checksum.
      Returns:
      The CRC checksum of the Sequence.
    • toPrepend

      public ByteArraySequence toPrepend(byte... aBytes)
      Prepends the given bytes to the beginning of this Sequence. This Sequence is not modified and a new Sequence is returned.
      Specified by:
      toPrepend in interface Sequence
      Parameters:
      aBytes - The bytes to be prepended.
      Returns:
      The according Sequence.
    • toPrepend

      public ByteArraySequence toPrepend(byte[] aBytes, int aOffset, int aLength)
      Prepends the given bytes to the beginning of this Sequence. This Sequence is not modified and a new Sequence is returned.
      Specified by:
      toPrepend in interface Sequence
      Parameters:
      aBytes - The bytes to be prepended.
      aOffset - The offset from where to start collecting the bytes.
      aLength - The number of bytes to be prepended.
      Returns:
      The according Sequence.
    • toPrepend

      public ByteArraySequence toPrepend(Sequence aSequence)
      Prepends the given Sequence to the beginning of this Sequence. This Sequence is not modified and a new Sequence is returned.
      Specified by:
      toPrepend in interface Sequence
      Parameters:
      aSequence - The Sequence to be prepended.
      Returns:
      The according Sequence.
    • toSequence

      public ByteArraySequence toSequence(int aOffset, int aLength)
      Retrieves a new Sequence from this Sequence, starting with the byte at the given offset and containing the given number of bytes.
      Specified by:
      toSequence in interface Sequence
      Parameters:
      aOffset - The offset from where to start collecting the bytes.
      aLength - The length of the byte array to be returned.
      Returns:
      The according TransmissionSequenceException.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • toTruncate

      public ByteArraySequence toTruncate(int aLength, org.refcodes.mixin.TruncateMode aTruncateMode)
      Returns a new Sequence truncated by the given number of bytes from the right or from the left of both, according to the given TruncateMode. If the number of bytes exceeds the actual length of the Sequence, then the Sequence will end up being empty.
      Specified by:
      toTruncate in interface Sequence
      Parameters:
      aLength - The number of bytes to truncate according to the TruncateMode.
      aTruncateMode - The TruncateMode to use for truncating the Sequence.
      Returns:
      The newly created truncated Sequence.
    • toTruncateHead

      public ByteArraySequence toTruncateHead(int aLength)
      Returns a new Sequence truncated by the given number of bytes from the left. If the number of bytes exceeds the actual length of the Sequence, then the new Sequence will end up being empty.
      Specified by:
      toTruncateHead in interface Sequence
      Parameters:
      aLength - The number of bytes to truncate from the left.
      Returns:
      The newly created truncated Sequence.
    • toTruncateTail

      public ByteArraySequence toTruncateTail(int aLength)
      Returns a new Sequence truncated by the given number of bytes from the right. If the number of bytes exceeds the actual length of the Sequence, then the new Sequence will end up being empty.
      Specified by:
      toTruncateTail in interface Sequence
      Parameters:
      aLength - The number of bytes to truncate from the right.
      Returns:
      The newly created truncated Sequence.
    • toOverwrite

      public ByteArraySequence toOverwrite(byte[] aBytes)
      Writes the given bytes into a copy of this Sequence. If the Sequence is too small for the bytes to fit into, then the Sequence is extended accordingly.
      Specified by:
      toOverwrite in interface Sequence
      Parameters:
      aBytes - The byte array where to copy the bytes from.
      Returns:
      The according Sequence.
    • toOverwrite

      public ByteArraySequence toOverwrite(int aOffset, Sequence aSeqquence, int aBytesOffset, int aLength)
      Writes the given Sequence into a copy of this Sequence. If the Sequence is too small for the bytes to fit into, then the Sequence is extended accordingly.
      Specified by:
      toOverwrite in interface Sequence
      Parameters:
      aOffset - The offset where to start writing the bytes to.
      aSeqquence - The Sequence where to copy the bytes from.
      aBytesOffset - The offset in the Sequence where to start copying.
      aLength - The number of bytes to be copied.
      Returns:
      The according Sequence.
    • toOverwrite

      public ByteArraySequence toOverwrite(int aOffset, byte[] aBytes, int aBytesOffset, int aLength)
      Writes the given bytes into a copy of this Sequence. If the Sequence is too small for the bytes to fit into, then the Sequence is extended accordingly.
      Specified by:
      toOverwrite in interface Sequence
      Parameters:
      aOffset - The offset where to start writing the bytes to.
      aBytes - The byte array where to copy the bytes from.
      aBytesOffset - The offset in the byte array where to start copying.
      aLength - The number of bytes to be copied.
      Returns:
      The according Sequence.
    • toOverwrite

      public ByteArraySequence toOverwrite(int aOffset, Sequence aSequence)
      Writes the given bytes into a copy of this Sequence. If the Sequence is too small for the bytes to fit into, then the Sequence is extended accordingly.
      Specified by:
      toOverwrite in interface Sequence
      Parameters:
      aOffset - The offset where to start writing the bytes to.
      aSequence - The Sequence where to copy the bytes from.
      Returns:
      The according Sequence.
    • toOverwrite

      public ByteArraySequence toOverwrite(Sequence aSequence)
      Writes the given bytes into a copy of this Sequence. If the Sequence is too small for the bytes to fit into, then the Sequence is extended accordingly.
      Specified by:
      toOverwrite in interface Sequence
      Parameters:
      aSequence - The Sequence where to copy the bytes from.
      Returns:
      The according Sequence.
    • truncateHead

      public void truncateHead(int aLength)
      Truncates the Sequence by the given number of bytes from the left. If the number of bytes exceeds the actual length of the Sequence, then the Sequence will end up being empty.
      Specified by:
      truncateHead in interface Sequence
      Parameters:
      aLength - The number of bytes to truncate from the left.
    • truncateTail

      public void truncateTail(int aLength)
      Truncates the Sequence by the given number of bytes from the right. If the number of bytes exceeds the actual length of the Sequence, then the Sequence will end up being empty.
      Specified by:
      truncateTail in interface Sequence
      Parameters:
      aLength - The number of bytes to truncate from the right.
    • withAppend

      public ByteArraySequence withAppend(byte... aBytes)
      Builder method for the Sequence.append(byte...) method.
      Specified by:
      withAppend in interface Sequence
      Parameters:
      aBytes - The bytes to be appended.
      Returns:
      This instance as of the builder pattern.
    • withAppend

      public ByteArraySequence withAppend(byte[] aBytes, int aOffset, int aLength)
      Builder method for the Sequence.append(byte...) method.
      Specified by:
      withAppend in interface Sequence
      Parameters:
      aBytes - The bytes to be appended.
      aOffset - The offset from where to start collecting the bytes.
      aLength - The number of bytes to be appended.
      Returns:
      This instance as of the builder pattern.
    • withAppend

      public ByteArraySequence withAppend(Sequence aSequence)
      Builder method for the Sequence.append(Sequence) method.
      Specified by:
      withAppend in interface Sequence
      Parameters:
      aSequence - The Sequence to be appended.
      Returns:
      This instance as of the builder pattern.
    • withConcatenate

      public ByteArraySequence withConcatenate(org.refcodes.mixin.ConcatenateMode aConcatenateMode, byte... aBytes)
      Builder method for the Sequence.concatenate(ConcatenateMode, byte...) method.
      Specified by:
      withConcatenate in interface Sequence
      Parameters:
      aConcatenateMode - The concatenation mode to be used.
      aBytes - The bytes to be concatenated with.
      Returns:
      This instance as of the builder pattern.
    • withConcatenate

      public ByteArraySequence withConcatenate(Sequence aSequence, org.refcodes.mixin.ConcatenateMode aConcatenateMode)
      Specified by:
      withConcatenate in interface Sequence
      Parameters:
      aSequence - The Sequence to be concatenated with
      aConcatenateMode - The concatenation mode to be used.
      Returns:
      This instance as of the builder pattern.
    • withPrepend

      public ByteArraySequence withPrepend(byte... aBytes)
      Builder method for the Sequence.prepend(byte...) method.
      Specified by:
      withPrepend in interface Sequence
      Parameters:
      aBytes - The bytes to be prepended.
      Returns:
      This instance as of the builder pattern.
    • withPrepend

      public ByteArraySequence withPrepend(byte[] aBytes, int aOffset, int aLength)
      Builder method for the Sequence.prepend(byte...) method.
      Specified by:
      withPrepend in interface Sequence
      Parameters:
      aBytes - The bytes to be prepended.
      aOffset - The offset from where to start collecting the bytes.
      aLength - The number of bytes to be prepended.
      Returns:
      This instance as of the builder pattern.
    • withPrepend

      public ByteArraySequence withPrepend(Sequence aSequence)
      Builder method for the Sequence.prepend(Sequence) method.
      Specified by:
      withPrepend in interface Sequence
      Parameters:
      aSequence - The Sequence to be prepended.
      Returns:
      This instance as of the builder pattern.
    • withReplace

      public ByteArraySequence withReplace(byte[] aBytes)
      Builder method for the Sequence.replace(byte[]) method.
      Specified by:
      withReplace in interface Sequence
      Parameters:
      aBytes - The byte array where to copy the bytes from.
      Returns:
      This instance as of the builder pattern.
    • withReplace

      public ByteArraySequence withReplace(byte[] aBytes, int aOffset, int aLength)
      Builder method for the Sequence.replace(byte[], int, int) method.
      Specified by:
      withReplace in interface Sequence
      Parameters:
      aBytes - The byte array where to copy the bytes from.
      aOffset - The offset in the byte array where to start copying.
      aLength - The number of bytes to be copied.
      Returns:
      This instance as of the builder pattern.
    • withReplace

      public ByteArraySequence withReplace(Sequence aSequence)
      Builder method for the Sequence.replace(Sequence) method.
      Specified by:
      withReplace in interface Sequence
      Parameters:
      aSequence - The Sequence where to copy the bytes from.
      Returns:
      This instance as of the builder pattern.
    • withReplace

      public ByteArraySequence withReplace(Sequence aSequence, int aOffset, int aLength)
      Builder method for the Sequence.replace(Sequence, int, int) method.
      Specified by:
      withReplace in interface Sequence
      Parameters:
      aSequence - The Sequence where to copy the bytes from.
      aOffset - The offset in the byte array where to start copying.
      aLength - The number of bytes to be copied.
      Returns:
      This instance as of the builder pattern.
    • withTruncate

      public ByteArraySequence withTruncate(int aLength, org.refcodes.mixin.TruncateMode aTruncateMode)
      Builder method for the Sequence.truncate(int, TruncateMode) method.
      Specified by:
      withTruncate in interface Sequence
      Parameters:
      aLength - The number of bytes to truncate according to the TruncateMode.
      aTruncateMode - The TruncateMode to use for truncating the Sequence.
      Returns:
      This instance as of the builder pattern.
    • withTruncateHead

      public ByteArraySequence withTruncateHead(int aLength)
      Builder method for the Sequence.truncateHead(int) method.
      Specified by:
      withTruncateHead in interface Sequence
      Parameters:
      aLength - The number of bytes to truncate.
      Returns:
      This instance as of the builder pattern.
    • withTruncateTail

      public ByteArraySequence withTruncateTail(int aLength)
      Builder method for the Sequence.truncateTail(int) method.
      Specified by:
      withTruncateTail in interface Sequence
      Parameters:
      aLength - The number of bytes to truncate.
      Returns:
      This instance as of the builder pattern.
    • withOverwrite

      public ByteArraySequence withOverwrite(byte[] aBytes)
      Builder method for the Sequence.overwrite(byte[]) method.
      Specified by:
      withOverwrite in interface Sequence
      Parameters:
      aBytes - The byte array where to copy the bytes from.
      Returns:
      This instance as of the builder pattern.
    • withOverwrite

      public ByteArraySequence withOverwrite(int aOffset, byte[] aBytes)
      Builder method for the Sequence.overwrite(int, byte[]) method.
      Specified by:
      withOverwrite in interface Sequence
      Parameters:
      aOffset - The offset where to start writing the bytes to.
      aBytes - The byte array where to copy the bytes from.
      Returns:
      This instance as of the builder pattern.
    • withOverwrite

      public ByteArraySequence withOverwrite(int aOffset, byte[] aBytes, int aBytesOffset, int aLength)
      Builder method for the Sequence.overwrite(int, byte[], int, int) method.
      Specified by:
      withOverwrite in interface Sequence
      Parameters:
      aOffset - The offset where to start writing the bytes to.
      aBytes - The byte array where to copy the bytes from.
      aBytesOffset - The offset in the byte array where to start copying.
      aLength - The number of bytes to be copied.
      Returns:
      This instance as of the builder pattern.
    • withOverwrite

      public ByteArraySequence withOverwrite(int aOffset, Sequence aSequence)
      Builder method for the Sequence.overwrite(int, Sequence) method.
      Specified by:
      withOverwrite in interface Sequence
      Parameters:
      aOffset - The offset where to start writing the bytes to.
      aSequence - The Sequence where to copy the bytes from.
      Returns:
      This instance as of the builder pattern.
    • withOverwrite

      public ByteArraySequence withOverwrite(int aOffset, Sequence aSequence, int aSequenceOffset, int aLength)
      Builder method for the Sequence.overwrite(int, Sequence, int, int) method.
      Specified by:
      withOverwrite in interface Sequence
      Parameters:
      aOffset - The offset where to start writing the bytes to.
      aSequence - The Sequence where to copy the bytes from.
      aSequenceOffset - The offset in the byte array where to start copying.
      aLength - The number of bytes to be copied.
      Returns:
      This instance as of the builder pattern.
    • withOverwrite

      public ByteArraySequence withOverwrite(Sequence aSequence)
      Builder method for the Sequence.overwrite(Sequence) method.
      Specified by:
      withOverwrite in interface Sequence
      Parameters:
      aSequence - The Sequence where to copy the bytes from.
      Returns:
      This instance as of the builder pattern.
    • writeTo

      public void writeTo(OutputStream aOutputStream) throws IOException
      Writes the content of the Sequence to the provided OutputStream.
      Specified by:
      writeTo in interface Sequence
      Parameters:
      aOutputStream - The OutputStream where to write to.
      Throws:
      IOException - thrown in case of I/O problems.