Class BidirectionalStreamByteTransceiver

java.lang.Object
org.refcodes.io.BidirectionalStreamByteTransceiver
All Implemented Interfaces:
Flushable, org.refcodes.component.Closable, org.refcodes.component.Closable.CloseAutomaton, org.refcodes.component.ClosedAccessor, org.refcodes.component.ConnectableComponent, org.refcodes.component.ConnectableComponent.ConnectableAutomaton, org.refcodes.component.ConnectionStatusAccessor, org.refcodes.component.Flushable, org.refcodes.component.OpenedAccessor, Availability, ByteDestination, ByteReceiver, BytesDestination, ByteSource, BytesReceiver, BytesSource, BytesTransceiver, BytesTransmitter, ByteTransceiver, ByteTransmitter, Receivable, Skippable, TimeoutInputStreamAccessor, Transmittable, org.refcodes.mixin.InputStreamAccessor, org.refcodes.mixin.OutputStreamAccessor

public class BidirectionalStreamByteTransceiver extends Object implements BytesTransceiver
The Class BidirectionalStreamByteTransceiver.
Author:
steiner
  • Constructor Details

    • BidirectionalStreamByteTransceiver

      public BidirectionalStreamByteTransceiver(InputStream aInputStream, OutputStream aOutputStream) throws IOException
      Instantiates a new bidirectional stream byte transceiver impl.
      Parameters:
      aInputStream - the input stream
      aOutputStream - the output stream
      Throws:
      IOException - the open exception
  • Method Details

    • isClosed

      public boolean isClosed()
      Specified by:
      isClosed in interface org.refcodes.component.ClosedAccessor
    • isOpened

      public boolean isOpened()
      Specified by:
      isOpened in interface org.refcodes.component.ConnectionStatusAccessor
      Specified by:
      isOpened in interface org.refcodes.component.OpenedAccessor
    • available

      public int available() throws IOException
      Determines the number of available datagram from a DatagramTransmitter. Use the DatagramDestination extenison's DatagramDestination.receive() method for retrieving available datagrams.
      Specified by:
      available in interface Availability
      Specified by:
      available in interface Skippable
      Returns:
      The number of datagrams ready to be retrieved .
      Throws:
      IOException - Thrown in case opening or accessing an open line (connection, junction, link) caused problems.
    • receiveAllBytes

      public byte[] receiveAllBytes() throws IOException
      Reads (receives) the all currently available data.
      Specified by:
      receiveAllBytes in interface BytesDestination
      Specified by:
      receiveAllBytes in interface BytesReceiver
      Returns:
      The according data.
      Throws:
      IOException - Thrown in case opening or accessing an open line (connection, junction, link) caused problems.
      EOFException - Signals that an end of file or end of stream has been reached unexpectedly during input.
    • getConnectionStatus

      public org.refcodes.component.ConnectionStatus getConnectionStatus()
      Specified by:
      getConnectionStatus in interface org.refcodes.component.ConnectionStatusAccessor
    • close

      public void close() throws IOException
      Specified by:
      close in interface org.refcodes.component.Closable
      Throws:
      IOException
    • receiveByte

      public byte receiveByte() throws IOException
      Reads (receives) the next byte, in case none byte is available, then this method blocks until one is available.
      Specified by:
      receiveByte in interface ByteDestination
      Specified by:
      receiveByte in interface BytesDestination
      Returns:
      The next byte available .
      Throws:
      IOException - Thrown in case opening or accessing an open line (connection, junction, link) caused problems.
      EOFException - Signals that an end of file or end of stream has been reached unexpectedly during input.
    • transmitAllBytes

      public void transmitAllBytes(byte[] aDatagram) throws IOException
      Writes (sends) a byte block.
      Specified by:
      transmitAllBytes in interface BytesSource
      Parameters:
      aDatagram - The byte to be pushed.
      Throws:
      IOException - Thrown in case opening or accessing an open line (connection, junction, link) caused problems.
    • transmitBytes

      public void transmitBytes(byte[] aDatagram, int aOffset, int aLength) throws IOException
      Writes (sends) a byte block.
      Specified by:
      transmitBytes in interface BytesSource
      Specified by:
      transmitBytes in interface BytesTransmitter
      Parameters:
      aDatagram - The byte to be pushed.
      aOffset - The offset from which to take the data.
      aLength - The number of elements to push starting at the given offset.
      Throws:
      IOException - Thrown in case opening or accessing an open line (connection, junction, link) caused problems.
    • transmitByte

      public void transmitByte(byte aByte) throws IOException
      Writes (sends) a byte.
      Specified by:
      transmitByte in interface ByteSource
      Specified by:
      transmitByte in interface BytesSource
      Parameters:
      aByte - The byte to be pushed.
      Throws:
      IOException - Thrown in case opening or accessing an open line (connection, junction, link) caused problems.
    • flush

      public void flush() throws IOException
      Specified by:
      flush in interface ByteTransmitter
      Specified by:
      flush in interface Flushable
      Specified by:
      flush in interface org.refcodes.component.Flushable
      Throws:
      IOException
    • isClosable

      public boolean isClosable()
      Specified by:
      isClosable in interface org.refcodes.component.Closable.CloseAutomaton