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:
-
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.mixin.EncodingAccessor
org.refcodes.mixin.EncodingAccessor.EncodingBuilder<E extends Object,
B extends org.refcodes.mixin.EncodingAccessor.EncodingBuilder<E, B>>, org.refcodes.mixin.EncodingAccessor.EncodingMutator<E extends Object>, org.refcodes.mixin.EncodingAccessor.EncodingProperty<E extends Object> 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.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.Section
Section.SectionMixin
Nested classes/interfaces inherited from interface org.refcodes.serial.Transmission
Transmission.TransmissionMixin
-
Constructor Summary
ConstructorDescriptionConstructs an emptyStringArraySection
using theTransmissionMetrics.DEFAULT_LENGTH_WIDTH
, theTransmissionMetrics.DEFAULT_ENDIANESS
as well as theTransmissionMetrics.DEFAULT_ENCODING
.StringArraySection
(int aLengthWidth, org.refcodes.numerical.Endianess aEndianess, Charset aCharset, String... aPayload) Constructs aStringArraySection
using containing the providedStringSection
elements and using the providedSegment
class for creatingSegment
instances.StringArraySection
(String aAlias) Constructs an emptyStringArraySection
using theTransmissionMetrics.DEFAULT_LENGTH_WIDTH
, theTransmissionMetrics.DEFAULT_ENDIANESS
as well as theTransmissionMetrics.DEFAULT_ENCODING
.StringArraySection
(String... aPayload) Constructs aStringArraySection
containing the provided payload and using theTransmissionMetrics.DEFAULT_LENGTH_WIDTH
, theTransmissionMetrics.DEFAULT_ENDIANESS
as well as theTransmissionMetrics.DEFAULT_ENCODING
.StringArraySection
(String aAlias, int aLengthWidth, org.refcodes.numerical.Endianess aEndianess, Charset aCharset, String... aPayload) Constructs aStringArraySection
using containing the providedStringSection
elements and using the providedSegment
class for creatingSegment
instances.StringArraySection
(String aAlias, String[] aPayload) Constructs aStringArraySection
containing the provided payload and using theTransmissionMetrics.DEFAULT_LENGTH_WIDTH
, theTransmissionMetrics.DEFAULT_ENDIANESS
as well as theTransmissionMetrics.DEFAULT_ENCODING
.StringArraySection
(String aAlias, Charset aCharset, String... aPayload) Constructs aStringArraySection
containing the provided payload and using theTransmissionMetrics.DEFAULT_LENGTH_WIDTH
, as well as theTransmissionMetrics.DEFAULT_ENDIANESS
.StringArraySection
(String aAlias, TransmissionMetrics aTransmissionMetrics) Constructs an according instance from the given configuration.StringArraySection
(String aAlias, TransmissionMetrics aTransmissionMetrics, String... aValue) Constructs an according instance from the given configuration.StringArraySection
(Charset aCharset, String... aPayload) Constructs aStringArraySection
containing the provided payload and using theTransmissionMetrics.DEFAULT_LENGTH_WIDTH
, as well as theTransmissionMetrics.DEFAULT_ENDIANESS
.StringArraySection
(TransmissionMetrics aTransmissionMetrics) Constructs an according instance from the given configuration.StringArraySection
(TransmissionMetrics aTransmissionMetrics, String... aValue) Constructs an according instance from the given configuration. -
Method Summary
Modifier and TypeMethodDescriptionvoid
fromTransmission
(Sequence aSequence, int aOffset, int aLength) (Re-)initializes this instance with the the givenSequence
data.getAlias()
org.refcodes.numerical.Endianess
int
Determines the overall length of thisTransmission
.int
Retrieves the length width (in bytes) from the length width (in bytes) property.String[]
void
receiveFrom
(InputStream aInputStream, int aLength, OutputStream aReturnStream) Default implementation harnessing theSection.fromTransmission(Sequence, int)
method.void
reset()
Resets any dynamic data (e.g. values such as payloads or checksums) and must not(!)void
setPayload
(String[] aValue) toSchema()
Provides theSequence
representation of thisTransmission
.org.refcodes.struct.SimpleTypeMap
Returns theSimpleTypeMap
representation of thisTransmission
.withPayload
(String[] aValue) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.refcodes.mixin.PayloadAccessor
getPayloadOr
Methods inherited from interface org.refcodes.mixin.PayloadAccessor.PayloadProperty
letPayload
Methods inherited from interface org.refcodes.serial.Section
fromTransmission, fromTransmission, fromTransmission, receiveFrom, receiveFrom
Methods inherited from interface org.refcodes.serial.Transmission
transmitTo, transmitTo
Methods inherited from interface org.refcodes.serial.Transmission.TransmissionMixin
transmitTo
-
Constructor Details
-
StringArraySection
Constructs an according instance 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.
-
StringArraySection
Constructs an according instance 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 theStringArraySection
.
-
StringArraySection
Constructs an according instance 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.
-
StringArraySection
public StringArraySection(String aAlias, TransmissionMetrics aTransmissionMetrics, String... aValue) Constructs an according instance 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 theStringArraySection
.
-
StringArraySection
public StringArraySection()Constructs an emptyStringArraySection
using theTransmissionMetrics.DEFAULT_LENGTH_WIDTH
, theTransmissionMetrics.DEFAULT_ENDIANESS
as well as theTransmissionMetrics.DEFAULT_ENCODING
. -
StringArraySection
Constructs aStringArraySection
containing the provided payload and using theTransmissionMetrics.DEFAULT_LENGTH_WIDTH
, theTransmissionMetrics.DEFAULT_ENDIANESS
as well as theTransmissionMetrics.DEFAULT_ENCODING
.- Parameters:
aPayload
- TheString
elements being contained in this instance.
-
StringArraySection
Constructs aStringArraySection
containing the provided payload and using theTransmissionMetrics.DEFAULT_LENGTH_WIDTH
, as well as theTransmissionMetrics.DEFAULT_ENDIANESS
. -
StringArraySection
public StringArraySection(int aLengthWidth, org.refcodes.numerical.Endianess aEndianess, Charset aCharset, String... aPayload) Constructs aStringArraySection
using containing the providedStringSection
elements and using the providedSegment
class for creatingSegment
instances. -
StringArraySection
Constructs an emptyStringArraySection
using theTransmissionMetrics.DEFAULT_LENGTH_WIDTH
, theTransmissionMetrics.DEFAULT_ENDIANESS
as well as theTransmissionMetrics.DEFAULT_ENCODING
.- Parameters:
aAlias
- The alias which identifies the content of this segment.
-
StringArraySection
Constructs aStringArraySection
containing the provided payload and using theTransmissionMetrics.DEFAULT_LENGTH_WIDTH
, theTransmissionMetrics.DEFAULT_ENDIANESS
as well as theTransmissionMetrics.DEFAULT_ENCODING
.- Parameters:
aAlias
- The alias which identifies the content of this segment.aPayload
- TheString
elements being contained in this instance.
-
StringArraySection
Constructs aStringArraySection
containing the provided payload and using theTransmissionMetrics.DEFAULT_LENGTH_WIDTH
, as well as theTransmissionMetrics.DEFAULT_ENDIANESS
. -
StringArraySection
public StringArraySection(String aAlias, int aLengthWidth, org.refcodes.numerical.Endianess aEndianess, Charset aCharset, String... aPayload) Constructs aStringArraySection
using containing the providedStringSection
elements and using the providedSegment
class for creatingSegment
instances.- Parameters:
aAlias
- The alias which identifies the content of this segment.aLengthWidth
- The width (in bytes) to be used for size values.aEndianess
- TheEndianess
to be used for size values.aCharset
- TheCharset
to use when encoding or decoding theString
instances.aPayload
- TheString
elements being contained in this instance.
-
-
Method Details
-
fromTransmission
public void fromTransmission(Sequence aSequence, int aOffset, int aLength) throws TransmissionException (Re-)initializes this instance with the the givenSequence
data.- Specified by:
fromTransmission
in interfaceSection
- Parameters:
aSequence
- TheSequence
data from which to (re-)initialize this instance.aOffset
- The offset where to start processing the providedSequence
.aLength
- The length of data assigned by theSequence
.- Throws:
TransmissionException
- thrown in case a givenSequence
cannot be processed.
-
receiveFrom
public void receiveFrom(InputStream aInputStream, int aLength, OutputStream aReturnStream) throws IOException Default implementation harnessing theSection.fromTransmission(Sequence, int)
method. (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 interfaceSection
- Specified by:
receiveFrom
in interfaceSection.SectionMixin
- Parameters:
aInputStream
- TheInputStream
from which to read the instance's (re-)initializationSequence
from.aLength
- The length of data assigned by the byte array.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 givenInputStream
bytes cannot be processed.
-
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
.
-
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. theTransmissionMetrics
).- Specified by:
reset
in interfaceorg.refcodes.mixin.Resetable
- Specified by:
reset
in interfaceTransmission
-
toSchema
- Specified by:
toSchema
in interfaceorg.refcodes.schema.Schemable
- Specified by:
toSchema
in interfaceTransmission
-
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).
-
getPayload
- Specified by:
getPayload
in interfaceorg.refcodes.mixin.PayloadAccessor<String[]>
-
setPayload
- Specified by:
setPayload
in interfaceorg.refcodes.mixin.PayloadAccessor.PayloadMutator<String[]>
-
withPayload
- 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
-
getEncoding
- Specified by:
getEncoding
in interfaceorg.refcodes.mixin.EncodingAccessor<Charset>
-
getAlias
- Specified by:
getAlias
in interfaceorg.refcodes.mixin.AliasAccessor
-
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
- Returns:
- The
SimpleTypeMap
representing thisTransmission
and (if any) its children, with the according aliases forming the paths to theTransmission
's values.
-