Module org.refcodes.serial
Package org.refcodes.serial
Class AbstractReferenceeLengthSegment<REFERENCEE extends Transmission>
java.lang.Object
org.refcodes.serial.AbstractReferenceeLengthSegment<REFERENCEE>
- Type Parameters:
REFERENCEE
- the generic type
- All Implemented Interfaces:
Serializable
,org.refcodes.mixin.LengthAccessor
,org.refcodes.mixin.Schemable
,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
The
AbstractReferenceeLengthSegment
represents a allocated length
value as of the referenced Transmission
element's length.- See Also:
-
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
FieldsModifier and TypeFieldDescriptionprotected int
protected org.refcodes.numerical.Endianess
protected int
protected REFERENCEE
static final String
static final String
static final String
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs 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
Modifier and TypeMethodDescriptionboolean
int
fromTransmission
(Sequence aSequence, int aOffset) (Re-)initializes this instance with the the givenSequence
data.int
Returns the allocated length in bytes declared by this instance.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.int
hashCode()
void
receiveFrom
(InputStream aInputStream, OutputStream aReturnStream) (Re-)initializes this instance by receiving the accordingSequence
from the givenInputStream
.toSchema()
Provides theSequence
representation of thisTransmission
.org.refcodes.struct.SimpleTypeMap
Returns theSimpleTypeMap
representation of thisTransmission
.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
Methods inherited from interface org.refcodes.serial.Transmission.TransmissionMixin
transmitTo
-
Field Details
-
ALLOC_LENGTH
- See Also:
-
ALLOC_LENGTH_WIDTH
- See Also:
-
ENDIANESS
- See Also:
-
_endianess
protected org.refcodes.numerical.Endianess _endianess -
_lengthWidth
protected int _lengthWidth -
_allocLength
protected int _allocLength -
_referencee
-
-
Constructor Details
-
AbstractReferenceeLengthSegment
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
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
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 Details
-
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.
-
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
.
-
fromTransmission
(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
(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
- Specified by:
toSchema
in interfaceorg.refcodes.mixin.Schemable
- Specified by:
toSchema
in interfaceTransmission
-
hashCode
public int hashCode() -
equals
-
toString
-
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.
-