- All Superinterfaces:
org.refcodes.mixin.LengthAccessor,org.refcodes.mixin.Resetable,org.refcodes.schema.Schemable,Serializable,Transmission
- All Known Subinterfaces:
ArraySection<ARRAY>,DecoratorSection<DECORATEE>,PayloadSection<T>,Section.SectionMixin
- All Known Implementing Classes:
AbstractPayloadSection,AbstractSectionDecorator,AssertMagicBytesSectionDecorator,BooleanArraySection,BreakerSectionDecorator,ByteArraySection,CharArraySection,CharSection,CipherSectionDecorator,CrcSectionDecorator,DoubleArraySection,DynamicTypeSection,FileSection,FixedSegmentArraySection,FloatArraySection,IntArraySection,InvertibleSectionDecorator,LongArraySection,MagicBytesSectionDecorator,MagicBytesSectionMultiplexer,PropertiesSection,ReadyToReceiveSectionDecorator,ReadyToSendSectionDecorator,SectionComposite,SegmentArraySection,SequenceSection,ShortArraySection,StopAndWaitPacketStreamSectionDecorator,StopAndWaitSectionDecorator,StringArraySection,StringSection
The
Section 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 Transmission.transmitTo(OutputStream, InputStream) and
to initialize with a Sequence representation for itself or to receive
a Sequence representation for itself through an InputStream
(with an optional feedback OutputStream) as of
receiveFrom(InputStream, int, OutputStream). A Section does
not have a predictable length and it cannot (by itself) determine itself's
length from a provided InputStream or Sequence, therefore a
length has to be provided alongside an InputStream or
Sequence.-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceDefault implementation of theSectioninterface providing an implementation of theSection.SectionMixin.receiveFrom(InputStream, int, OutputStream)method using thefromTransmission(Sequence, int)method or thefromTransmission(Sequence, int, int)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.LengthPropertyNested classes/interfaces inherited from interface org.refcodes.serial.Transmission
Transmission.TransmissionMixin -
Method Summary
Modifier and TypeMethodDescriptiondefault voidfromTransmission(byte[] aChunk, int aLength) (Re-)initializes this instance with the the given byte array data.default voidfromTransmission(byte[] aChunk, int aOffset, int aLength) (Re-)initializes this instance with the the given byte array data.default voidfromTransmission(Sequence aSequence, int aLength) (Re-)initializes this instance with the the givenSequencedata.voidfromTransmission(Sequence aSequence, int aOffset, int aLength) (Re-)initializes this instance with the the givenSequencedata.default voidreceiveFrom(InputStream aInputStream, int aLength) (Re-)initializes this instance by receiving the accordingSequencefrom the givenInputStream.voidreceiveFrom(InputStream aInputStream, int aLength, OutputStream aReturnStream) (Re-)initializes this instance by receiving the accordingSequencefrom the givenInputStream.default voidreceiveFrom(SerialTransceiver aSerialTransceiver, int aLength) (Re-)initializes this instance by receiving the accordingSequencefrom the givenSerialTransceiver'sInputStream.Methods inherited from interface org.refcodes.serial.Transmission
getLength, reset, toSchema, toSequence, toSimpleTypeMap, transmitTo, transmitTo, transmitTo
-
Method Details
-
fromTransmission
(Re-)initializes this instance with the the given byte array data.- Parameters:
aChunk- The byte array data from which to (re-)initialize this instance.aLength- The length of data assigned by the byte array.- Throws:
TransmissionException- thrown in case a givenSequencecannot be processed.
-
fromTransmission
(Re-)initializes this instance with the the givenSequencedata.- Parameters:
aSequence- TheSequencedata from which to (re-)initialize this instance.aLength- The length of data assigned by theSequence.- Throws:
TransmissionException- thrown in case a givenSequencecannot be processed.
-
fromTransmission
(Re-)initializes this instance with the the given byte array data.- Parameters:
aChunk- The byte array data from which to (re-)initialize this instance.aOffset- The offset where to start processing the provided byte array.aLength- The length of data assigned by the byte array.- Throws:
TransmissionException- thrown in case a givenSequencecannot be processed.
-
fromTransmission
(Re-)initializes this instance with the the givenSequencedata.- Parameters:
aSequence- TheSequencedata from which to (re-)initialize this instance.aOffset- The offset where to start processing the providedSequence.aLength- The length of data assigned by theSequence.- Throws:
TransmissionException- thrown in case a givenSequencecannot be processed.
-
receiveFrom
(Re-)initializes this instance by receiving the accordingSequencefrom the givenSerialTransceiver'sInputStream. Implementations providing error correction methods use the providedSerialTransceiver's feedbackOutputStreamto do some sort of "stop-and-wait ARQ" or apply similar methods to ensure correctness of the received data. This is a convenience method (actually thereceiveFrom(InputStream, int, OutputStream)method is invoked). OverridereceiveFrom(InputStream, int, OutputStream)for your custom receiving functionality.- Parameters:
aSerialTransceiver- TheSerialTransceiverproviding theInputStreamwhere to read this instance'sSequencefrom and providing theOutputStreambeing the feedback channel to handle "stop-and-wait ARQ".aLength- The length of data assigned by the byte array.- Throws:
IOException- thrown in case reading data from theInputStreamcaused problems.TransmissionException- thrown in case a givenInputStreambytes cannot be processed.
-
receiveFrom
(Re-)initializes this instance by receiving the accordingSequencefrom the givenInputStream. This is a convenience method in case there is no feedbackOutputStreamavailable (actually thereceiveFrom(InputStream, int, OutputStream)method is invoked withnullfor the feedbackOutputStream). OverridereceiveFrom(InputStream, int, OutputStream)for your custom receiving functionality.- Parameters:
aInputStream- TheInputStreamfrom which to read the instance's (re-)initializationSequencefrom.aLength- The length of data assigned by the byte array.- Throws:
IOException- thrown in case reading data from theInputStreamcaused problems.TransmissionException- thrown in case a givenInputStreambytes cannot be processed.
-
receiveFrom
void receiveFrom(InputStream aInputStream, int aLength, OutputStream aReturnStream) throws IOException (Re-)initializes this instance by receiving the accordingSequencefrom the givenInputStream. Implementations providing error correction methods use the provided feedbackOutputStreamto do some sort of "stop-and-wait ARQ" or apply similar methods to ensure correctness of the received data.- Parameters:
aInputStream- TheInputStreamfrom which to read the instance's (re-)initializationSequencefrom.aLength- The length of data assigned by the byte array.aReturnStream- AnOutputStreambeing 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 theInputStreamcaused problems.TransmissionException- thrown in case a givenInputStreambytes cannot be processed.
-