Clover coverage report - jMock - 1.0-beta1
Coverage timestamp: Sat Nov 29 2003 19:35:59 GMT
file stats: LOC: 61   Methods: 8
NCLOC: 42   Classes: 1
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover
 
 Source file Conditionals Statements Methods TOTAL
ReturnValues.java 0% 0% 0% 0%
coverage
 1   
 /* Copyright (c) 2000-2003, jMock.org. See bundled LICENSE.txt */
 2   
 package org.jmock.expectation;
 3   
 
 4   
 import junit.framework.AssertionFailedError;
 5   
 
 6   
 import java.util.Collection;
 7   
 import java.util.Vector;
 8   
 
 9   
 /**
 10   
  * Sequence values as required by MockMaker
 11   
  * This is a generic class that should have been introduced to the mockobjects code stream instead of
 12   
  * being separately included in org.mockobjects.
 13   
  * It is possibly similar to a ReturnObjectList?
 14   
  */
 15   
 public class ReturnValues {
 16   
     private String myName;
 17   
     protected Vector myContents = new Vector();
 18   
     private boolean myKeepUsingLastReturnValue = false;
 19   
 
 20  0
     public ReturnValues() {
 21  0
         this("Generate me with a useful name!", true);
 22   
     }
 23   
 
 24  0
     public ReturnValues(String name, boolean keepUsingLastReturnValue) {
 25  0
         myName = name;
 26  0
         myKeepUsingLastReturnValue = keepUsingLastReturnValue;
 27   
     }
 28   
 
 29  0
     public ReturnValues(boolean keepUsingLastReturnValue) {
 30  0
         this("Generate me with a useful name!", keepUsingLastReturnValue);
 31   
     }
 32   
 
 33  0
     public void add(Object element) {
 34  0
         myContents.addElement(element);
 35   
     }
 36   
 
 37  0
     public void addAll(Collection returnValues) {
 38  0
         myContents.addAll(returnValues);
 39   
     }
 40   
 
 41  0
     public Object getNext() {
 42  0
         if (myContents.isEmpty()) {
 43  0
             throw new AssertionFailedError(getClass().getName() + "[" + myName + "] was not setup with enough values");
 44   
         }
 45  0
         return pop();
 46   
     }
 47   
 
 48  0
     public boolean isEmpty() {
 49  0
         return myContents.size() == 0;
 50   
     }
 51   
 
 52  0
     protected Object pop() {
 53  0
         Object result = myContents.firstElement();
 54  0
         boolean shouldNotRemoveElement = myContents.size() == 1 && myKeepUsingLastReturnValue;
 55  0
         if (!shouldNotRemoveElement) {
 56  0
             myContents.removeElementAt(0);
 57   
         }
 58  0
         return result;
 59   
     }
 60   
 }
 61