final class Net2OneChannel<T> extends NetAltingChannelInput<T>
NetChannelInput
,
NetAltingChannelInput
,
NetChannel
Modifier and Type | Field and Description |
---|---|
private ChannelData |
data
The ChannelData structure representing this channel.
|
private AltingChannelInput |
in
The input channel coming into the networked channel input object from Links or locally connected net channel
outputs.
|
private NetworkMessage |
lastRead
The lastRead ChannelMessage.
|
private NetChannelLocation |
location
The location of this channel
|
private NetworkMessageFilter.FilterRx |
messageFilter
The filter used to convert the incoming byte array into an object
|
Modifier | Constructor and Description |
---|---|
private |
Net2OneChannel(AltingChannelInput input,
ChannelData chanData,
NetworkMessageFilter.FilterRx filter)
Private constructor for creating a new instance of a Net2OneChannel.
|
Modifier and Type | Method and Description |
---|---|
(package private) static <T2> Net2OneChannel<T2> |
create(int index,
int poisonImmunity,
NetworkMessageFilter.FilterRx filter)
Static factory method used to create a new Net2OneChannel with a given index.
|
(package private) static <T2> Net2OneChannel<T2> |
create(int poisonImmunity,
NetworkMessageFilter.FilterRx filter)
Static factory method used to create a new Net2OneChannel.
|
void |
destroy()
Destroys the underlying channel
|
void |
endRead()
Ends an extended read operation.
|
(package private) ChannelData |
getChannelData()
Gets the channel data object for this channel.
|
NetLocation |
getLocation()
Returns the NetChannelLocation of the channel
|
boolean |
pending()
Checks if any data is waiting on the channel.
|
void |
poison(int strength)
Poisons the underlying channel
|
T |
read()
Reads the next message from the channel
|
void |
setDecoder(NetworkMessageFilter.FilterRx decoder)
Sets the underlying message filter
|
T |
startRead()
Performs an extended read operation on the channel
|
getChannel, setChannel
private final AltingChannelInput in
private final ChannelData data
private NetworkMessage lastRead
private NetworkMessageFilter.FilterRx messageFilter
private final NetChannelLocation location
private Net2OneChannel(AltingChannelInput input, ChannelData chanData, NetworkMessageFilter.FilterRx filter) throws JCSPNetworkException
input
- The input channel connecting to the networked channel.chanData
- The ChannelData object representing the networked channel.filter
- The filter used to convert the incoming byte array to an objectJCSPNetworkException
static <T2> Net2OneChannel<T2> create(int poisonImmunity, NetworkMessageFilter.FilterRx filter)
poisonImmunity
- The immunity level of the channelfilter
- The filter on the channel used to convert read bytes into an objectstatic <T2> Net2OneChannel<T2> create(int index, int poisonImmunity, NetworkMessageFilter.FilterRx filter) throws java.lang.IllegalArgumentException
index
- The index to create the channel withpoisonImmunity
- The immunity level of the channelfilter
- The filter used to take the incoming byte array and convert it into an objectjava.lang.IllegalArgumentException
- Thrown if the index given is already allocated within the ChannelManagerpublic void endRead() throws java.lang.IllegalStateException, JCSPNetworkException, NetworkPoisonException
endRead
in interface ChannelInput<T>
endRead
in class AltingChannelInputWrapper<T>
java.lang.IllegalStateException
- Thrown if the method is called when the channel is not in an extended read stateJCSPNetworkException
- Thrown if something goes wrong in the underlying architectureNetworkPoisonException
- Thrown if the channel has been poisonedChannelInput.endRead
public boolean pending() throws JCSPNetworkException, NetworkPoisonException
pending
in class AltingChannelInputWrapper<T>
JCSPNetworkException
- Thrown if the channel has been destroyedNetworkPoisonException
- Thrown if the channel has poisonedpublic void poison(int strength)
poison
in interface Poisonable
poison
in class AltingChannelInputWrapper<T>
strength
- The strength of the poisonpublic T read() throws JCSPNetworkException, NetworkPoisonException, java.lang.IllegalStateException
read
in interface ChannelInput<T>
read
in class AltingChannelInputWrapper<T>
JCSPNetworkException
- Thrown if something goes wrong in the underlying architectureNetworkPoisonException
- Thrown if the channel is poisonedjava.lang.IllegalStateException
- Thrown if the channel is in an extended read statepublic T startRead() throws JCSPNetworkException, java.lang.IllegalStateException, NetworkPoisonException
startRead
in interface ChannelInput<T>
startRead
in class AltingChannelInputWrapper<T>
JCSPNetworkException
- Thrown if something goes wrong in the underlying architecturejava.lang.IllegalStateException
- Thrown if the channel is already in an extended read stateNetworkPoisonException
- Thrown if the channel is poisoned.ChannelInput.startRead
public NetLocation getLocation()
public void destroy()
final ChannelData getChannelData()
public void setDecoder(NetworkMessageFilter.FilterRx decoder)
decoder
- The message filter to use