- All Superinterfaces:
org.refcodes.mixin.LengthAccessor,org.refcodes.mixin.Resetable,org.refcodes.schema.Schemable,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,EnumSegment,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, org.refcodes.mixin.Resetable, Serializable, org.refcodes.schema.Schemable
The
Transmission interface enables an implementing type to provide a
Sequence representation of itself or to transmit its Sequence
representation through an OutputStream (with an optional feedback
InputStream) as of transmitTo(OutputStream, InputStream).
Usually, an implementation of the Transmission interface actually
either implements the Segment interface or the Section
interface which both share the Transmission super-interface. (this
interface is Serializable in order to achieve a deep copy the easy
way which is required by the ComplexTypeSegment and the
FixedSegmentArraySection).-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceDefault implementation of theTransmissioninterface providing an implementation of theTransmission.TransmissionMixin.transmitTo(OutputStream, InputStream)method using thetoSequence()method.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 -
Method Summary
Modifier and TypeMethodDescriptionstatic byte[]fromInputStream(InputStream aInputStream, int aLength) Retrieves the number of bytes from the givenInputStreamby also trying to read the required number of bytes in chunks (in case not all bytes can be read in one take).intDetermines the overall length of thisTransmission.voidreset()Resets any dynamic data (e.g. values such as payloads or checksums) and must not(!)toSchema()Provides theSequencerepresentation of thisTransmission.org.refcodes.struct.SimpleTypeMapReturns theSimpleTypeMaprepresentation of thisTransmission.default voidtransmitTo(OutputStream aOutputStream) Transmits theSequencerepresenting the implementing type's instance to the givenOutputStream.voidtransmitTo(OutputStream aOutputStream, InputStream aReturnStream) Transmits theSequencerepresenting the implementing type's instance to the givenOutputStream.default voidtransmitTo(SerialTransceiver aSerialTransceiver) Transmits theSequencerepresenting the implementing type's instance to the givenSerialTransceiver'sOutputStream.
-
Method Details
-
getLength
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- Returns:
- The (overall) length of the
Transmission(including any sub-segments).
-
toSequence
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.- Returns:
- The according instance's
Sequence.
-
transmitTo
Transmits theSequencerepresenting the implementing type's instance to the givenOutputStream. This is a convenience method in case there is no feedbackInputStreamavailable (actually thetransmitTo(OutputStream, InputStream)method is invoked withnullfor the feedbackInputStream). OverridetransmitTo(OutputStream, InputStream)for your custom transmitting functionality.- Parameters:
aOutputStream- TheOutputStreamwhere to write this instance'sSequenceto.- Throws:
IOException- thrown in case writing data to theOutputStreamcaused problems.
-
transmitTo
Transmits theSequencerepresenting the implementing type's instance to the givenSerialTransceiver'sOutputStream. Implementations providing error correction methods use the providedSerialTransceiver's feedbackInputStreamto 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- TheSerialTransceiverproviding theOutputStreamwhere to write this instance'sSequenceto and providing theInputStreambeing the return channel to handle "stop-and-wait ARQ".- Throws:
IOException- thrown in case writing data to theOutputStreamcaused problems.
-
transmitTo
Transmits theSequencerepresenting the implementing type's instance to the givenOutputStream. Implementations providing error correction methods use the provided feedbackInputStreamto do some sort of "stop-and-wait ARQ" or apply similar methods to ensure correctness of the transmitted data.- Parameters:
aOutputStream- TheOutputStreamwhere to write this instance'sSequenceto.aReturnStream- AnInputStreambeing 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 theOutputStreamcaused problems.
-
reset
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:
resetin interfaceorg.refcodes.mixin.Resetable
-
toSchema
SerialSchema toSchema()- Specified by:
toSchemain interfaceorg.refcodes.schema.Schemable
-
toSimpleTypeMap
org.refcodes.struct.SimpleTypeMap toSimpleTypeMap()Returns theSimpleTypeMaprepresentation of thisTransmission. In case this Transmission hasTransmissionchildren, then the children are queried as well and contained in the resultingSimpleTypeMap. The aliases of the accordingTransmissioninstances represent the resulting path to aTransmission's final simple type.- Returns:
- The
SimpleTypeMaprepresenting thisTransmissionand (if any) its children, with the according aliases forming the paths to theTransmission's values.
-
fromInputStream
Retrieves the number of bytes from the givenInputStreamby 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 theInputStreamcaused problems.
-