Class ByteArraySection

java.lang.Object
org.refcodes.serial.AbstractPayloadSection<byte[]>
org.refcodes.serial.ByteArraySection
All Implemented Interfaces:
Serializable, org.refcodes.mixin.AliasAccessor, org.refcodes.mixin.LengthAccessor, org.refcodes.mixin.PayloadAccessor<byte[]>, org.refcodes.mixin.PayloadAccessor.PayloadBuilder<byte[],​PayloadTransmission<byte[]>>, org.refcodes.mixin.PayloadAccessor.PayloadMutator<byte[]>, org.refcodes.mixin.PayloadAccessor.PayloadProperty<byte[]>, PayloadSection<byte[]>, PayloadTransmission<byte[]>, Section, Section.SectionMixin, Transmission, Transmission.TransmissionMixin

public class ByteArraySection
extends AbstractPayloadSection<byte[]>
implements PayloadSection<byte[]>
The ByteArraySection is an implementation of a Section carrying a byte array as payload.
See Also:
Serialized Form
  • Constructor Details

    • ByteArraySection

      public ByteArraySection()
      Constructs an empty ByteArraySection.
    • ByteArraySection

      public ByteArraySection​(byte[] aPayload)
      Constructs a ByteArraySection with the given byte array payload.
      Parameters:
      aPayload - The payload to be contained by the Section.
    • ByteArraySection

      public ByteArraySection​(Byte[] aPayload)
      Constructs a ByteArraySection with the given byte array payload.
      Parameters:
      aPayload - The payload to be contained by the Section.
    • ByteArraySection

      public ByteArraySection​(String aAlias)
      Constructs an empty ByteArraySection.
      Parameters:
      aAlias - The alias which identifies the content of this segment.
    • ByteArraySection

      public ByteArraySection​(String aAlias, byte[] aPayload)
      Constructs a ByteArraySection with the given byte array payload.
      Parameters:
      aAlias - The alias which identifies the content of this segment.
      aPayload - The payload to be contained by the Section.
    • ByteArraySection

      public ByteArraySection​(String aAlias, Byte[] aPayload)
      Constructs a ByteArraySection with the given byte array payload.
      Parameters:
      aAlias - The alias which identifies the content of this segment.
      aPayload - The payload to be contained by the Section.
  • Method Details

    • toTransmission

      public Sequence toTransmission()
      Provides the Sequence representation of this Transmission. In case of nested Transmission instances, all Sequence representations from all sub-segments are accumulated to the result as well.
      Specified by:
      toTransmission in interface Transmission
      Returns:
      The according instance's Sequence.
    • fromTransmission

      public void fromTransmission​(Sequence aSequence, int aOffset, int aLength) throws TransmissionException
      (Re-)initializes this instance with the the given Sequence data.
      Specified by:
      fromTransmission in interface Section
      Parameters:
      aSequence - The Sequence data from which to (re-)initialize this instance.
      aOffset - The offset where to start processing the provided Sequence.
      aLength - The length of data assigned by the Sequence.
      Throws:
      TransmissionException - thrown in case a given Sequence cannot be processed.
    • getLength

      public int getLength()
      Determines the overall length of this Transmission. In case of nested Transmission instances, all length values from all sub-segments are accumulated to the result as well.
      Specified by:
      getLength in interface org.refcodes.mixin.LengthAccessor
      Specified by:
      getLength in interface Transmission
      Returns:
      The (overall) length of the Transmission (including any sub-segments).
    • toSchema

      public Schema toSchema()
      Retrieves the Schema representing the Transmission. Retrieving a Schema is useful when analyzing and debugging data structures such as a AllocSectionDecoratorSegment instance to help document, learn and verify on the structure (as well as the content) of that very AllocSectionDecoratorSegment.
      Specified by:
      toSchema in interface Transmission
      Returns:
      The Schema representation of the implementing type for debugging and verification (or documentation) purposes.
    • toString

      public String toString()
      Overrides:
      toString in class AbstractPayloadSection<byte[]>
    • withPayload

      public ByteArraySection withPayload​(byte[] aValue)
      Specified by:
      withPayload in interface org.refcodes.mixin.PayloadAccessor.PayloadBuilder<byte[],​PayloadTransmission<byte[]>>
    • setPayload

      public void setPayload​(Byte[] aPayload)
      Convenience method to convert the array of wrapper types into its counterpart with primitive types before invoking AbstractPayloadSection.setPayload(Object).
      Parameters:
      aPayload - The payload with the wrapper types.
    • withPayload

      public ByteArraySection withPayload​(Byte[] aPayload)
      Convenience method to convert the array of wrapper types into its counterpart with primitive types before invoking withPayload(byte[]).
      Parameters:
      aPayload - The payload with the wrapper types.
      Returns:
      This instance as of the builder pattern.