From: Jeff M. <cus...@us...> - 2003-04-10 10:33:26
|
Update of /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects In directory sc8-pr-cvs1:/tmp/cvs-serv24273/src/core/com/mockobjects Modified Files: ReturnObjectBag.java Log Message: Added support for int Index: ReturnObjectBag.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/ReturnObjectBag.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- ReturnObjectBag.java 23 Jan 2003 13:09:13 -0000 1.2 +++ ReturnObjectBag.java 10 Apr 2003 10:33:22 -0000 1.3 @@ -5,8 +5,7 @@ import com.mockobjects.util.AssertMo; import com.mockobjects.util.Null; -import java.util.HashMap; -import java.util.Iterator; +import java.util.*; /** * The ReturnObjectBag is a map containing instances of ReturnObjectList. @@ -20,7 +19,7 @@ * @version $Revision$ */ public class ReturnObjectBag implements Verifiable { - private final HashMap returnObjectLists = new HashMap(); + private final Hashtable returnObjectLists = new Hashtable(); private final String name; /** @@ -37,10 +36,10 @@ * @see ReturnObjectList#addObjectToReturn */ public void putObjectToReturn(Object key, Object value) { - ReturnObjectList returnObjectList = (ReturnObjectList) returnObjectLists.get(key); if (key == null) { key = Null.NULL; } + ReturnObjectList returnObjectList = (ReturnObjectList) returnObjectLists.get(key); if (returnObjectList == null) { returnObjectList = new ReturnObjectList(name + "." + key.toString()); returnObjectLists.put(key, returnObjectList); @@ -50,6 +49,16 @@ } /** + * Places an object into the list of return objects for a particular int key + * @param key the key against which the object will be stored + * @param value the value to be added to the list for that key + * @see ReturnObjectList#addObjectToReturn + */ + public void putObjectToReturn(int key, Object value) { + putObjectToReturn(new Integer(key), value); + } + + /** * Checks each the list for each key to verify that all no objects remain * in the list for that key. * @see ReturnObjectList#verify @@ -76,4 +85,17 @@ AssertMo.assertNotNull(name + " does not contain " + key.toString(), returnObjectList); return returnObjectList.nextReturnObject(); } + + /** + * Returns the next object in the ReturnObjectList for a given int key. + * The call will throw an AssertFailError if the requested key is + * not present within this ReturnObjectBag. + * @param key The key for which the next object should be returned. + * @return The next object from the ReturnObjectList stored against the given key. + * @see ReturnObjectList#nextReturnObject + */ + public Object getNextReturnObject(int key) { + return getNextReturnObject(new Integer(key)); + } + } |