Class AbstractInputStreamByteReceiver

java.lang.Object
org.refcodes.component.AbstractConnectable
org.refcodes.component.AbstractConnectableAutomaton
org.refcodes.io.AbstractInputStreamByteReceiver
All Implemented Interfaces:
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.OpenedAccessor, Availability, ByteDestination, ByteReceiver, BytesDestination, BytesReceiver, Receivable, Skippable, TimeoutInputStreamAccessor, org.refcodes.mixin.InputStreamAccessor
Direct Known Subclasses:
BidirectionalStreamConnectionByteTransceiverImpl, InputStreamConnectionByteReceiverImpl

public abstract class AbstractInputStreamByteReceiver extends org.refcodes.component.AbstractConnectableAutomaton implements BytesReceiver
Abstract implementation of the BytesReceiver interface. The open(InputStream), AbstractConnectableAutomaton.setConnectionStatus(ConnectionStatus) and AbstractConnectableAutomaton.isOpenable() methods are your hooks when extending this class.
  • Constructor Details

    • AbstractInputStreamByteReceiver

      public AbstractInputStreamByteReceiver()
  • Method Details

    • 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.
    • 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.
    • close

      public void close() throws IOException
      Specified by:
      close in interface org.refcodes.component.Closable
      Overrides:
      close in class org.refcodes.component.AbstractConnectableAutomaton
      Throws:
      IOException
    • open

      protected void open(InputStream aInputStream) throws IOException
      Open, see ConnectionOpenable.open(Object).
      Parameters:
      aInputStream - the input stream
      Throws:
      IOException - the open exception
    • isOpenable

      protected boolean isOpenable(InputStream aInputStream)
      Checks if is openable. See also ConnectionOpenable.ConnectionOpenAutomaton.isOpenable(Object).
      Parameters:
      aInputStream - the input stream
      Returns:
      true, if is openable