Class StringArraySection

java.lang.Object
org.refcodes.serial.StringArraySection
All Implemented Interfaces:
Serializable, org.refcodes.mixin.AliasAccessor, org.refcodes.mixin.EncodingAccessor<Charset>, org.refcodes.mixin.LengthAccessor, org.refcodes.mixin.PayloadAccessor<String[]>, org.refcodes.mixin.PayloadAccessor.PayloadBuilder<String[],PayloadTransmission<String[]>>, org.refcodes.mixin.PayloadAccessor.PayloadMutator<String[]>, org.refcodes.mixin.PayloadAccessor.PayloadProperty<String[]>, org.refcodes.mixin.Resetable, org.refcodes.numerical.EndianessAccessor, org.refcodes.schema.Schemable, LengthWidthAccessor, PayloadSection<String[]>, PayloadTransmission<String[]>, Section, Section.SectionMixin, Transmission, Transmission.TransmissionMixin

public class StringArraySection extends Object implements Section.SectionMixin, PayloadSection<String[]>, LengthWidthAccessor, org.refcodes.numerical.EndianessAccessor, org.refcodes.mixin.EncodingAccessor<Charset>
The StringArraySection is an implementation of a Section carrying a String array as payload. Each String is represented by a StringSection decorated by an AllocSectionDecoratorSegment.
See Also:
  • Constructor Details

  • Method Details

    • 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.
    • receiveFrom

      public void receiveFrom(InputStream aInputStream, int aLength, OutputStream aReturnStream) throws IOException
      Default implementation harnessing the Section.fromTransmission(Sequence, int) method. (Re-)initializes this instance by receiving the according Sequence from the given InputStream. Implementations providing error correction methods use the provided feedback OutputStream to do some sort of "stop-and-wait ARQ" or apply similar methods to ensure correctness of the received data.
      Specified by:
      receiveFrom in interface Section
      Specified by:
      receiveFrom in interface Section.SectionMixin
      Parameters:
      aInputStream - The InputStream from which to read the instance's (re-)initialization Sequence from.
      aLength - The length of data assigned by the byte array.
      aReturnStream - An OutputStream being the return channel to handle "stop-and-wait ARQ" or the like in case of a bidirectional connection. Can be null in case we have a unidirectional connection.
      Throws:
      IOException - thrown in case reading data from the InputStream caused problems.
      TransmissionException - thrown in case a given InputStream bytes cannot be processed.
    • 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.
      Specified by:
      toSequence in interface Transmission
      Returns:
      The according instance's Sequence.
    • reset

      public void reset()
      Resets any dynamic data (e.g. values such as payloads or checksums) and must not(!) reset any configurations or settings required to produce the dynamic data (e.g. the TransmissionMetrics).
      Specified by:
      reset in interface org.refcodes.mixin.Resetable
      Specified by:
      reset in interface Transmission
    • toSchema

      public SerialSchema toSchema()
      Specified by:
      toSchema in interface org.refcodes.schema.Schemable
      Specified by:
      toSchema in interface Transmission
    • 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).
    • getPayload

      public String[] getPayload()
      Specified by:
      getPayload in interface org.refcodes.mixin.PayloadAccessor<String[]>
    • setPayload

      public void setPayload(String[] aValue)
      Specified by:
      setPayload in interface org.refcodes.mixin.PayloadAccessor.PayloadMutator<String[]>
    • withPayload

      public StringArraySection withPayload(String[] aValue)
      Specified by:
      withPayload in interface org.refcodes.mixin.PayloadAccessor.PayloadBuilder<String[],PayloadTransmission<String[]>>
    • getLengthWidth

      public int getLengthWidth()
      Retrieves the length width (in bytes) from the length width (in bytes) property.
      Specified by:
      getLengthWidth in interface LengthWidthAccessor
      Returns:
      The length width (in bytes) stored by the length width (in bytes) property.
    • getEndianess

      public org.refcodes.numerical.Endianess getEndianess()
      Specified by:
      getEndianess in interface org.refcodes.numerical.EndianessAccessor
    • getEncoding

      public Charset getEncoding()
      Specified by:
      getEncoding in interface org.refcodes.mixin.EncodingAccessor<Charset>
    • getAlias

      public String getAlias()
      Specified by:
      getAlias in interface org.refcodes.mixin.AliasAccessor
    • toSimpleTypeMap

      public org.refcodes.struct.SimpleTypeMap toSimpleTypeMap()
      Returns the SimpleTypeMap representation of this Transmission. In case this Transmission has Transmission children, then the children are queried as well and contained in the resulting SimpleTypeMap. The aliases of the according Transmission instances represent the resulting path to a Transmission's final simple type.
      Specified by:
      toSimpleTypeMap in interface Transmission
      Returns:
      The SimpleTypeMap representing this Transmission and (if any) its children, with the according aliases forming the paths to the Transmission's values.