public interface Receiver
All implementations of this interface must follow these rules, regardless of the number of threads that are accessing the receiver:
Objects that implement this interface can only be contained by an instance of IOPort.
Token
Modifier and Type | Method and Description |
---|---|
void |
clear()
Clear this receiver of any contained tokens.
|
java.util.List<Token> |
elementList()
Return a list with tokens that are currently in the receiver
available for get() or getArray().
|
Token |
get()
Get a token from this receiver.
|
Token[] |
getArray(int numberOfTokens)
Get an array of tokens from this receiver.
|
IOPort |
getContainer()
Return the container of this receiver, or null if there is none.
|
boolean |
hasRoom()
Return true if the receiver has room to put a token into it
(via the put() method).
|
boolean |
hasRoom(int numberOfTokens)
Return true if the receiver has room to put the specified number of
tokens into it (via the put() method).
|
boolean |
hasToken()
Return true if the receiver contains a token that can be obtained
by calling the get() method.
|
boolean |
hasToken(int numberOfTokens)
Return true if the receiver contains the specified number of tokens.
|
boolean |
isKnown()
Return true if this receiver has known state;
that is, the tokens in this receiver are known, or this
receiver is known not to contain any tokens.
|
void |
put(Token token)
Put the specified token into this receiver.
|
void |
putArray(Token[] tokenArray,
int numberOfTokens)
Put a portion of the specified token array into this receiver.
|
void |
putArrayToAll(Token[] tokens,
int numberOfTokens,
Receiver[] receivers)
Put a sequence of tokens to all receivers in the specified array.
|
void |
putToAll(Token token,
Receiver[] receivers)
Put a single token to all receivers in the specified array.
|
void |
reset()
Reset this receiver to its initial state, which is typically
either empty (same as calling clear()) or unknown.
|
void |
setContainer(IOPort port)
Set the container.
|
void clear() throws IllegalActionException
IllegalActionException
- If clear() is not supported by
the domain.java.util.List<Token> elementList() throws IllegalActionException
IllegalActionException
- If the operation is not supported.Token get() throws NoTokenException
NoTokenException
- If there is no token.Token[] getArray(int numberOfTokens) throws NoTokenException
numberOfTokens
- The number of tokens to get in the
returned array.NoTokenException
- If there are not numberOfTokens
tokens.IOPort getContainer()
setContainer(IOPort)
boolean hasRoom()
boolean hasRoom(int numberOfTokens)
numberOfTokens
- The number of tokens to put into this receiver.boolean hasToken()
boolean hasToken(int numberOfTokens)
numberOfTokens
- The number of tokens desired.boolean isKnown()
void put(Token token) throws NoRoomException, IllegalActionException
token
- The token to put into the receiver, or null to
put no token.NoRoomException
- If there is no room in the receiver.IllegalActionException
- If the token is not acceptable
to one of the ports (e.g., wrong type).void putArray(Token[] tokenArray, int numberOfTokens) throws NoRoomException, IllegalActionException
tokenArray
- The array containing tokens to put into this
receiver.numberOfTokens
- The number of elements of the token
array to put into this receiver.NoRoomException
- If the token array cannot be put.IllegalActionException
- If the token is not acceptable
to one of the ports (e.g., wrong type).void putArrayToAll(Token[] tokens, int numberOfTokens, Receiver[] receivers) throws NoRoomException, IllegalActionException
tokens
- The sequence of token to put.numberOfTokens
- The number of tokens to put (the array might
be longer).receivers
- The receivers.NoRoomException
- If there is no room for the token.IllegalActionException
- If the token is not acceptable
to one of the ports (e.g., wrong type).void putToAll(Token token, Receiver[] receivers) throws NoRoomException, IllegalActionException
token
- The token to put, or null to send no token.receivers
- The receivers.NoRoomException
- If there is no room for the token.IllegalActionException
- If the token is not acceptable
to one of the ports (e.g., wrong type).void reset() throws IllegalActionException
IllegalActionException
- If reset() is not supported by
the domain.void setContainer(IOPort port) throws IllegalActionException
port
- The container.IllegalActionException
- If the container is not of
an appropriate subclass of IOPort for the particular receiver
implementation.getContainer()