Clover coverage report - DynamicJava Test Coverage (dynamicjava-20130518-r5436)
Coverage timestamp: Sat May 18 2013 03:01:28 CDT
file stats: LOC: 153   Methods: 10
NCLOC: 51   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
FieldDeclaration.java 25% 45.8% 50% 41.3%
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 koala.dynamicjava.tree.visitor.*;
 32   
 33    /**
 34    * This class represents field declarations in an AST
 35    *
 36    * @author Stephane Hillion
 37    * @version 1.0 - 1999/05/11
 38    */
 39   
 40    public class FieldDeclaration extends Declaration {
 41    /**
 42    * The type of this field
 43    */
 44    private TypeName type;
 45   
 46    /**
 47    * The name of this field
 48    */
 49    private String name;
 50   
 51    /**
 52    * The initializer
 53    */
 54    private Expression initializer;
 55   
 56    /**
 57    * Creates a new field declaration
 58    * @param mods the modifiers
 59    * @param type the type of this field
 60    * @param name the name of this field
 61    * @param init the initializer. Can be null
 62    * @exception IllegalArgumentException if name is null or type is null
 63    */
 64  0 public FieldDeclaration(ModifierSet mods, TypeName type, String name, Expression init) {
 65  0 this(mods, type, name, init, SourceInfo.NONE);
 66    }
 67   
 68    /**
 69    * Creates a new field declaration
 70    * @param mods the modifiers
 71    * @param type the type of this field
 72    * @param name the name of this field
 73    * @param init the initializer. Can be null
 74    * @exception IllegalArgumentException if name is null or type is null
 75    */
 76  23 public FieldDeclaration(ModifierSet mods, TypeName type, String name, Expression init,
 77    SourceInfo si) {
 78  23 super(mods, si);
 79   
 80  0 if (type == null) throw new IllegalArgumentException("type == null");
 81  0 if (name == null) throw new IllegalArgumentException("name == null");
 82  23 this.type = type;
 83  23 this.name = name;
 84  23 initializer = init;
 85   
 86  23 if (type instanceof ArrayTypeName) {
 87  0 if (initializer instanceof ArrayInitializer) {
 88  0 ((ArrayInitializer)initializer).setElementType
 89    (((ArrayTypeName)type).getElementType());
 90    }
 91    }
 92    }
 93   
 94    /**
 95    * Gets the declared type for this field
 96    */
 97  173 public TypeName getType() {
 98  173 return type;
 99    }
 100   
 101    /**
 102    * Sets the type of this field
 103    * @exception IllegalArgumentException if t is null
 104    */
 105  0 public void setType(TypeName t) {
 106  0 if (t == null) throw new IllegalArgumentException("t == null");
 107  0 type = t;
 108    }
 109   
 110    /**
 111    * Returns the name of this field
 112    */
 113  370 public String getName() {
 114  370 return name;
 115    }
 116   
 117    /**
 118    * Sets the field's name
 119    * @exception IllegalArgumentException if s is null
 120    */
 121  0 public void setName(String s) {
 122  0 if (s == null) throw new IllegalArgumentException("s == null");
 123  0 name = s;
 124    }
 125   
 126    /**
 127    * Returns the initializer for this field
 128    */
 129  35 public Expression getInitializer() {
 130  35 return initializer;
 131    }
 132   
 133    /**
 134    * Sets the initializer
 135    */
 136  0 public void setInitializer(Expression e) {
 137  0 initializer = e;
 138    }
 139   
 140    /**
 141    * Allows a visitor to traverse the tree
 142    * @param visitor the visitor to accept
 143    */
 144  81 public <T> T acceptVisitor(Visitor<T> visitor) {
 145  81 return visitor.visit(this);
 146    }
 147    /**
 148    * Implementation of toString for use in unit testing
 149    */
 150  0 public String toString() {
 151  0 return "("+getClass().getName()+": "+getModifiers()+" "+getType()+" "+getName()+" "+getInitializer()+")";
 152    }
 153    }