001/* Test AbstractReceiver 002 003 Copyright (c) 2006-2014 The Regents of the University of California. 004 All rights reserved. 005 Permission is hereby granted, without written agreement and without 006 license or royalty fees, to use, copy, modify, and distribute this 007 software and its documentation for any purpose, provided that the above 008 copyright notice and the following two paragraphs appear in all copies 009 of this software. 010 011 IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY 012 FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES 013 ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF 014 THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF 015 SUCH DAMAGE. 016 017 THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, 018 INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 019 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE 020 PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF 021 CALIFORNIA HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, 022 ENHANCEMENTS, OR MODIFICATIONS. 023 024 PT_COPYRIGHT_VERSION_2 025 COPYRIGHTENDKEY 026 027 028 */ 029package ptolemy.actor.test; 030 031import ptolemy.actor.AbstractReceiver; 032import ptolemy.actor.IOPort; 033import ptolemy.actor.NoRoomException; 034import ptolemy.actor.NoTokenException; 035import ptolemy.data.Token; 036import ptolemy.kernel.util.IllegalActionException; 037 038/////////////////////////////////////////////////////////////////// 039//// TestAbstractReceiver 040 041/** 042 Test AbstractReceiver. 043 044 @author Christopher Brooks 045 @version $Id$ 046 @since Ptolemy II 5.2 047 @Pt.ProposedRating Red (cxh) 048 @Pt.AcceptedRating Red (cxh) 049 */ 050public class TestAbstractReceiver extends AbstractReceiver { 051 /** Construct an empty receiver with the specified container. 052 * @param container The container of the receiver. 053 * @exception IllegalActionException If the container does 054 * not accept this receiver. 055 */ 056 public TestAbstractReceiver(IOPort container) 057 throws IllegalActionException { 058 super(container); 059 } 060 061 /////////////////////////////////////////////////////////////////// 062 //// public methods //// 063 064 /** Get a token from this receiver. 065 * @exception NoTokenException If there is no token. 066 */ 067 @Override 068 public Token get() throws NoTokenException { 069 return null; 070 } 071 072 /** Return true if the receiver has room to put a token into it 073 * (via the put() method). 074 * Returning true in this method guarantees that the next call to 075 * put() will not result in an exception. 076 * @return True 077 */ 078 @Override 079 public boolean hasRoom() { 080 return true; 081 } 082 083 /** Return true if the receiver has room to put the specified number of 084 * tokens into it (via the put() method). 085 * Returning true in this method guarantees that the next 086 * <i>numberOfTokens</i> calls to put() or a corresponding call 087 * to putArray() will not result in an exception. 088 * @param numberOfTokens The number of tokens to put into this receiver. 089 * @return True 090 */ 091 @Override 092 public boolean hasRoom(int numberOfTokens) { 093 return true; 094 } 095 096 /** Return true if the receiver contains a token that can be obtained 097 * by calling the get() method. In an implementation, 098 * returning true in this method guarantees that the next 099 * call to get() will not result in an exception. 100 * @return True 101 */ 102 @Override 103 public boolean hasToken() { 104 return true; 105 } 106 107 /** Return true if the receiver contains the specified number of tokens. 108 * In an implementation, returning true in this method guarantees 109 * that the next <i>numberOfTokens</i> calls to get(), or a 110 * corresponding call to getArray(), will not result in an exception. 111 * @param numberOfTokens The number of tokens desired. 112 * @return True 113 */ 114 @Override 115 public boolean hasToken(int numberOfTokens) { 116 return true; 117 } 118 119 /** Return <i>true</i>. Most domains have no notion of the state of 120 * the receiver being unknown. It is always known whether there is 121 * a token available. Certain domains with fixed point semantics, 122 * however, such as SR, will need to override this method. 123 * @return True. 124 */ 125 @Override 126 public boolean isKnown() { 127 return true; 128 } 129 130 /** Put the specified token into this receiver. 131 * @param token The token to put into the receiver. 132 * @exception NoRoomException If there is no room in the receiver. 133 * @exception IllegalActionException If the put fails 134 * (e.g. because of incompatible types). 135 */ 136 @Override 137 public void put(Token token) 138 throws NoRoomException, IllegalActionException { 139 140 } 141}