Clover coverage report - Ant Coverage
Coverage timestamp: Tue Apr 8 2003 20:43:55 EST
file stats: LOC: 173   Methods: 9
NCLOC: 74   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
AntFilterReader.java 0% 20.6% 55.6% 19.7%
 1   
 /*
 2   
  * The Apache Software License, Version 1.1
 3   
  *
 4   
  * Copyright (c) 2002 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.types;
 55   
 
 56   
 import java.util.Vector;
 57   
 import org.apache.tools.ant.BuildException;
 58   
 
 59   
 /**
 60   
  * An AntFileReader is a wrapper class that encloses the classname
 61   
  * and configuration of a Configurable FilterReader.
 62   
  *
 63   
  * @author Magesh Umasankar
 64   
  */
 65   
 public final class AntFilterReader
 66   
     extends DataType
 67   
     implements Cloneable {
 68   
 
 69   
     private String className;
 70   
 
 71   
     private final Vector parameters = new Vector();
 72   
 
 73   
     private Path classpath;
 74   
 
 75  3
     public final void setClassName(final String className) {
 76  3
         this.className = className;
 77   
     }
 78   
 
 79  3
     public final String getClassName() {
 80  3
         return className;
 81   
     }
 82   
 
 83  2
     public final void addParam(final Parameter param) {
 84  2
         parameters.addElement(param);
 85   
     }
 86   
 
 87   
     /**
 88   
      * Set the classpath to load the FilterReader through (attribute).
 89   
      */
 90  0
     public final void setClasspath(Path classpath) {
 91  0
         if (isReference()) {
 92  0
             throw tooManyAttributes();
 93   
         }
 94  0
         if (this.classpath == null) {
 95  0
             this.classpath = classpath;
 96   
         } else {
 97  0
             this.classpath.append(classpath);
 98   
         }
 99   
     }
 100   
 
 101   
     /**
 102   
      * Set the classpath to load the FilterReader through (nested element).
 103   
      */
 104  0
     public final Path createClasspath() {
 105  0
         if (isReference()) {
 106  0
             throw noChildrenAllowed();
 107   
         }
 108  0
         if (this.classpath == null) {
 109  0
             this.classpath = new Path(getProject());
 110   
         }
 111  0
         return this.classpath.createPath();
 112   
     }
 113   
 
 114   
     /**
 115   
      * Get the classpath
 116   
      */
 117  3
     public final Path getClasspath() {
 118  3
         return classpath;
 119   
     }
 120   
 
 121   
     /**
 122   
      * Set the classpath to load the FilterReader through via
 123   
      * reference (attribute).
 124   
      */
 125  0
     public void setClasspathRef(Reference r) {
 126  0
         if (isReference()) {
 127  0
             throw tooManyAttributes();
 128   
         }
 129  0
         createClasspath().setRefid(r);
 130   
     }
 131   
 
 132  2
     public final Parameter[] getParams() {
 133  2
         Parameter[] params = new Parameter[parameters.size()];
 134  2
         parameters.copyInto(params);
 135  2
         return params;
 136   
     }
 137   
 
 138   
     /**
 139   
      * Makes this instance in effect a reference to another AntFilterReader 
 140   
      * instance.
 141   
      *
 142   
      * <p>You must not set another attribute or nest elements inside
 143   
      * this element if you make it a reference.</p>
 144   
      *
 145   
      * @param r the reference to which this instance is associated
 146   
      * @exception BuildException if this instance already has been configured.
 147   
      */
 148  0
     public void setRefid(Reference r) throws BuildException {
 149  0
         if (!parameters.isEmpty() || className != null
 150   
                 || classpath != null) {
 151  0
             throw tooManyAttributes();
 152   
         }
 153   
         // change this to get the objects from the other reference
 154  0
         Object o = r.getReferencedObject(getProject());
 155  0
         if (o instanceof AntFilterReader) {
 156  0
             AntFilterReader afr = (AntFilterReader) o;
 157  0
             setClassName(afr.getClassName());
 158  0
             setClasspath(afr.getClasspath());
 159  0
             Parameter[] p = afr.getParams();
 160  0
             if (p != null) {
 161  0
                 for (int i = 0; i < p.length; i++) {
 162  0
                     addParam(p[i]);
 163   
                 }
 164   
             }
 165   
         } else {
 166  0
             String msg = r.getRefId() + " doesn\'t refer to a FilterReader";
 167  0
             throw new BuildException(msg);
 168   
         }
 169   
 
 170  0
         super.setRefid(r);
 171   
     }
 172   
 }
 173