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 Tokenget()Get a token from this receiver.booleanhasRoom()Return true if the receiver has room to put a token into it (via the put() method).booleanhasRoom(int numberOfTokens)Return true if the receiver has room to put the specified number of tokens into it (via the put() method).booleanhasToken()Return true if the receiver contains a token that can be obtained by calling the get() method.booleanhasToken(int numberOfTokens)Return true if the receiver contains the specified number of tokens.booleanisKnown()Return true.voidput(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:
getin interfaceReceiver- Specified by:
getin 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:
hasRoomin interfaceReceiver- Specified by:
hasRoomin 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:
hasRoomin interfaceReceiver- Specified by:
hasRoomin 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:
hasTokenin interfaceReceiver- Specified by:
hasTokenin 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:
hasTokenin interfaceReceiver- Specified by:
hasTokenin 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:
isKnownin interfaceReceiver- Overrides:
isKnownin classAbstractReceiver- Returns:
- True.
-
put
public void put(Token token) throws NoRoomException, IllegalActionException
Put the specified token into this receiver.- Specified by:
putin interfaceReceiver- Specified by:
putin 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).
-
-