Clover coverage report - DynamicJava Test Coverage (dynamicjava-20120526-r5436)
Coverage timestamp: Sat May 26 2012 03:02:18 CDT
file stats: LOC: 189   Methods: 14
NCLOC: 61   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
ForStatement.java 16.7% 60% 64.3% 55.6%
coverage coverage
 1    /*
 2    * DynamicJava - Copyright (C) 1999-2001
 3    *
 4    * Permission is hereby granted, free of charge, to any person obtaining a
 5    * copy of this software and associated documentation files
 6    * (the "Software"), to deal in the Software without restriction, including
 7    * without limitation the rights to use, copy, modify, merge, publish,
 8    * distribute, sublicense, and/or sell copies of the Software, and to permit
 9    * persons to whom the Software is furnished to do so, subject to the
 10    * following conditions:
 11    * The above copyright notice and this permission notice shall be included
 12    * in all copies or substantial portions of the Software.
 13    *
 14    * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 15    * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 16    * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 17    * IN NO EVENT SHALL DYADE BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 18    * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 19    * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 20    * DEALINGS IN THE SOFTWARE.
 21    *
 22    * Except as contained in this notice, the name of Dyade shall not be
 23    * used in advertising or otherwise to promote the sale, use or other
 24    * dealings in this Software without prior written authorization from
 25    * Dyade.
 26    *
 27    */
 28   
 29    package koala.dynamicjava.tree;
 30   
 31    import java.util.*;
 32   
 33    import koala.dynamicjava.tree.visitor.*;
 34   
 35    /**
 36    * This class represents the for statement nodes of the syntax tree
 37    *
 38    * @author Stephane Hillion
 39    * @version 1.0 - 1999/05/23
 40    */
 41   
 42    public class ForStatement extends ForSlashEachStatement implements ContinueTarget {
 43    /**
 44    * The initialization statements
 45    */
 46    private List<Node> initialization;
 47   
 48    /**
 49    * The condition to evaluate at each loop
 50    */
 51    private Expression condition;
 52   
 53    /**
 54    * The update statements
 55    */
 56    private List<Node> update;
 57   
 58    /**
 59    * The body of this statement
 60    */
 61    private Node body;
 62   
 63    /**
 64    * The labels
 65    */
 66    private List<String> labels;
 67   
 68    /**
 69    * Creates a new for statement
 70    * @param init the initialization statements
 71    * @param cond the condition to evaluate at each loop
 72    * @param updt the update statements
 73    * @param body the body
 74    * @exception IllegalArgumentException if body is null
 75    */
 76  1 public ForStatement(List<Node> init, Expression cond, List<Node> updt, Node body) {
 77  1 this(init, cond, updt, body, SourceInfo.NONE);
 78    }
 79   
 80    /**
 81    * Creates a new for statement
 82    * @param init the initialization statements (either Statements or declarations)
 83    * @param cond the condition to evaluate at each loop
 84    * @param updt the update statements (either Statements or declarations)
 85    * @param body the body
 86    * @exception IllegalArgumentException if body is null
 87    */
 88  113 public ForStatement(List<Node> init, Expression cond, List<Node> updt, Node body,
 89    SourceInfo si) {
 90  113 super(si);
 91   
 92  0 if (body == null) throw new IllegalArgumentException("body == null");
 93   
 94  113 initialization = init;
 95  113 condition = cond;
 96  113 update = updt;
 97  113 this.body = body;
 98  113 labels = new LinkedList<String>();
 99    }
 100   
 101    /**
 102    * Gets the initialization statements
 103    */
 104  258 public List<Node> getInitialization() {
 105  258 return initialization;
 106    }
 107   
 108    /**
 109    * Sets the initialization statements
 110    */
 111  0 public void setInitialization(List<Node> l) {
 112  0 initialization = l;
 113    }
 114   
 115    /**
 116    * Gets the condition to evaluate at each loop
 117    */
 118  352 public Expression getCondition() {
 119  352 return condition;
 120    }
 121   
 122    /**
 123    * Sets the condition to evaluate
 124    */
 125  111 public void setCondition(Expression e) {
 126  111 condition = e;
 127    }
 128   
 129    /**
 130    * Gets the update statements
 131    */
 132  241 public List<Node> getUpdate() {
 133  241 return update;
 134    }
 135   
 136    /**
 137    * Sets the update statements
 138    */
 139  0 public void setUpdate(List<Node> l) {
 140  0 update = l;
 141    }
 142   
 143    /**
 144    * Returns the body of this statement
 145    */
 146  157 public Node getBody() {
 147  157 return body;
 148    }
 149   
 150    /**
 151    * Sets the body of this statement
 152    * @exception IllegalArgumentException if node is null
 153    */
 154  0 public void setBody(Node node) {
 155  0 if (node == null) throw new IllegalArgumentException("node == null");
 156  0 body = node;
 157    }
 158   
 159    /**
 160    * Adds a label to this statement
 161    * @param label the label to add
 162    * @exception IllegalArgumentException if label is null
 163    */
 164  0 public void addLabel(String label) {
 165  0 if (label == null) throw new IllegalArgumentException("label == null");
 166   
 167  0 labels.add(label);
 168    }
 169   
 170    /**
 171    * Test whether this statement has the given label
 172    * @return true if this statement has the given label
 173    */
 174  0 public boolean hasLabel(String label) {
 175  0 return labels.contains(label);
 176    }
 177   
 178    /**
 179    * Allows a visitor to traverse the tree
 180    * @param visitor the visitor to accept
 181    */
 182  128 public <T> T acceptVisitor(Visitor<T> visitor) {
 183  128 return visitor.visit(this);
 184    }
 185   
 186  2 public String toString(){
 187  2 return "("+getClass().getName()+": "+getInitialization()+" "+getCondition()+" "+getUpdate()+" "+getBody()+")";
 188    }
 189    }