Class AsciizArraySegment

java.lang.Object
org.refcodes.serial.AbstractPayloadSegment<String[]>
org.refcodes.serial.AsciizArraySegment
All Implemented Interfaces:
Serializable, org.refcodes.mixin.AliasAccessor, 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.Schemable, org.refcodes.numerical.EndianessAccessor, EndOfStringByteAccessor, LengthWidthAccessor, PayloadSegment<String[]>, PayloadTransmission<String[]>, Segment, Segment.SegmentMixin, Transmission, Transmission.TransmissionMixin

public class AsciizArraySegment extends AbstractPayloadSegment<String[]> implements PayloadSegment<String[]>, LengthWidthAccessor, org.refcodes.numerical.EndianessAccessor, EndOfStringByteAccessor
The AsciizArraySegment is an implementation of a Section carrying a String array as payload. Each String is represented by a String decorated by an AllocSectionDecoratorSegment.
See Also:
  • Constructor Details

    • AsciizArraySegment

      public AsciizArraySegment(TransmissionMetrics aTransmissionMetrics)
      Constructs an AsciizArraySegment from the given configuration. The configuration attributes are taken from the TransmissionMetrics configuration object, though only those attributes are supported which are also supported by the other constructors!
      Parameters:
      aTransmissionMetrics - The TransmissionMetrics to be used for configuring this instance.
    • AsciizArraySegment

      public AsciizArraySegment(TransmissionMetrics aTransmissionMetrics, String... aValue)
      Constructs an AsciizArraySegment from the given configuration. The configuration attributes are taken from the TransmissionMetrics configuration object, though only those attributes are supported which are also supported by the other constructors!
      Parameters:
      aTransmissionMetrics - The TransmissionMetrics to be used for configuring this instance.
      aValue - The payload to be contained by the AsciizArraySegment.
    • AsciizArraySegment

      public AsciizArraySegment(String aAlias, TransmissionMetrics aTransmissionMetrics)
      Constructs an AsciizArraySegment from the given configuration. The configuration attributes are taken from the TransmissionMetrics configuration object, though only those attributes are supported which are also supported by the other constructors!
      Parameters:
      aAlias - The alias which identifies the content of this instance.
      aTransmissionMetrics - The TransmissionMetrics to be used for configuring this instance.
    • AsciizArraySegment

      public AsciizArraySegment(String aAlias, TransmissionMetrics aTransmissionMetrics, String... aValue)
      Constructs an AsciizArraySegment from the given configuration. The configuration attributes are taken from the TransmissionMetrics configuration object, though only those attributes are supported which are also supported by the other constructors!
      Parameters:
      aAlias - The alias which identifies the content of this instance.
      aTransmissionMetrics - The TransmissionMetrics to be used for configuring this instance.
      aValue - The payload to be contained by the AsciizArraySegment.
    • AsciizArraySegment

      public AsciizArraySegment(String... aPayload)
      Constructs an AsciizArraySegment containing the provided payload and using the TransmissionMetrics.DEFAULT_LENGTH_WIDTH as well as the TransmissionMetrics.DEFAULT_ENDIANESS.
      Parameters:
      aPayload - The String elements being contained in this instance.
    • AsciizArraySegment

      public AsciizArraySegment(int aLengthWidth, org.refcodes.numerical.Endianess aEndianess, String... aPayload)
      Constructs an AsciizArraySegment using the provided String elements and using the provided Segment class for creating Segment instances.
      Parameters:
      aLengthWidth - The width (in bytes) to be used for size values (number of elements in the payload array). * @param aEndianess The Endianess to be used for size values.
      aEndianess - the endianess
      aPayload - The String elements being contained in this instance.
    • AsciizArraySegment

      public AsciizArraySegment(String aAlias, int aLengthWidth, org.refcodes.numerical.Endianess aEndianess, String... aPayload)
      Constructs an AsciizArraySegment using the provided arguments.
      Parameters:
      aAlias - The alias which identifies the content of this segment.
      aLengthWidth - The width (in bytes) to be used for size values (number of elements in the payload array).
      aEndianess - The Endianess to be used for size values.
      aPayload - The String elements being contained in this instance.
    • AsciizArraySegment

      public AsciizArraySegment(String aAlias, TransmissionMetrics aTransmissionMetrics, byte aEndOfStringByte)
      Constructs an AsciizArraySegment from the given configuration. The configuration attributes are taken from the TransmissionMetrics configuration object, though only those attributes are supported which are also supported by the other constructors!
      Parameters:
      aAlias - The alias which identifies the content of this instance.
      aTransmissionMetrics - The TransmissionMetrics to be used for configuring this instance.
      aEndOfStringByte - The alternate value instead of 0 "zero" identifying the end of the string.
    • AsciizArraySegment

      public AsciizArraySegment(byte aEndOfStringByte, String... aPayload)
      Constructs an AsciizArraySegment containing the provided payload and using the TransmissionMetrics.DEFAULT_LENGTH_WIDTH as well as the TransmissionMetrics.DEFAULT_ENDIANESS.
      Parameters:
      aEndOfStringByte - The alternate value instead of 0 "zero" identifying the end of the string.
      aPayload - The String elements being contained in this instance.
    • AsciizArraySegment

      public AsciizArraySegment(byte aEndOfStringByte, int aLengthWidth, org.refcodes.numerical.Endianess aEndianess, String... aPayload)
      Constructs an AsciizArraySegment using the provided String elements and using the provided Segment class for creating Segment instances.
      Parameters:
      aEndOfStringByte - The alternate value instead of 0 "zero" identifying the end of the string.
      aLengthWidth - The width (in bytes) to be used for size values (number of elements in the payload array). * @param aEndianess The Endianess to be used for size values.
      aEndianess - the endianess
      aPayload - The String elements being contained in this instance.
    • AsciizArraySegment

      public AsciizArraySegment(String aAlias, byte aEndOfStringByte, int aLengthWidth, org.refcodes.numerical.Endianess aEndianess, String... aPayload)
      Constructs an AsciizArraySegment using the provided arguments.
      Parameters:
      aAlias - The alias which identifies the content of this segment.
      aEndOfStringByte - The alternate value instead of 0 "zero" identifying the end of the string.
      aLengthWidth - The width (in bytes) to be used for size values (number of elements in the payload array).
      aEndianess - The Endianess to be used for size values.
      aPayload - The String elements being contained in this instance.
  • Method Details

    • fromTransmission

      public int fromTransmission(Sequence aSequence, int aOffset) throws TransmissionException
      (Re-)initializes this instance with the the given Sequence data.
      Specified by:
      fromTransmission in interface Segment
      Parameters:
      aSequence - The Sequence data from which to (re-)initialize this instance.
      aOffset - The offset where to start processing the provided Sequence.
      Returns:
      The index after the last offset into the given Sequence processed by this method.
      Throws:
      TransmissionException - thrown in case a given Sequence cannot be processed.
    • receiveFrom

      public void receiveFrom(InputStream aInputStream, OutputStream aReturnStream) throws IOException, TransmissionException
      (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 Segment
      Specified by:
      receiveFrom in interface Segment.SegmentMixin
      Parameters:
      aInputStream - The InputStream from which to read the instance's (re-)initialization Sequence from.
      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 transmission 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.
    • transmitTo

      public void transmitTo(OutputStream aOutputStream, InputStream aReturnStream) throws IOException
      Transmits the Sequence representing the implementing type's instance to the given OutputStream. Implementations providing error correction methods use the provided feedback InputStream to do some sort of "stop-and-wait ARQ" or apply similar methods to ensure correctness of the transmitted data.
      Specified by:
      transmitTo in interface Transmission
      Specified by:
      transmitTo in interface Transmission.TransmissionMixin
      Parameters:
      aOutputStream - The OutputStream where to write this instance's Sequence to.
      aReturnStream - An InputStream 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 writing data to the OutputStream caused problems.
    • toSchema

      public SerialSchema toSchema()
      Specified by:
      toSchema in interface org.refcodes.mixin.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).
    • withPayload

      public AsciizArraySegment 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
    • getAlias

      public String getAlias()
      Specified by:
      getAlias in interface org.refcodes.mixin.AliasAccessor
      Overrides:
      getAlias in class AbstractPayloadSegment<String[]>
    • 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
      Overrides:
      toSimpleTypeMap in class AbstractPayloadSegment<String[]>
      Returns:
      The SimpleTypeMap representing this Transmission and (if any) its children, with the according aliases forming the paths to the Transmission's values.
    • getEndOfStringByte

      public byte getEndOfStringByte()
      Retrieves the end of string byte from the end of string byte property.
      Specified by:
      getEndOfStringByte in interface EndOfStringByteAccessor
      Returns:
      The end of string byte stored by the end of string byte property.