Module org.refcodes.serial
Package org.refcodes.serial
Class AbstractReferenceeLengthSegment<REFERENCEE extends Transmission>
- java.lang.Object
-
- org.refcodes.serial.AbstractReferenceeLengthSegment<REFERENCEE>
-
- All Implemented Interfaces:
Serializable
,org.refcodes.mixin.LengthAccessor
,org.refcodes.numerical.EndianessAccessor
,AllocLengthAccessor
,LengthWidthAccessor
,Segment
,Transmission
,Transmission.TransmissionMixin
- Direct Known Subclasses:
AbstractLengthDecoratorSegment
,AllocSegmentHead
,LengthSegment
public abstract class AbstractReferenceeLengthSegment<REFERENCEE extends Transmission> extends Object implements Segment, Transmission.TransmissionMixin, LengthWidthAccessor, org.refcodes.numerical.EndianessAccessor, AllocLengthAccessor
TheAbstractReferenceeLengthSegment
represents a allocated length value as of the referencedTransmission
element's length.- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.refcodes.serial.AllocLengthAccessor
AllocLengthAccessor.AllocLengthBuilder<B extends AllocLengthAccessor.AllocLengthBuilder<B>>, AllocLengthAccessor.AllocLengthMutator, AllocLengthAccessor.AllocLengthProperty
-
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.serial.Segment
Segment.SegmentMixin
-
Nested classes/interfaces inherited from interface org.refcodes.serial.Transmission
Transmission.TransmissionMixin
-
-
Field Summary
Fields Modifier and Type Field Description protected int
_allocLength
protected org.refcodes.numerical.Endianess
_endianess
protected int
_lengthWidth
protected REFERENCEE
_referencee
static String
LENGTH_ENDIANESS
static String
LENGTH_WIDTH
-
Constructor Summary
Constructors Constructor Description AbstractReferenceeLengthSegment()
Constructs an empty allocation value with a width ofTransmissionMetrics.DEFAULT_LENGTH_WIDTH
bytes used to specify the decoratee's length and aTransmissionMetrics.DEFAULT_ENDIANESS
endian representation of the decoratee's length.AbstractReferenceeLengthSegment(int aLengthWidth)
Constructs an empty allocation value with the given number of bytes used to specify the decoratee's length and aTransmissionMetrics.DEFAULT_ENDIANESS
endian representation of the decoratee's length.AbstractReferenceeLengthSegment(int aLengthWidth, org.refcodes.numerical.Endianess aEndianess)
Constructs an empty allocation value with the given number of bytes used to specify the decoratee's length and the providedEndianess
representation of the decoratee's length.AbstractReferenceeLengthSegment(org.refcodes.numerical.Endianess aEndianess)
Constructs an empty allocation value with a width ofTransmissionMetrics.DEFAULT_LENGTH_WIDTH
bytes used to specify the decoratee's length and the providedEndianess
representation of the decoratee's length.AbstractReferenceeLengthSegment(TransmissionMetrics aTransmissionMetrics)
Constructs an according instance.AbstractReferenceeLengthSegment(REFERENCEE aReferencee)
Constructs the allocation value with the given decoratee and a width ofTransmissionMetrics.DEFAULT_LENGTH_WIDTH
bytes used to specify the decoratee's length aTransmissionMetrics.DEFAULT_ENDIANESS
endian representation of the decoratee's length.AbstractReferenceeLengthSegment(REFERENCEE aReferencee, int aLengthWidth)
Constructs the allocation value with the given decoratee and with the given number of bytes used to specify the decoratee's length and aTransmissionMetrics.DEFAULT_ENDIANESS
endian representation of the decoratee's length.AbstractReferenceeLengthSegment(REFERENCEE aReferencee, int aLengthWidth, org.refcodes.numerical.Endianess aEndianess)
Constructs the allocation value with the given decoratee and with the given number of bytes used to specify the decoratee's length and the providedEndianess
representation of the decoratee's length.AbstractReferenceeLengthSegment(REFERENCEE aReferencee, org.refcodes.numerical.Endianess aEndianess)
Constructs the allocation value with the given decoratee and a width ofTransmissionMetrics.DEFAULT_LENGTH_WIDTH
bytes used to specify the decoratee's length and the providedEndianess
representation of the decoratee's length.AbstractReferenceeLengthSegment(REFERENCEE aReferencee, TransmissionMetrics aTransmissionMetrics)
Constructs an according instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object obj)
int
fromTransmission(Sequence aSequence, int aOffset)
(Re-)initializes this instance with the the givenSequence
data.int
getAllocLength()
Returns the allocated length in bytes declared by this instance.org.refcodes.numerical.Endianess
getEndianess()
int
getLength()
Determines the overall length of thisTransmission
.int
getLengthWidth()
Retrieves the length width (in bytes) from the length width (in bytes) property.int
hashCode()
void
receiveFrom(InputStream aInputStream, OutputStream aReturnStream)
(Re-)initializes this instance by receiving the accordingSequence
from the givenInputStream
.Schema
toSchema()
Retrieves theSchema
representing theTransmission
.org.refcodes.struct.SimpleTypeMap
toSimpleTypeMap()
Returns theSimpleTypeMap
representation of thisTransmission
.String
toString()
Sequence
toTransmission()
Provides theSequence
representation of thisTransmission
.-
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
-
Methods inherited from interface org.refcodes.serial.Transmission.TransmissionMixin
transmitTo
-
-
-
-
Field Detail
-
LENGTH_WIDTH
public static final String LENGTH_WIDTH
- See Also:
- Constant Field Values
-
LENGTH_ENDIANESS
public static final String LENGTH_ENDIANESS
- See Also:
- Constant Field Values
-
_endianess
protected org.refcodes.numerical.Endianess _endianess
-
_lengthWidth
protected int _lengthWidth
-
_allocLength
protected int _allocLength
-
_referencee
protected REFERENCEE extends Transmission _referencee
-
-
Constructor Detail
-
AbstractReferenceeLengthSegment
public AbstractReferenceeLengthSegment(TransmissionMetrics aTransmissionMetrics)
Constructs an according instance. 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.
-
AbstractReferenceeLengthSegment
public AbstractReferenceeLengthSegment(REFERENCEE aReferencee, TransmissionMetrics aTransmissionMetrics)
Constructs an according instance. The configuration attributes are taken from theTransmissionMetrics
configuration object, though only those attributes are supported which are also supported by the other constructors!- Parameters:
aReferencee
- The referencedTransmission
which's length is to be used.aTransmissionMetrics
- TheTransmissionMetrics
to be used for configuring this instance.
-
AbstractReferenceeLengthSegment
public AbstractReferenceeLengthSegment()
Constructs an empty allocation value with a width ofTransmissionMetrics.DEFAULT_LENGTH_WIDTH
bytes used to specify the decoratee's length and aTransmissionMetrics.DEFAULT_ENDIANESS
endian representation of the decoratee's length.
-
AbstractReferenceeLengthSegment
public AbstractReferenceeLengthSegment(org.refcodes.numerical.Endianess aEndianess)
Constructs an empty allocation value with a width ofTransmissionMetrics.DEFAULT_LENGTH_WIDTH
bytes used to specify the decoratee's length and the providedEndianess
representation of the decoratee's length.- Parameters:
aEndianess
- TheEndianess
to be used for length values.
-
AbstractReferenceeLengthSegment
public AbstractReferenceeLengthSegment(int aLengthWidth)
Constructs an empty allocation value with the given number of bytes used to specify the decoratee's length and aTransmissionMetrics.DEFAULT_ENDIANESS
endian representation of the decoratee's length.- Parameters:
aLengthWidth
- The width (in bytes) to be used for length values.
-
AbstractReferenceeLengthSegment
public AbstractReferenceeLengthSegment(int aLengthWidth, org.refcodes.numerical.Endianess aEndianess)
Constructs an empty allocation value with the given number of bytes used to specify the decoratee's length and the providedEndianess
representation of the decoratee's length.- Parameters:
aLengthWidth
- The width (in bytes) to be used for length values.aEndianess
- TheEndianess
to be used for length values.
-
AbstractReferenceeLengthSegment
public AbstractReferenceeLengthSegment(REFERENCEE aReferencee)
Constructs the allocation value with the given decoratee and a width ofTransmissionMetrics.DEFAULT_LENGTH_WIDTH
bytes used to specify the decoratee's length aTransmissionMetrics.DEFAULT_ENDIANESS
endian representation of the decoratee's length.- Parameters:
aReferencee
- The decoratee used for this allocation value.
-
AbstractReferenceeLengthSegment
public AbstractReferenceeLengthSegment(REFERENCEE aReferencee, org.refcodes.numerical.Endianess aEndianess)
Constructs the allocation value with the given decoratee and a width ofTransmissionMetrics.DEFAULT_LENGTH_WIDTH
bytes used to specify the decoratee's length and the providedEndianess
representation of the decoratee's length.- Parameters:
aReferencee
- The decoratee used for this allocation value.aEndianess
- TheEndianess
to be used for length values.
-
AbstractReferenceeLengthSegment
public AbstractReferenceeLengthSegment(REFERENCEE aReferencee, int aLengthWidth)
Constructs the allocation value with the given decoratee and with the given number of bytes used to specify the decoratee's length and aTransmissionMetrics.DEFAULT_ENDIANESS
endian representation of the decoratee's length.- Parameters:
aReferencee
- The decoratee used for this allocation value.aLengthWidth
- The width (in bytes) to be used for length values.
-
AbstractReferenceeLengthSegment
public AbstractReferenceeLengthSegment(REFERENCEE aReferencee, int aLengthWidth, org.refcodes.numerical.Endianess aEndianess)
Constructs the allocation value with the given decoratee and with the given number of bytes used to specify the decoratee's length and the providedEndianess
representation of the decoratee's length.- Parameters:
aReferencee
- The decoratee used for this allocation value.aLengthWidth
- The width (in bytes) to be used for length values.aEndianess
- TheEndianess
to be used for length values.
-
-
Method Detail
-
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.
-
toTransmission
public Sequence toTransmission()
Provides theSequence
representation of thisTransmission
. In case of nestedTransmission
instances, allSequence
representations from all sub-segments are accumulated to the result as well.- Specified by:
toTransmission
in interfaceTransmission
- Returns:
- The according instance's
Sequence
.
-
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
- 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.
-
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).
-
getEndianess
public org.refcodes.numerical.Endianess getEndianess()
- Specified by:
getEndianess
in interfaceorg.refcodes.numerical.EndianessAccessor
-
getAllocLength
public int getAllocLength()
Returns the allocated length in bytes declared by this instance.- Specified by:
getAllocLength
in interfaceAllocLengthAccessor
- Returns:
- The allocated length in bytes.
-
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.
-
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.
-
-