Package ptolemy.actor.test
Class TestAbstractReceiver
- java.lang.Object
-
- ptolemy.actor.AbstractReceiver
-
- ptolemy.actor.test.TestAbstractReceiver
-
- All Implemented Interfaces:
Receiver
public class TestAbstractReceiver extends AbstractReceiver
Test AbstractReceiver.- Since:
- Ptolemy II 5.2
- Version:
- $Id$
- Author:
- Christopher Brooks
- Pt.AcceptedRating:
- Red (cxh)
- Pt.ProposedRating:
- Red (cxh)
-
-
Constructor Summary
Constructors Constructor Description TestAbstractReceiver(IOPort container)
Construct an empty receiver with the specified container.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Token
get()
Get a token from this receiver.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.void
put(Token token)
Put the specified token into this receiver.-
Methods inherited from class ptolemy.actor.AbstractReceiver
clear, elementList, getArray, getContainer, getCurrentTime, getModelTime, putArray, putArrayToAll, putToAll, reset, setContainer, toString
-
-
-
-
Constructor Detail
-
TestAbstractReceiver
public TestAbstractReceiver(IOPort container) throws IllegalActionException
Construct an empty receiver with the specified container.- Parameters:
container
- The container of the receiver.- Throws:
IllegalActionException
- If the container does not accept this receiver.
-
-
Method Detail
-
get
public Token get() throws NoTokenException
Get a token from this receiver.- Specified by:
get
in interfaceReceiver
- Specified by:
get
in classAbstractReceiver
- Returns:
- A token read from the receiver.
- Throws:
NoTokenException
- If there is no token.
-
hasRoom
public boolean hasRoom()
Return true if the receiver has room to put a token into it (via the put() method). Returning true in this method guarantees that the next call to put() will not result in an exception.- Specified by:
hasRoom
in interfaceReceiver
- Specified by:
hasRoom
in classAbstractReceiver
- Returns:
- True
-
hasRoom
public boolean hasRoom(int numberOfTokens)
Return true if the receiver has room to put the specified number of tokens into it (via the put() method). Returning true in this method guarantees that the next numberOfTokens calls to put() or a corresponding call to putArray() will not result in an exception.- Specified by:
hasRoom
in interfaceReceiver
- Specified by:
hasRoom
in classAbstractReceiver
- Parameters:
numberOfTokens
- The number of tokens to put into this receiver.- Returns:
- True
-
hasToken
public boolean hasToken()
Return true if the receiver contains a token that can be obtained by calling the get() method. In an implementation, returning true in this method guarantees that the next call to get() will not result in an exception.- Specified by:
hasToken
in interfaceReceiver
- Specified by:
hasToken
in classAbstractReceiver
- Returns:
- True
-
hasToken
public boolean hasToken(int numberOfTokens)
Return true if the receiver contains the specified number of tokens. In an implementation, returning true in this method guarantees that the next numberOfTokens calls to get(), or a corresponding call to getArray(), will not result in an exception.- Specified by:
hasToken
in interfaceReceiver
- Specified by:
hasToken
in classAbstractReceiver
- Parameters:
numberOfTokens
- The number of tokens desired.- Returns:
- True
-
isKnown
public boolean isKnown()
Return true. Most domains have no notion of the state of the receiver being unknown. It is always known whether there is a token available. Certain domains with fixed point semantics, however, such as SR, will need to override this method.- Specified by:
isKnown
in interfaceReceiver
- Overrides:
isKnown
in classAbstractReceiver
- Returns:
- True.
-
put
public void put(Token token) throws NoRoomException, IllegalActionException
Put the specified token into this receiver.- Specified by:
put
in interfaceReceiver
- Specified by:
put
in classAbstractReceiver
- Parameters:
token
- The token to put into the receiver.- Throws:
NoRoomException
- If there is no room in the receiver.IllegalActionException
- If the put fails (e.g. because of incompatible types).
-
-