- java.lang.Object
-
- org.refcodes.serial.AbstractPayloadSegment<Long>
-
- org.refcodes.serial.NumberSegment
-
- All Implemented Interfaces:
Serializable,org.refcodes.mixin.AliasAccessor,org.refcodes.mixin.LengthAccessor,org.refcodes.mixin.PayloadAccessor<Long>,org.refcodes.mixin.PayloadAccessor.PayloadBuilder<Long,PayloadTransmission<Long>>,org.refcodes.mixin.PayloadAccessor.PayloadMutator<Long>,org.refcodes.mixin.PayloadAccessor.PayloadProperty<Long>,org.refcodes.mixin.ValueAccessor<Long>,org.refcodes.mixin.ValueAccessor.ValueBuilder<Long,NumberSegment>,org.refcodes.mixin.ValueAccessor.ValueMutator<Long>,org.refcodes.mixin.ValueAccessor.ValueProperty<Long>,PayloadSegment<Long>,PayloadTransmission<Long>,Segment,Segment.SegmentMixin,Transmission,Transmission.TransmissionMixin
- Direct Known Subclasses:
SequenceNumberSegment
public class NumberSegment extends AbstractPayloadSegment<Long> implements Segment, org.refcodes.mixin.ValueAccessor.ValueProperty<Long>, org.refcodes.mixin.ValueAccessor.ValueBuilder<Long,NumberSegment>
TheNumberSegmentis an implementation of aSegmentcarrying in long an integer value with a configurable width (in bytes) as payload.- 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.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.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
-
Nested classes/interfaces inherited from interface org.refcodes.mixin.ValueAccessor
org.refcodes.mixin.ValueAccessor.ValueBuilder<V extends Object,B extends org.refcodes.mixin.ValueAccessor.ValueBuilder<V,B>>, org.refcodes.mixin.ValueAccessor.ValueMutator<V extends Object>, org.refcodes.mixin.ValueAccessor.ValueProperty<V extends Object>
-
-
Field Summary
Fields Modifier and Type Field Description static StringENDIANESS-
Fields inherited from class org.refcodes.serial.AbstractPayloadSegment
_alias, _payload
-
-
Constructor Summary
Constructors Constructor Description NumberSegment(int aNumberWidth)Constructs an emptyNumberSegmentwith aTransmissionMetrics.DEFAULT_ENDIANESSendian representation of theNumberSegment's value.NumberSegment(int aNumberWidth, Long aValue)Constructs aNumberSegmentwith the given long payload and aTransmissionMetrics.DEFAULT_ENDIANESSendian representation of theNumberSegment's value.NumberSegment(int aNumberWidth, Long aValue, org.refcodes.numerical.Endianess aEndianess)Constructs aNumberSegmentwith the given long payload and the givenEndianessfor the representation of theNumberSegment's value (payload).NumberSegment(int aNumberWidth, Long aValue, TransmissionMetrics aTransmissionMetrics)Constructs an according instance from the given configuration.NumberSegment(int aNumberWidth, org.refcodes.numerical.Endianess aEndianess)Constructs an emptyNumberSegmentwith the givenEndianess.NumberSegment(int aNumberWidth, TransmissionMetrics aTransmissionMetrics)Constructs an according instance from the given configuration.NumberSegment(String aAlias, int aNumberWidth)Constructs an emptyNumberSegmentwith aTransmissionMetrics.DEFAULT_ENDIANESSendian representation of theNumberSegment's value.NumberSegment(String aAlias, int aNumberWidth, Long aValue)Constructs aNumberSegmentwith the given long payload and aTransmissionMetrics.DEFAULT_ENDIANESSendian representation of theNumberSegment's value.NumberSegment(String aAlias, int aNumberWidth, Long aValue, org.refcodes.numerical.Endianess aEndianess)Constructs aNumberSegmentwith the given long payload and the givenEndianessfor the representation of theNumberSegment's value (payload).NumberSegment(String aAlias, int aNumberWidth, org.refcodes.numerical.Endianess aEndianess)Constructs an emptyNumberSegmentwith the givenEndianess.NumberSegment(String aAlias, int aNumberWidth, TransmissionMetrics aTransmissionMetrics)Constructs an according instance from the given configuration.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intfromTransmission(Sequence aSequence, int aOffset)(Re-)initializes this instance with the the givenSequencedata.intgetLength()Determines the overall length of thisTransmission.LonggetValue()voidsetValue(Long aValue)SchematoSchema()Retrieves theSchemarepresenting theTransmission.SequencetoSequence()Provides theSequencerepresentation of thisTransmission.NumberSegmentwithPayload(Long aValue)NumberSegmentwithValue(Long aValue)-
Methods inherited from class org.refcodes.serial.AbstractPayloadSegment
equals, getAlias, getPayload, hashCode, setPayload, toSimpleTypeMap, 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.Segment.SegmentMixin
receiveFrom
-
Methods inherited from interface org.refcodes.serial.Transmission
toSimpleTypeMap, transmitTo, transmitTo
-
Methods inherited from interface org.refcodes.serial.Transmission.TransmissionMixin
transmitTo
-
-
-
-
Field Detail
-
ENDIANESS
public static final String ENDIANESS
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
NumberSegment
public NumberSegment(int aNumberWidth, TransmissionMetrics aTransmissionMetrics)Constructs an according instance from the given configuration. The configuration attributes are taken from theTransmissionMetricsconfiguration object, though only those attributes are supported which are also supported by the other constructors!- Parameters:
aNumberWidth- The number of bytes to be occupied by the number.aTransmissionMetrics- TheTransmissionMetricsto be used for configuring this instance.
-
NumberSegment
public NumberSegment(int aNumberWidth, Long aValue, TransmissionMetrics aTransmissionMetrics)Constructs an according instance from the given configuration. The configuration attributes are taken from theTransmissionMetricsconfiguration object, though only those attributes are supported which are also supported by the other constructors!- Parameters:
aNumberWidth- The number of bytes to be occupied by the number.aValue- The payload to be contained by theDoubleArraySection.aTransmissionMetrics- TheTransmissionMetricsto be used for configuring this instance.
-
NumberSegment
public NumberSegment(String aAlias, int aNumberWidth, TransmissionMetrics aTransmissionMetrics)
Constructs an according instance from the given configuration. The configuration attributes are taken from theTransmissionMetricsconfiguration 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.aNumberWidth- The number of bytes to be occupied by the number.aTransmissionMetrics- TheTransmissionMetricsto be used for configuring this instance.
-
NumberSegment
public NumberSegment(int aNumberWidth)
Constructs an emptyNumberSegmentwith aTransmissionMetrics.DEFAULT_ENDIANESSendian representation of theNumberSegment's value.- Parameters:
aNumberWidth- The number of bytes to be occupied by the number.
-
NumberSegment
public NumberSegment(int aNumberWidth, org.refcodes.numerical.Endianess aEndianess)Constructs an emptyNumberSegmentwith the givenEndianess.- Parameters:
aNumberWidth- The number of bytes to be occupied by the number.aEndianess- TheEndianessto be used for payload values.
-
NumberSegment
public NumberSegment(int aNumberWidth, Long aValue)Constructs aNumberSegmentwith the given long payload and aTransmissionMetrics.DEFAULT_ENDIANESSendian representation of theNumberSegment's value.- Parameters:
aNumberWidth- The number of bytes to be occupied by the number.aValue- The payload to be contained by theNumberSegment.
-
NumberSegment
public NumberSegment(int aNumberWidth, Long aValue, org.refcodes.numerical.Endianess aEndianess)Constructs aNumberSegmentwith the given long payload and the givenEndianessfor the representation of theNumberSegment's value (payload).- Parameters:
aNumberWidth- The number of bytes to be occupied by the number.aValue- The value (payload) to be contained by theNumberSegment.aEndianess- TheEndianessto be used for payload values.
-
NumberSegment
public NumberSegment(String aAlias, int aNumberWidth)
Constructs an emptyNumberSegmentwith aTransmissionMetrics.DEFAULT_ENDIANESSendian representation of theNumberSegment's value.- Parameters:
aAlias- The alias which identifies the content of this segment.aNumberWidth- The number of bytes to be occupied by the number.
-
NumberSegment
public NumberSegment(String aAlias, int aNumberWidth, org.refcodes.numerical.Endianess aEndianess)
Constructs an emptyNumberSegmentwith the givenEndianess.- Parameters:
aAlias- The alias which identifies the content of this segment.aNumberWidth- The number of bytes to be occupied by the number.aEndianess- TheEndianessto be used for payload values.
-
NumberSegment
public NumberSegment(String aAlias, int aNumberWidth, Long aValue)
Constructs aNumberSegmentwith the given long payload and aTransmissionMetrics.DEFAULT_ENDIANESSendian representation of theNumberSegment's value.- Parameters:
aAlias- The alias which identifies the content of this segment.aNumberWidth- The number of bytes to be occupied by the number.aValue- The payload to be contained by theNumberSegment.
-
NumberSegment
public NumberSegment(String aAlias, int aNumberWidth, Long aValue, org.refcodes.numerical.Endianess aEndianess)
Constructs aNumberSegmentwith the given long payload and the givenEndianessfor the representation of theNumberSegment's value (payload).- Parameters:
aAlias- The alias which identifies the content of this segment.aNumberWidth- The number of bytes to be occupied by the number.aValue- The value (payload) to be contained by theNumberSegment.aEndianess- TheEndianessto be used for payload values.
-
-
Method Detail
-
toSequence
public Sequence toSequence()
Provides theSequencerepresentation of thisTransmission. In case of nestedTransmissioninstances, allSequencerepresentations from all sub-segments are accumulated to the result as well. Caution, the Transmission (or its nestedTransmissioninstances) may be backed by the returnedSequence.- Specified by:
toSequencein interfaceTransmission- Returns:
- The according instance's
Sequence.
-
fromTransmission
public int fromTransmission(Sequence aSequence, int aOffset) throws TransmissionException
(Re-)initializes this instance with the the givenSequencedata.- Specified by:
fromTransmissionin interfaceSegment- Parameters:
aSequence- TheSequencedata 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
Sequenceprocessed by this method. - Throws:
TransmissionException- thrown in case a givenSequencecannot be processed.
-
getLength
public int getLength()
Determines the overall length of thisTransmission. In case of nestedTransmissioninstances, all length values from all sub-segments are accumulated to the result as well.- Specified by:
getLengthin interfaceorg.refcodes.mixin.LengthAccessor- Specified by:
getLengthin interfaceTransmission- Returns:
- The (overall) length of the
Transmission(including any sub-segments).
-
toSchema
public Schema toSchema()
Retrieves theSchemarepresenting theTransmission. Retrieving aSchemais useful when analyzing and debugging data structures such as aAllocSectionDecoratorSegmentinstance to help document, learn and verify on the structure (as well as the content) of that veryAllocSectionDecoratorSegment.- Specified by:
toSchemain interfaceTransmission- Returns:
- The
Schemarepresentation of the implementing type for debugging and verification (or documentation) purposes.
-
withPayload
public NumberSegment withPayload(Long aValue)
- Specified by:
withPayloadin interfaceorg.refcodes.mixin.PayloadAccessor.PayloadBuilder<Long,PayloadTransmission<Long>>
-
getValue
public Long getValue()
- Specified by:
getValuein interfaceorg.refcodes.mixin.ValueAccessor<Long>
-
setValue
public void setValue(Long aValue)
- Specified by:
setValuein interfaceorg.refcodes.mixin.ValueAccessor.ValueMutator<Long>
-
withValue
public NumberSegment withValue(Long aValue)
- Specified by:
withValuein interfaceorg.refcodes.mixin.ValueAccessor.ValueBuilder<Long,NumberSegment>
-
-