Clover coverage report - DynamicJava Test Coverage (dynamicjava-20120526-r5436)
Coverage timestamp: Sat May 26 2012 03:02:18 CDT
file stats: LOC: 164   Methods: 12
NCLOC: 55   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
ImportDeclaration.java 16.7% 45.8% 58.3% 45.2%
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 import declarations
 37    *
 38    * @author Stephane Hillion
 39    * @version 1.0 - 1999/04/24
 40    */
 41   
 42    public class ImportDeclaration extends Node {
 43    /**
 44    * The name of the imported class or package
 45    */
 46    private String name;
 47   
 48    /**
 49    * Is this declaration import a class or a package
 50    */
 51    private boolean pckage;
 52   
 53    private boolean sttic;
 54   
 55    /**
 56    * Creates a new import declaration node
 57    * @param ident a list of tokens that represents a package or a class name
 58    * @param pkg true if this declaration imports a package
 59    * @param sttc true if this declaration is a static import
 60    * @exception IllegalArgumentException if ident is null
 61    */
 62  0 public ImportDeclaration(List<IdentifierToken> ident, boolean pkg, boolean sttc) {
 63  0 this(ident, pkg, sttc, SourceInfo.NONE);
 64    }
 65   
 66    /**
 67    * Creates a new import declaration node
 68    * @param ident a list of tokens that represents a package or a class name
 69    * @param pkg true if this declaration imports a package
 70    * @param sttc true if this declaration is a static import
 71    * @exception IllegalArgumentException if ident is null
 72    */
 73  0 public ImportDeclaration(List<IdentifierToken> ident, boolean pkg, boolean sttc,
 74    SourceInfo si) {
 75  0 super(si);
 76   
 77  0 if (ident == null) throw new IllegalArgumentException("ident == null");
 78  0 pckage = pkg;
 79  0 sttic = sttc;
 80  0 name = TreeUtilities.listToName(ident);
 81    }
 82   
 83    /**
 84    * Creates a new import declaration node
 85    * @param nm a string that represents a package or a class name
 86    * @param pkg true if this declaration imports a package
 87    * @param sttc true if this declaration is a static import
 88    * @exception IllegalArgumentException if ident is null
 89    */
 90  15 public ImportDeclaration(String nm, boolean pkg, boolean sttc,
 91    SourceInfo si) {
 92  15 super(si);
 93   
 94  0 if (nm == null) throw new IllegalArgumentException("name == null");
 95   
 96  15 pckage = pkg;
 97  15 sttic = sttc;
 98  15 name = nm;
 99    }
 100   
 101    /**
 102    * Returns the name of the imported class or package
 103    */
 104  24 public String getName() {
 105  24 return name;
 106    }
 107   
 108    /**
 109    * Sets the package name
 110    * @exception IllegalArgumentException if s is null
 111    */
 112  0 public void setName(String s) {
 113  0 if (s == null) throw new IllegalArgumentException("s == null");
 114  0 name = s;
 115    }
 116   
 117    /**
 118    * Returns true if the identifier represents a package, false
 119    * if it represents a class
 120    */
 121  15 public boolean isPackage() {
 122  15 return pckage;
 123    }
 124   
 125    /**
 126    * Returns true if the identifier represents a class whose methods are being statically imported,
 127    * false if it represents a single method or if it is not a static import
 128    */
 129  0 public boolean isStaticImportClass() {
 130  0 return sttic && pckage;
 131    }
 132   
 133    /**
 134    * Sets the package property
 135    */
 136  0 public void setPackage(boolean b) {
 137  0 pckage = b;
 138    }
 139   
 140    /**
 141    * Returns true if the identifier represents a static import, false otherwise
 142    */
 143  15 public boolean isStatic() {
 144  15 return sttic;
 145    }
 146   
 147    /**
 148    * Allows a visitor to traverse the tree
 149    * @param visitor the visitor to accept
 150    */
 151  18 public <T> T acceptVisitor(Visitor<T> visitor) {
 152  18 return visitor.visit(this);
 153    }
 154    /**
 155    * Implementation of toString for use in unit testing
 156    */
 157  6 public String toString() {
 158  6 return "("+getClass().getName()+": "+toStringHelper()+")";
 159    }
 160   
 161  6 public String toStringHelper(){
 162  6 return getName()+" "+isPackage()+" "+isStatic();
 163    }
 164    }