Interface Section

All Superinterfaces:
org.refcodes.mixin.LengthAccessor, org.refcodes.mixin.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

public interface Section extends Transmission
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.
  • Method Details

    • 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 given Sequence cannot be processed.
    • fromTransmission

      default void fromTransmission(Sequence aSequence, int aLength) throws TransmissionException
      (Re-)initializes this instance with the the given Sequence data.
      Parameters:
      aSequence - The Sequence data from which to (re-)initialize this instance.
      aLength - The length of data assigned by the Sequence.
      Throws:
      TransmissionException - thrown in case a given Sequence cannot 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 given Sequence cannot be processed.
    • fromTransmission

      void fromTransmission(Sequence aSequence, int aOffset, int aLength) throws TransmissionException
      (Re-)initializes this instance with the the given Sequence data.
      Parameters:
      aSequence - The Sequence data from which to (re-)initialize this instance.
      aOffset - The offset where to start processing the provided Sequence.
      aLength - The length of data assigned by the Sequence.
      Throws:
      TransmissionException - thrown in case a given Sequence cannot be processed.
    • receiveFrom

      default void receiveFrom(SerialTransceiver aSerialTransceiver, int aLength) throws IOException
      (Re-)initializes this instance by receiving the according Sequence from the given SerialTransceiver's InputStream. Implementations providing error correction methods use the provided SerialTransceiver's feedback OutputStream to 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 the receiveFrom(InputStream, int, OutputStream) method is invoked). Override receiveFrom(InputStream, int, OutputStream) for your custom receiving functionality.
      Parameters:
      aSerialTransceiver - The SerialTransceiver providing the InputStream where to read this instance's Sequence from and providing the OutputStream being 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 the InputStream caused problems.
      TransmissionException - thrown in case a given InputStream bytes cannot be processed.
    • receiveFrom

      default void receiveFrom(InputStream aInputStream, int aLength) throws IOException
      (Re-)initializes this instance by receiving the according Sequence from the given InputStream. This is a convenience method in case there is no feedback OutputStream available (actually the receiveFrom(InputStream, int, OutputStream) method is invoked with null for the feedback OutputStream). Override receiveFrom(InputStream, int, OutputStream) for your custom receiving functionality.
      Parameters:
      aInputStream - The InputStream from which to read the instance's (re-)initialization Sequence from.
      aLength - The length of data assigned by the byte array.
      Throws:
      IOException - thrown in case reading data from the InputStream caused problems.
      TransmissionException - thrown in case a given InputStream bytes cannot be processed.
    • receiveFrom

      void receiveFrom(InputStream aInputStream, int aLength, OutputStream aReturnStream) throws IOException
      (Re-)initializes this instance by receiving the according Sequence from the given InputStream. Implementations providing error correction methods use the provided feedback OutputStream to do some sort of "stop-and-wait ARQ" or apply similar methods to ensure correctness of the received data.
      Parameters:
      aInputStream - The InputStream from which to read the instance's (re-)initialization Sequence from.
      aLength - The length of data assigned by the byte array.
      aReturnStream - An OutputStream 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 the InputStream caused problems.
      TransmissionException - thrown in case a given InputStream bytes cannot be processed.