Clover coverage report - Ant Coverage
Coverage timestamp: Tue Apr 8 2003 20:43:55 EST
file stats: LOC: 243   Methods: 23
NCLOC: 104   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
AntXMLContext.java 62.5% 82.4% 82.6% 80%
 1   
 /*
 2   
  * The Apache Software License, Version 1.1
 3   
  *
 4   
  * Copyright (c) 2003 The Apache Software Foundation.  All rights
 5   
  * reserved.
 6   
  *
 7   
  * Redistribution and use in source and binary forms, with or without
 8   
  * modification, are permitted provided that the following conditions
 9   
  * are met:
 10   
  *
 11   
  * 1. Redistributions of source code must retain the above copyright
 12   
  *    notice, this list of conditions and the following disclaimer.
 13   
  *
 14   
  * 2. Redistributions in binary form must reproduce the above copyright
 15   
  *    notice, this list of conditions and the following disclaimer in
 16   
  *    the documentation and/or other materials provided with the
 17   
  *    distribution.
 18   
  *
 19   
  * 3. The end-user documentation included with the redistribution, if
 20   
  *    any, must include the following acknowlegement:
 21   
  *       "This product includes software developed by the
 22   
  *        Apache Software Foundation (http://www.apache.org/)."
 23   
  *    Alternately, this acknowlegement may appear in the software itself,
 24   
  *    if and wherever such third-party acknowlegements normally appear.
 25   
  *
 26   
  * 4. The names "Ant" and "Apache Software
 27   
  *    Foundation" must not be used to endorse or promote products derived
 28   
  *    from this software without prior written permission. For written
 29   
  *    permission, please contact apache@apache.org.
 30   
  *
 31   
  * 5. Products derived from this software may not be called "Apache"
 32   
  *    nor may "Apache" appear in their names without prior written
 33   
  *    permission of the Apache Group.
 34   
  *
 35   
  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
 36   
  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 37   
  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 38   
  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
 39   
  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 40   
  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 41   
  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
 42   
  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 43   
  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 44   
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
 45   
  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 46   
  * SUCH DAMAGE.
 47   
  * ====================================================================
 48   
  *
 49   
  * This software consists of voluntary contributions made by many
 50   
  * individuals on behalf of the Apache Software Foundation.  For more
 51   
  * information on the Apache Software Foundation, please see
 52   
  * <http://www.apache.org/>.
 53   
  */
 54   
 package org.apache.tools.ant.helper;
 55   
 
 56   
 import java.io.File;
 57   
 import java.util.Vector;
 58   
 
 59   
 import org.xml.sax.Locator;
 60   
 import org.xml.sax.Attributes;
 61   
 
 62   
 
 63   
 import org.apache.tools.ant.Project;
 64   
 import org.apache.tools.ant.Target;
 65   
 import org.apache.tools.ant.RuntimeConfigurable;
 66   
 
 67   
 
 68   
 /**
 69   
  * Context information for the ant processing.
 70   
  *
 71   
  * @author Costin Manolache
 72   
  */
 73   
 public class AntXMLContext {
 74   
     /** The project to configure. */
 75   
     private Project project;
 76   
 
 77   
     /** The configuration file to parse. */
 78   
     private File buildFile;
 79   
 
 80   
     /** Vector with all the targets, in the order they are
 81   
      * defined. Project maintains a Hashtable, which is not ordered.
 82   
      * This will allow description to know the original order.
 83   
      */
 84   
     private Vector targetVector = new Vector();
 85   
 
 86   
     /**
 87   
      * Parent directory of the build file. Used for resolving entities
 88   
      * and setting the project's base directory.
 89   
      */
 90   
     private File buildFileParent;
 91   
 
 92   
     /** Name of the current project */
 93   
     private String currentProjectName;
 94   
 
 95   
     /**
 96   
      * Locator for the configuration file parser.
 97   
      * Used for giving locations of errors etc.
 98   
      */
 99   
     private Locator locator;
 100   
 
 101   
      /**
 102   
       * Target that all other targets will depend upon implicitly.
 103   
       *
 104   
       * <p>This holds all tasks and data type definitions that have
 105   
       * been placed outside of targets.</p>
 106   
       */
 107   
     private Target implicitTarget = new Target();
 108   
 
 109   
     /** Current target ( no need for a stack as the processing model
 110   
         allows only one level of target ) */
 111   
     private Target currentTarget = null;
 112   
 
 113   
     /** The stack of RuntimeConfigurable2 wrapping the
 114   
         objects.
 115   
     */
 116   
     private Vector wStack = new Vector();
 117   
 
 118   
     /**
 119   
      * Indicates whether the project tag attributes are to be ignored
 120   
      * when processing a particular build file.
 121   
      */
 122   
     private boolean ignoreProjectTag = false;
 123   
 
 124  566
     public AntXMLContext(Project project) {
 125  566
         this.project = project;
 126  566
         implicitTarget.setName("");
 127  566
         targetVector.addElement(implicitTarget);
 128   
     }
 129   
 
 130  566
     public void setBuildFile(File buildFile) {
 131  566
         this.buildFile = buildFile;
 132  566
         this.buildFileParent = new File(buildFile.getParent());
 133   
     }
 134   
 
 135  1132
     public File getBuildFile() {
 136  1132
         return buildFile;
 137   
     }
 138   
 
 139  533
     public File getBuildFileParent() {
 140  533
         return buildFileParent;
 141   
     }
 142   
 
 143  30621
     public Project getProject() {
 144  30621
         return project;
 145   
     }
 146   
 
 147  1132
     public String getCurrentProjectName() {
 148  1132
         return currentProjectName;
 149   
     }
 150   
 
 151  520
     public void setCurrentProjectName(String name) {
 152  520
         this.currentProjectName = name;
 153   
     }
 154   
 
 155  37449
     public RuntimeConfigurable currentWrapper() {
 156  37449
         if (wStack.size() < 1) {
 157  14637
             return null;
 158   
         }
 159  22812
         return (RuntimeConfigurable) wStack.elementAt(wStack.size() - 1);
 160   
     }
 161   
 
 162  0
     public RuntimeConfigurable parentWrapper() {
 163  0
         if (wStack.size() < 2) {
 164  0
             return null;
 165   
         }
 166  0
         return (RuntimeConfigurable) wStack.elementAt(wStack.size() - 2);
 167   
     }
 168   
 
 169  22085
     public void pushWrapper(RuntimeConfigurable wrapper) {
 170  22085
         wStack.addElement(wrapper);
 171   
     }
 172   
 
 173  22085
     public void popWrapper() {
 174  22085
         if (wStack.size() > 0) {
 175  22085
             wStack.removeElementAt(wStack.size() - 1);
 176   
         }
 177   
     }
 178   
 
 179  0
     public Vector getWrapperStack() {
 180  0
         return wStack;
 181   
     }
 182   
 
 183  7960
     public void addTarget(Target target) {
 184  7960
         targetVector.addElement(target);
 185  7960
         currentTarget = target;
 186   
     }
 187   
 
 188  36722
     public Target getCurrentTarget() {
 189  36722
         return currentTarget;
 190   
     }
 191   
 
 192  9655
     public Target getImplicitTarget() {
 193  9655
         return implicitTarget;
 194   
     }
 195   
 
 196  8525
     public void setCurrentTarget(Target target) {
 197  8525
         this.currentTarget = target;
 198   
     }
 199   
 
 200  0
     public void setImplicitTarget(Target target) {
 201  0
         this.implicitTarget = target;
 202   
     }
 203   
 
 204  566
     public Vector getTargets() {
 205  566
         return targetVector;
 206   
     }
 207   
 
 208   
     /**
 209   
      * Scans an attribute list for the <code>id</code> attribute and
 210   
      * stores a reference to the target object in the project if an
 211   
      * id is found.
 212   
      * <p>
 213   
      * This method was moved out of the configure method to allow
 214   
      * it to be executed at parse time.
 215   
      *
 216   
      * @see #configure(java.lang.Object,org.xml.sax.AttributeList,org.apache.tools.ant.Project)
 217   
      */
 218  22085
     public void configureId(Object element, Attributes attr) {
 219  22085
         String id = attr.getValue("id");
 220  22085
         if (id != null) {
 221  364
             project.addReference(id, element);
 222   
         }
 223   
     }
 224   
 
 225  66257
     public Locator getLocator() {
 226  66257
         return locator;
 227   
     }
 228   
 
 229  566
     public void setLocator(Locator locator) {
 230  566
         this.locator = locator;
 231   
     }
 232   
 
 233  2223
     public boolean isIgnoringProjectTag() {
 234  2223
         return ignoreProjectTag;
 235   
     }
 236   
 
 237  0
     public void setIgnoreProjectTag(boolean flag) {
 238  0
         this.ignoreProjectTag = flag;
 239   
     }
 240   
 }
 241   
 
 242   
 
 243