-
- All Superinterfaces:
org.refcodes.mixin.LengthAccessor
,Serializable
- All Known Subinterfaces:
ArraySection<ARRAY>
,ArraySegment<SEGMENT>
,ArrayTransmission<ARRAY>
,DecoratorSection<DECORATEE>
,DecoratorSegment<DECORATEE>
,DynamicTypeTransmission
,ErrorCorrectionTransmission
,PayloadSection<T>
,PayloadSegment<T>
,PayloadTransmission<T>
,ReadyToReceiveTransmission
,ReadyToSendTransmission
,Section
,Section.SectionMixin
,Segment
,Segment.SegmentMixin
,StopAndWaitPacketStreamTransmission
,StopAndWaitTransmission
,Transmission.TransmissionMixin
,TransmissionComposite<CHILD>
- All Known Implementing Classes:
AbstractArrayTransmission
,AbstractCipherTransmissionDecorator
,AbstractCrcTransmissionDecorator
,AbstractErrorCorrectionTransmissionDecorator
,AbstractInvertibleTransmissionDecorator
,AbstractLengthDecoratorSegment
,AbstractMagicBytesTransmission
,AbstractMagicBytesTransmissionDecorator
,AbstractMagicBytesTransmissionMultiplexer
,AbstractPayloadSection
,AbstractPayloadSegment
,AbstractReadyToReceiveTransmissionDecorator
,AbstractReadyToSendTransmissionDecorator
,AbstractReferenceeLengthSegment
,AbstractSectionDecorator
,AbstractSegmentDecorator
,AbstractStopAndWaitPacketStreamTransmissionDecorator
,AbstractStopAndWaitTransmissionDecorator
,AbstractTransmissionComposite
,AbstractTransmissionDecorator
,AllocSectionDecoratorSegment
,AllocSegmentBody
,AllocSegmentHead
,AsciizArraySegment
,AsciizSegment
,AssertMagicBytesSectionDecorator
,AssertMagicBytesSegment
,AssertMagicBytesSegmentDecorator
,BooleanArraySection
,BooleanSegment
,BreakerSectionDecorator
,BreakerSegmentDecorator
,ByteArraySection
,ByteSegment
,CharArraySection
,CharSection
,CipherSectionDecorator
,CipherSegmentDecorator
,ComplexTypeSegment
,CrcSectionDecorator
,CrcSegmentDecorator
,DoubleArraySection
,DoubleSegment
,DynamicTypeSection
,DynamicTypeSegment
,FileSection
,FixedLengthSequenceSegment
,FixedSegmentArraySection
,FloatArraySection
,FloatSegment
,IntArraySection
,IntSegment
,InvertibleSectionDecorator
,InvertibleSegmentDecorator
,LengthSegment
,LengthSegmentDecoratorSegment
,LongArraySection
,LongSegment
,MagicBytesSectionDecorator
,MagicBytesSectionMultiplexer
,MagicBytesSegment
,MagicBytesSegmentDecorator
,MagicBytesSegmentMultiplexer
,NullSegment
,NumberSegment
,PropertiesSection
,ReadyToReceiveSectionDecorator
,ReadyToReceiveSegmentDecorator
,ReadyToSendSectionDecorator
,ReadyToSendSegmentDecorator
,SectionComposite
,SegmentArraySection
,SegmentComposite
,SequenceNumberSegment
,SequenceSection
,ShortArraySection
,ShortSegment
,StopAndWaitPacketStreamSectionDecorator
,StopAndWaitPacketStreamSegmentDecorator
,StopAndWaitSectionDecorator
,StopAndWaitSegmentDecorator
,StringArraySection
,StringSection
,StringSegment
public interface Transmission extends org.refcodes.mixin.LengthAccessor, Serializable
TheTransmission
interface enables an implementing type to provide aSequence
representation of itself or to transmit itsSequence
representation through anOutputStream
(with an optional feedbackInputStream
) as oftransmitTo(OutputStream, InputStream)
. Usually, an implementation of theTransmission
interface actually either implements theSegment
interface or theSection
interface which both share theTransmission
super-interface. (this interface isSerializable
in order to achieve a deep copy the easy way which is required by theComplexTypeSegment
and theFixedSegmentArraySection
).
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
Transmission.TransmissionMixin
Default implementation of theTransmission
interface providing an implementation of theTransmission.TransmissionMixin.transmitTo(OutputStream, InputStream)
method using thetoSequence()
method.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description static byte[]
fromInputStream(InputStream aInputStream, int aLength)
Retrieves the number of bytes from the givenInputStream
by also trying to read the required number of bytes in chunks (in case not all bytes can be read in one take).int
getLength()
Determines the overall length of thisTransmission
.Schema
toSchema()
Retrieves theSchema
representing theTransmission
.Sequence
toSequence()
Provides theSequence
representation of thisTransmission
.org.refcodes.struct.SimpleTypeMap
toSimpleTypeMap()
Returns theSimpleTypeMap
representation of thisTransmission
.default void
transmitTo(OutputStream aOutputStream)
Transmits theSequence
representing the implementing type's instance to the givenOutputStream
.void
transmitTo(OutputStream aOutputStream, InputStream aReturnStream)
Transmits theSequence
representing the implementing type's instance to the givenOutputStream
.default void
transmitTo(SerialTransceiver aSerialTransceiver)
Transmits theSequence
representing the implementing type's instance to the givenSerialTransceiver
'sOutputStream
.
-
-
-
Method Detail
-
getLength
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
- Returns:
- The (overall) length of the
Transmission
(including any sub-segments).
-
toSequence
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
.- Returns:
- The according instance's
Sequence
.
-
transmitTo
default void transmitTo(OutputStream aOutputStream) throws IOException
Transmits theSequence
representing the implementing type's instance to the givenOutputStream
. This is a convenience method in case there is no feedbackInputStream
available (actually thetransmitTo(OutputStream, InputStream)
method is invoked withnull
for the feedbackInputStream
). OverridetransmitTo(OutputStream, InputStream)
for your custom transmitting functionality.- Parameters:
aOutputStream
- TheOutputStream
where to write this instance'sSequence
to.- Throws:
IOException
- thrown in case writing data to theOutputStream
caused problems.
-
transmitTo
default void transmitTo(SerialTransceiver aSerialTransceiver) throws IOException
Transmits theSequence
representing the implementing type's instance to the givenSerialTransceiver
'sOutputStream
. Implementations providing error correction methods use the providedSerialTransceiver
's feedbackInputStream
to do some sort of "stop-and-wait ARQ" or apply similar methods to ensure correctness of the transmitted data.This is a convenience method (actually thetransmitTo(OutputStream, InputStream)
method is invoked). OverridetransmitTo(OutputStream, InputStream)
for your custom transmitting functionality.- Parameters:
aSerialTransceiver
- TheSerialTransceiver
providing theOutputStream
where to write this instance'sSequence
to and providing theInputStream
being the return channel to handle "stop-and-wait ARQ".- Throws:
IOException
- thrown in case writing data to theOutputStream
caused problems.
-
transmitTo
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.- 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
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
.- Returns:
- The
Schema
representation of the implementing type for debugging and verification (or documentation) purposes.
-
toSimpleTypeMap
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.- Returns:
- The
SimpleTypeMap
representing thisTransmission
and (if any) its children, with the according aliases forming the paths to theTransmission
's values.
-
fromInputStream
static byte[] fromInputStream(InputStream aInputStream, int aLength) throws IOException
Retrieves the number of bytes from the givenInputStream
by also trying to read the required number of bytes in chunks (in case not all bytes can be read in one take).- Parameters:
aInputStream
- The byte array data from which to retrieve the bytes.aLength
- The number of bytes to be retrieved.- Returns:
- An array containing the number of bytes.
- Throws:
IOException
- thrown in case reading data from theInputStream
caused problems.
-
-