Clover coverage report - Common - 1.0.0
Coverage timestamp: sam. déc. 27 2003 15:13:46 CET
file stats: LOC: 60   Methods: 3
NCLOC: 22   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
LimitedStack.java 100% 80% 66,7% 80%
coverage coverage
 1   
 /*
 2   
  * EJTools, the Enterprise Java Tools
 3   
  *
 4   
  * Distributable under LGPL license.
 5   
  * See terms of license at www.gnu.org.
 6   
  */
 7   
 package org.ejtools.util;
 8   
 
 9   
 import java.util.Stack;
 10   
 
 11   
 /**
 12   
  * Extension of the Stack class, which has a limited depth (FIFO stack). This class doesn't allow duplicates.
 13   
  *
 14   
  * @author    Laurent Etiemble
 15   
  * @version   $Revision: 1.7 $
 16   
  */
 17   
 public class LimitedStack extends Stack
 18   
 {
 19   
    /** Maximum number elements allowed in the stack */
 20   
    protected int maximumSize;
 21   
 
 22   
 
 23   
    /** Constructor for the LimitedStack object */
 24  0
    public LimitedStack()
 25   
    {
 26  0
       this(10);
 27   
    }
 28   
 
 29   
 
 30   
    /**
 31   
     * Constructor for the LimitedStack object
 32   
     *
 33   
     * @param size  Depth size of the stack
 34   
     */
 35  32
    public LimitedStack(int size)
 36   
    {
 37  32
       this.maximumSize = size;
 38   
    }
 39   
 
 40   
 
 41   
    /**
 42   
     * Overrides the push method to limit the number of elements.
 43   
     *
 44   
     * @param item  Item to push onto the stack
 45   
     * @return      The item pushed
 46   
     */
 47  232
    public Object push(Object item)
 48   
    {
 49   
       // If size is exceeded, remove the first in
 50  232
       if (this.size() >= this.maximumSize)
 51   
       {
 52  16
          this.remove(0);
 53   
       }
 54   
 
 55   
       // Push the item
 56  232
       return super.push(item);
 57   
    }
 58   
 }
 59   
 
 60