public class Mailbox extends AbstractReceiver
Green (neuendor) |
Green (eal) |
Constructor and Description |
---|
Mailbox()
Construct an empty Mailbox with no container.
|
Mailbox(IOPort container)
Construct an empty Mailbox with the specified container.
|
Modifier and Type | Method and Description |
---|---|
void |
clear()
Clear this receiver of any contained token.
|
java.util.List<Token> |
elementList()
Return a list with the token currently in the receiver, or
an empty list if there is no such token.
|
Token |
get()
Get the contained Token.
|
boolean |
hasRoom()
Return true if this mailbox is empty.
|
boolean |
hasRoom(int numberOfTokens)
Return true if the argument is 1 and the mailbox is empty,
and otherwise return false.
|
boolean |
hasToken()
Return true if this mailbox is not empty.
|
boolean |
hasToken(int numberOfTokens)
Return true if the argument is 1 and this mailbox is not empty,
and otherwise return false.
|
void |
put(Token token)
Put a token into the mailbox.
|
getArray, getContainer, getCurrentTime, getModelTime, isKnown, putArray, putArrayToAll, putToAll, reset, setContainer, toString
protected Token _token
public Mailbox()
public Mailbox(IOPort container) throws IllegalActionException
container
- The container.IllegalActionException
- If the container does
not accept this receiver.public void clear() throws IllegalActionException
clear
in interface Receiver
clear
in class AbstractReceiver
IllegalActionException
- If a derived class throws it (not
thrown in this base class).public java.util.List<Token> elementList()
elementList
in interface Receiver
elementList
in class AbstractReceiver
public Token get() throws NoTokenException
get
in interface Receiver
get
in class AbstractReceiver
NoTokenException
- If this mailbox is empty.public boolean hasRoom()
hasRoom
in interface Receiver
hasRoom
in class AbstractReceiver
public boolean hasRoom(int numberOfTokens) throws java.lang.IllegalArgumentException
hasRoom
in interface Receiver
hasRoom
in class AbstractReceiver
numberOfTokens
- The number of tokens to put into the mailbox.java.lang.IllegalArgumentException
- If the argument is not positive.
This is a runtime exception, so it does not need to be declared
explicitly.public boolean hasToken()
hasToken
in interface Receiver
hasToken
in class AbstractReceiver
public boolean hasToken(int numberOfTokens) throws java.lang.IllegalArgumentException
hasToken
in interface Receiver
hasToken
in class AbstractReceiver
numberOfTokens
- The number of tokens to get from the receiver.java.lang.IllegalArgumentException
- If the argument is not positive.
This is a runtime exception, so it does not need to be declared
explicitly.public void put(Token token) throws NoRoomException
put
in interface Receiver
put
in class AbstractReceiver
token
- The token to be put into the mailbox.NoRoomException
- If this mailbox is not empty.