- 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.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
TheAsciizArraySegment
is an implementation of aSection
carrying aString
array as payload. EachString
is represented by aString
decorated by anAllocSectionDecoratorSegment
.- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.refcodes.mixin.AliasAccessor
org.refcodes.mixin.AliasAccessor.AliasBuilder<B extends org.refcodes.mixin.AliasAccessor.AliasBuilder<B>>, org.refcodes.mixin.AliasAccessor.AliasMutator, org.refcodes.mixin.AliasAccessor.AliasProperty
-
Nested classes/interfaces inherited from interface org.refcodes.numerical.EndianessAccessor
org.refcodes.numerical.EndianessAccessor.EndianessBuilder<B extends org.refcodes.numerical.EndianessAccessor.EndianessBuilder<B>>, org.refcodes.numerical.EndianessAccessor.EndianessMutator, org.refcodes.numerical.EndianessAccessor.EndianessProperty
-
Nested classes/interfaces inherited from interface org.refcodes.serial.EndOfStringByteAccessor
EndOfStringByteAccessor.EndOfStringByteBuilder<B extends EndOfStringByteAccessor.EndOfStringByteBuilder<B>>, EndOfStringByteAccessor.EndOfStringByteMutator, EndOfStringByteAccessor.EndOfStringByteProperty
-
Nested classes/interfaces inherited from interface org.refcodes.mixin.LengthAccessor
org.refcodes.mixin.LengthAccessor.LengthBuilder<B extends org.refcodes.mixin.LengthAccessor.LengthBuilder<B>>, org.refcodes.mixin.LengthAccessor.LengthMutator, org.refcodes.mixin.LengthAccessor.LengthProperty
-
Nested classes/interfaces inherited from interface org.refcodes.serial.LengthWidthAccessor
LengthWidthAccessor.LengthWidthBuilder<B extends LengthWidthAccessor.LengthWidthBuilder<B>>, LengthWidthAccessor.LengthWidthMutator, LengthWidthAccessor.LengthWidthProperty
-
Nested classes/interfaces inherited from interface org.refcodes.mixin.PayloadAccessor
org.refcodes.mixin.PayloadAccessor.PayloadBuilder<P extends Object,B extends org.refcodes.mixin.PayloadAccessor.PayloadBuilder<P,B>>, org.refcodes.mixin.PayloadAccessor.PayloadMutator<P extends Object>, org.refcodes.mixin.PayloadAccessor.PayloadProperty<P extends Object>
-
Nested classes/interfaces inherited from interface org.refcodes.serial.Segment
Segment.SegmentMixin
-
Nested classes/interfaces inherited from interface org.refcodes.serial.Transmission
Transmission.TransmissionMixin
-
-
Field Summary
-
Fields inherited from class org.refcodes.serial.AbstractPayloadSegment
_alias, _payload
-
-
Constructor Summary
Constructors Constructor Description AsciizArraySegment(byte aEndOfStringByte, int aLengthWidth, org.refcodes.numerical.Endianess aEndianess, String... aPayload)
Constructs anAsciizArraySegment
using the providedString
elements and using the providedSegment
class for creatingSegment
instances.AsciizArraySegment(byte aEndOfStringByte, String... aPayload)
Constructs anAsciizArraySegment
containing the provided payload and using theTransmissionMetrics.DEFAULT_LENGTH_WIDTH
as well as theTransmissionMetrics.DEFAULT_ENDIANESS
.AsciizArraySegment(int aLengthWidth, org.refcodes.numerical.Endianess aEndianess, String... aPayload)
Constructs anAsciizArraySegment
using the providedString
elements and using the providedSegment
class for creatingSegment
instances.AsciizArraySegment(String... aPayload)
Constructs anAsciizArraySegment
containing the provided payload and using theTransmissionMetrics.DEFAULT_LENGTH_WIDTH
as well as theTransmissionMetrics.DEFAULT_ENDIANESS
.AsciizArraySegment(String aAlias, byte aEndOfStringByte, int aLengthWidth, org.refcodes.numerical.Endianess aEndianess, String... aPayload)
Constructs anAsciizArraySegment
using the provided arguments.AsciizArraySegment(String aAlias, int aLengthWidth, org.refcodes.numerical.Endianess aEndianess, String... aPayload)
Constructs anAsciizArraySegment
using the provided arguments.AsciizArraySegment(String aAlias, TransmissionMetrics aTransmissionMetrics)
Constructs anAsciizArraySegment
from the given configuration.AsciizArraySegment(String aAlias, TransmissionMetrics aTransmissionMetrics, byte aEndOfStringByte)
Constructs anAsciizArraySegment
from the given configuration.AsciizArraySegment(String aAlias, TransmissionMetrics aTransmissionMetrics, String... aValue)
Constructs anAsciizArraySegment
from the given configuration.AsciizArraySegment(TransmissionMetrics aTransmissionMetrics)
Constructs anAsciizArraySegment
from the given configuration.AsciizArraySegment(TransmissionMetrics aTransmissionMetrics, String... aValue)
Constructs anAsciizArraySegment
from the given configuration.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
fromTransmission(Sequence aSequence, int aOffset)
(Re-)initializes this instance with the the givenSequence
data.String
getAlias()
org.refcodes.numerical.Endianess
getEndianess()
byte
getEndOfStringByte()
Retrieves the end of string byte from the end of string byte property.int
getLength()
Determines the overall length of thisTransmission
.int
getLengthWidth()
Retrieves the length width (in bytes) from the length width (in bytes) property.void
receiveFrom(InputStream aInputStream, OutputStream aReturnStream)
(Re-)initializes this instance by receiving the accordingSequence
from the givenInputStream
.Schema
toSchema()
Retrieves theSchema
representing theTransmission
.Sequence
toSequence()
Provides theSequence
representation of thisTransmission
.org.refcodes.struct.SimpleTypeMap
toSimpleTypeMap()
Returns theSimpleTypeMap
representation of thisTransmission
.void
transmitTo(OutputStream aOutputStream, InputStream aReturnStream)
Transmits theSequence
representing the implementing type's instance to the givenOutputStream
.AsciizArraySegment
withPayload(String[] aValue)
-
Methods inherited from class org.refcodes.serial.AbstractPayloadSegment
equals, getPayload, hashCode, setPayload, toString
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.refcodes.serial.Segment
fromTransmission, fromTransmission, fromTransmission, receiveFrom, receiveFrom
-
Methods inherited from interface org.refcodes.serial.Transmission
transmitTo, transmitTo
-
-
-
-
Constructor Detail
-
AsciizArraySegment
public AsciizArraySegment(TransmissionMetrics aTransmissionMetrics)
Constructs anAsciizArraySegment
from the given configuration. The configuration attributes are taken from theTransmissionMetrics
configuration object, though only those attributes are supported which are also supported by the other constructors!- Parameters:
aTransmissionMetrics
- TheTransmissionMetrics
to be used for configuring this instance.
-
AsciizArraySegment
public AsciizArraySegment(TransmissionMetrics aTransmissionMetrics, String... aValue)
Constructs anAsciizArraySegment
from the given configuration. The configuration attributes are taken from theTransmissionMetrics
configuration object, though only those attributes are supported which are also supported by the other constructors!- Parameters:
aTransmissionMetrics
- TheTransmissionMetrics
to be used for configuring this instance.aValue
- The payload to be contained by theAsciizArraySegment
.
-
AsciizArraySegment
public AsciizArraySegment(String aAlias, TransmissionMetrics aTransmissionMetrics)
Constructs anAsciizArraySegment
from the given configuration. The configuration attributes are taken from theTransmissionMetrics
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
- TheTransmissionMetrics
to be used for configuring this instance.
-
AsciizArraySegment
public AsciizArraySegment(String aAlias, TransmissionMetrics aTransmissionMetrics, String... aValue)
Constructs anAsciizArraySegment
from the given configuration. The configuration attributes are taken from theTransmissionMetrics
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
- TheTransmissionMetrics
to be used for configuring this instance.aValue
- The payload to be contained by theAsciizArraySegment
.
-
AsciizArraySegment
public AsciizArraySegment(String... aPayload)
Constructs anAsciizArraySegment
containing the provided payload and using theTransmissionMetrics.DEFAULT_LENGTH_WIDTH
as well as theTransmissionMetrics.DEFAULT_ENDIANESS
.- Parameters:
aPayload
- TheString
elements being contained in this instance.
-
AsciizArraySegment
public AsciizArraySegment(int aLengthWidth, org.refcodes.numerical.Endianess aEndianess, String... aPayload)
Constructs anAsciizArraySegment
using the providedString
elements and using the providedSegment
class for creatingSegment
instances.- Parameters:
aLengthWidth
- The width (in bytes) to be used for size values (number of elements in the payload array). * @param aEndianess TheEndianess
to be used for size values.aEndianess
- the endianessaPayload
- TheString
elements being contained in this instance.
-
AsciizArraySegment
public AsciizArraySegment(String aAlias, int aLengthWidth, org.refcodes.numerical.Endianess aEndianess, String... aPayload)
Constructs anAsciizArraySegment
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
- TheEndianess
to be used for size values.aPayload
- TheString
elements being contained in this instance.
-
AsciizArraySegment
public AsciizArraySegment(String aAlias, TransmissionMetrics aTransmissionMetrics, byte aEndOfStringByte)
Constructs anAsciizArraySegment
from the given configuration. The configuration attributes are taken from theTransmissionMetrics
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
- TheTransmissionMetrics
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 anAsciizArraySegment
containing the provided payload and using theTransmissionMetrics.DEFAULT_LENGTH_WIDTH
as well as theTransmissionMetrics.DEFAULT_ENDIANESS
.- Parameters:
aEndOfStringByte
- The alternate value instead of 0 "zero" identifying the end of the string.aPayload
- TheString
elements being contained in this instance.
-
AsciizArraySegment
public AsciizArraySegment(byte aEndOfStringByte, int aLengthWidth, org.refcodes.numerical.Endianess aEndianess, String... aPayload)
Constructs anAsciizArraySegment
using the providedString
elements and using the providedSegment
class for creatingSegment
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 TheEndianess
to be used for size values.aEndianess
- the endianessaPayload
- TheString
elements being contained in this instance.
-
AsciizArraySegment
public AsciizArraySegment(String aAlias, byte aEndOfStringByte, int aLengthWidth, org.refcodes.numerical.Endianess aEndianess, String... aPayload)
Constructs anAsciizArraySegment
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
- TheEndianess
to be used for size values.aPayload
- TheString
elements being contained in this instance.
-
-
Method Detail
-
fromTransmission
public int fromTransmission(Sequence aSequence, int aOffset) throws TransmissionException
(Re-)initializes this instance with the the givenSequence
data.- Specified by:
fromTransmission
in interfaceSegment
- Parameters:
aSequence
- TheSequence
data from which to (re-)initialize this instance.aOffset
- The offset where to start processing the providedSequence
.- Returns:
- The index after the last offset into the given
Sequence
processed by this method. - Throws:
TransmissionException
- thrown in case a givenSequence
cannot be processed.
-
receiveFrom
public void receiveFrom(InputStream aInputStream, OutputStream aReturnStream) throws IOException, TransmissionException
(Re-)initializes this instance by receiving the accordingSequence
from the givenInputStream
. Implementations providing error correction methods use the provided feedbackOutputStream
to do some sort of "stop-and-wait ARQ" or apply similar methods to ensure correctness of the received data.- Specified by:
receiveFrom
in interfaceSegment
- Specified by:
receiveFrom
in interfaceSegment.SegmentMixin
- Parameters:
aInputStream
- TheInputStream
from which to read the instance's (re-)initializationSequence
from.aReturnStream
- AnOutputStream
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 theInputStream
caused problems.TransmissionException
- thrown in case a given transmission cannot be processed.
-
toSequence
public Sequence toSequence()
Provides theSequence
representation of thisTransmission
. In case of nestedTransmission
instances, allSequence
representations from all sub-segments are accumulated to the result as well. Caution, the Transmission (or its nestedTransmission
instances) may be backed by the returnedSequence
.- Specified by:
toSequence
in interfaceTransmission
- Returns:
- The according instance's
Sequence
.
-
transmitTo
public void transmitTo(OutputStream aOutputStream, InputStream aReturnStream) throws IOException
Transmits theSequence
representing the implementing type's instance to the givenOutputStream
. Implementations providing error correction methods use the provided feedbackInputStream
to do some sort of "stop-and-wait ARQ" or apply similar methods to ensure correctness of the transmitted data.- Specified by:
transmitTo
in interfaceTransmission
- Specified by:
transmitTo
in interfaceTransmission.TransmissionMixin
- Parameters:
aOutputStream
- TheOutputStream
where to write this instance'sSequence
to.aReturnStream
- AnInputStream
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 theOutputStream
caused problems.
-
toSchema
public Schema toSchema()
Retrieves theSchema
representing theTransmission
. Retrieving aSchema
is useful when analyzing and debugging data structures such as aAllocSectionDecoratorSegment
instance to help document, learn and verify on the structure (as well as the content) of that veryAllocSectionDecoratorSegment
.- Specified by:
toSchema
in interfaceTransmission
- Returns:
- The
Schema
representation of the implementing type for debugging and verification (or documentation) purposes.
-
getLength
public int getLength()
Determines the overall length of thisTransmission
. In case of nestedTransmission
instances, all length values from all sub-segments are accumulated to the result as well.- Specified by:
getLength
in interfaceorg.refcodes.mixin.LengthAccessor
- Specified by:
getLength
in interfaceTransmission
- Returns:
- The (overall) length of the
Transmission
(including any sub-segments).
-
withPayload
public AsciizArraySegment withPayload(String[] aValue)
- Specified by:
withPayload
in interfaceorg.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 interfaceLengthWidthAccessor
- 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 interfaceorg.refcodes.numerical.EndianessAccessor
-
getAlias
public String getAlias()
- Specified by:
getAlias
in interfaceorg.refcodes.mixin.AliasAccessor
- Overrides:
getAlias
in classAbstractPayloadSegment<String[]>
-
toSimpleTypeMap
public org.refcodes.struct.SimpleTypeMap toSimpleTypeMap()
Returns theSimpleTypeMap
representation of thisTransmission
. In case this Transmission hasTransmission
children, then the children are queried as well and contained in the resultingSimpleTypeMap
. The aliases of the accordingTransmission
instances represent the resulting path to aTransmission
's final simple type.- Specified by:
toSimpleTypeMap
in interfaceTransmission
- Overrides:
toSimpleTypeMap
in classAbstractPayloadSegment<String[]>
- Returns:
- The
SimpleTypeMap
representing thisTransmission
and (if any) its children, with the according aliases forming the paths to theTransmission
's values.
-
getEndOfStringByte
public byte getEndOfStringByte()
Retrieves the end of string byte from the end of string byte property.- Specified by:
getEndOfStringByte
in interfaceEndOfStringByteAccessor
- Returns:
- The end of string byte stored by the end of string byte property.
-
-