-
- All Superinterfaces:
org.refcodes.mixin.LengthAccessor,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
public interface Section extends Transmission
TheSectioninterface enables an implementing type to provide aSequencerepresentation of itself or to transmit itsSequencerepresentation through anOutputStream(with an optional feedbackInputStream) as ofTransmission.transmitTo(OutputStream, InputStream)and to initialize with aSequencerepresentation for itself or to receive aSequencerepresentation for itself through anInputStream(with an optional feedbackOutputStream) as ofreceiveFrom(InputStream, int, OutputStream). ASectiondoes not have a predictable length and it cannot (by itself) determine itself's length from a providedInputStreamorSequence, therefore a length has to be provided alongside anInputStreamorSequence.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceSection.SectionMixinDefault 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.LengthProperty
-
Nested classes/interfaces inherited from interface org.refcodes.serial.Transmission
Transmission.TransmissionMixin
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default 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, toSchema, toSequence, toSimpleTypeMap, transmitTo, transmitTo, transmitTo
-
-
-
-
Method Detail
-
fromTransmission
default void fromTransmission(byte[] aChunk, int aLength) throws TransmissionException(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
default void fromTransmission(Sequence aSequence, int aLength) throws TransmissionException
(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
default void fromTransmission(byte[] aChunk, int aOffset, int aLength) throws TransmissionException(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
void fromTransmission(Sequence aSequence, int aOffset, int aLength) throws TransmissionException
(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
default void receiveFrom(SerialTransceiver aSerialTransceiver, int aLength) throws IOException, TransmissionException
(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
default void receiveFrom(InputStream aInputStream, int aLength) throws IOException, TransmissionException
(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, TransmissionException
(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.
-
-