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
AbstractPrefetchInputStreamByteReceiver
, ByteArrayReceiver
, BytesReceiverDecorator
, LoopbackBytesReceiver
, LoopbackBytesTransceiver
public abstract class AbstractBytesReceiver extends AbstractBytesDestination implements BytesReceiver
AbstractBytesReceiver
is a base abstract implementation of the
BytesReceiver
interface providing common functionality for concrete
real live implementations.Modifier and Type | Class | Description |
---|---|---|
protected static class |
AbstractBytesReceiver.ConnectableAutomaton |
The Class ConnectableAutomaton.
|
BytesReceiver.ReceiverInputStream
org.refcodes.component.Closable.CloseAutomaton, org.refcodes.component.Closable.CloseBuilder<B extends org.refcodes.component.Closable.CloseBuilder<B>>
org.refcodes.component.ClosedAccessor.ClosedMutator, org.refcodes.component.ClosedAccessor.ClosedProperty
org.refcodes.component.ConnectionStatusAccessor.ConnectionStatusMutator, org.refcodes.component.ConnectionStatusAccessor.ConnectionStatusProperty
org.refcodes.mixin.InputStreamAccessor.InputStreamBuilder<B extends org.refcodes.mixin.InputStreamAccessor.InputStreamBuilder<?>>, org.refcodes.mixin.InputStreamAccessor.InputStreamMutator, org.refcodes.mixin.InputStreamAccessor.InputStreamProperty
org.refcodes.component.OpenedAccessor.OpenedMutator, org.refcodes.component.OpenedAccessor.OpenedProperty
TimeoutInputStreamAccessor.TimeoutInputStreamBuilder<B extends TimeoutInputStreamAccessor.TimeoutInputStreamBuilder<?>>, TimeoutInputStreamAccessor.TimeoutInputStreamMutator, TimeoutInputStreamAccessor.TimeoutInputStreamProperty
Modifier and Type | Field | Description |
---|---|---|
protected AbstractBytesReceiver.ConnectableAutomaton |
_automaton |
_datagramQueue, DATAGRAM_QUEUE_SIZE
Constructor | Description |
---|---|
AbstractBytesReceiver() |
Constructs a
AbstractBytesReceiver with a default sized blocking
queue enabling a maximum of AbstractBytesDestination.DATAGRAM_QUEUE_SIZE datagrams.
-------------------------------------------------------------------------
Make sure your code fetches the datagrams quick enough to prevent filling
up of the queue. |
AbstractBytesReceiver(int aCapacity) |
Constructs a
AbstractBytesReceiver with a custom sized blocking
queue enabling a maximum of datagrams as specified by the capacity
parameter.
-------------------------------------------------------------------------
Make sure your code fetches the datagrams quick enough to prevent filling
up of the queue. |
Modifier and Type | Method | Description |
---|---|---|
int |
available() |
Determines the number of available datagram from a
DatagramTransmitter . |
void |
close() |
|
org.refcodes.component.ConnectionStatus |
getConnectionStatus() |
|
boolean |
isClosable() |
|
boolean |
isClosed() |
|
protected boolean |
isOpenable() |
Checks if is openable.
|
boolean |
isOpened() |
|
protected void |
open() |
Open.
|
byte[] |
receiveAllBytes() |
Reads (receives) the all currently available data.
|
byte |
receiveByte() |
Reads (receives) the next byte, in case none byte is available, then this
method blocks until one is available.
|
byte[] |
receiveBytes(int aMaxLength) |
Similar to
BytesDestination.receiveAllBytes() though at maximum the amount of
data as of the provided length returned. |
protected void |
setConnectionStatus(org.refcodes.component.ConnectionStatus aConnectionStatus) |
Sets the connection status.
|
pushDatagram, pushDatagrams, pushDatagrams
hasAvailable
receiveBytes
getInputStream, getInputStream, receiveBytesWithin, receiveBytesWithin, receiveByteWithin, skip
closeIn, closeQuietly, closeUnchecked
alert, alert, critical, critical, debug, error, info, notice, panic, trace, warn, warn
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
skipAvailable, skipAvailableExcept, skipAvailableTill, skipAvailableTillSilenceFor, skipAvailableTillSilenceFor, skipAvailableWithin, skipAvailableWithin
protected AbstractBytesReceiver.ConnectableAutomaton _automaton
public AbstractBytesReceiver()
AbstractBytesReceiver
with a default sized blocking
queue enabling a maximum of AbstractBytesDestination.DATAGRAM_QUEUE_SIZE
datagrams.
-------------------------------------------------------------------------
Make sure your code fetches the datagrams quick enough to prevent filling
up of the queue. In case the queue is filled up, adding elements via
AbstractBytesDestination.pushDatagram(byte)
to the queue is blocked until elements are
taken from the queue via receiveByte()
.public AbstractBytesReceiver(int aCapacity)
AbstractBytesReceiver
with a custom sized blocking
queue enabling a maximum of datagrams as specified by the capacity
parameter.
-------------------------------------------------------------------------
Make sure your code fetches the datagrams quick enough to prevent filling
up of the queue. In case the queue is filled up, adding elements via
AbstractBytesDestination.pushDatagram(byte)
to the queue is blocked until elements are
taken from the queue via receiveByte()
.aCapacity
- The capacity of the queue holding the received
datagrams.public byte receiveByte() throws IOException
receiveByte
in interface ByteDestination
receiveByte
in interface BytesDestination
receiveByte
in class AbstractBytesDestination
IOException
- Thrown in case opening or accessing an open line
(connection, junction, link) caused problems.public byte[] receiveAllBytes() throws IOException
receiveAllBytes
in interface BytesDestination
receiveAllBytes
in interface BytesReceiver
receiveAllBytes
in class AbstractBytesDestination
DatagramsTransmitter
or DatagramReceiver
counterpart.IOException
- Thrown in case opening or accessing an open line
(connection, junction, link) caused problems.public byte[] receiveBytes(int aMaxLength) throws IOException
BytesDestination.receiveAllBytes()
though at maximum the amount of
data as of the provided length returned.receiveBytes
in interface BytesDestination
receiveBytes
in interface BytesReceiver
receiveBytes
in class AbstractBytesDestination
aMaxLength
- The block-size which is not to exceeded by the returned
data. A value of -1 specifies to retrieve all available datagrams
(same behavior as method BytesDestination.receiveAllBytes()
.DatagramsTransmitter
or DatagramReceiver
counterpart.IOException
- Thrown in case opening or accessing an open line
(connection, junction, link) caused problems.public int available() throws IOException
DatagramTransmitter
. Use the DatagramDestination
extenison's DatagramDestination.receive()
method for retrieving
available datagrams.available
in interface Availability
available
in interface Skippable
IOException
- Thrown in case opening or accessing an open line
(connection, junction, link) caused problems.public void close() throws IOException
close
in interface org.refcodes.component.Closable
IOException
public boolean isOpened()
isOpened
in interface org.refcodes.component.ConnectionStatusAccessor
isOpened
in interface org.refcodes.component.OpenedAccessor
public boolean isClosable()
isClosable
in interface org.refcodes.component.Closable.CloseAutomaton
public boolean isClosed()
isClosed
in interface org.refcodes.component.ClosedAccessor
public org.refcodes.component.ConnectionStatus getConnectionStatus()
getConnectionStatus
in interface org.refcodes.component.ConnectionStatusAccessor
protected void open() throws IOException
IOException
- the open exceptionprotected void setConnectionStatus(org.refcodes.component.ConnectionStatus aConnectionStatus)
aConnectionStatus
- the new connection statusprotected boolean isOpenable()
Copyright © 2021. All rights reserved.