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[]>, org.refcodes.mixin.Resetable, org.refcodes.schema.Schemable, PayloadSection<byte[]>, PayloadTransmission<byte[]>, Section, Section.SectionMixin, Transmission, Transmission.TransmissionMixin

public class ByteArraySection extends AbstractPayloadSection<byte[]>
The ByteArraySection is an implementation of a Section carrying a byte array as payload.
See Also:
  • 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

    • toSequence

      public Sequence toSequence()
      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. Caution, the Transmission (or its nested Transmission instances) may be backed by the returned Sequence.
      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.
      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.
      Returns:
      The (overall) length of the Transmission (including any sub-segments).
    • toSchema

      public SerialSchema toSchema()
    • toString

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

      public ByteArraySection withPayload(byte[] aValue)
    • 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.