Clover coverage report - Ant Coverage
Coverage timestamp: Tue Apr 8 2003 20:43:55 EST
file stats: LOC: 180   Methods: 8
NCLOC: 60   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
DefaultJspCompilerAdapter.java 70% 87.5% 100% 85.7%
 1   
 /*
 2   
  * The Apache Software License, Version 1.1
 3   
  *
 4   
  * Copyright (c) 2001-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   
 
 55   
 package org.apache.tools.ant.taskdefs.optional.jsp.compilers;
 56   
 
 57   
 import java.io.File;
 58   
 import java.util.Enumeration;
 59   
 import java.util.Vector;
 60   
 import org.apache.tools.ant.Project;
 61   
 import org.apache.tools.ant.taskdefs.optional.jsp.JspC;
 62   
 import org.apache.tools.ant.types.CommandlineJava;
 63   
 
 64   
 /**
 65   
  * This is the default implementation for the JspCompilerAdapter interface.
 66   
  * This is currently very light on the ground since only one compiler type is
 67   
  * supported.
 68   
  *
 69   
  * @author Matthew Watson <a href="mailto:mattw@i3sp.com">mattw@i3sp.com</a>
 70   
  */
 71   
 public abstract class DefaultJspCompilerAdapter
 72   
     implements JspCompilerAdapter {
 73   
 
 74   
     private static String lSep = System.getProperty("line.separator");
 75   
 
 76   
     /**
 77   
      * Logs the compilation parameters, adds the files to compile and logs the 
 78   
      * &quot;niceSourceList&quot;
 79   
      */
 80  6
     protected void logAndAddFilesToCompile(JspC jspc,
 81   
                                            Vector compileList,
 82   
                                            CommandlineJava cmd) {
 83  6
         jspc.log("Compilation " + cmd.describeJavaCommand(),
 84   
                  Project.MSG_VERBOSE);
 85   
 
 86  6
         StringBuffer niceSourceList = new StringBuffer("File");
 87  6
         if (compileList.size() != 1) {
 88  0
             niceSourceList.append("s");
 89   
         }
 90  6
         niceSourceList.append(" to be compiled:");
 91   
 
 92  6
         niceSourceList.append(lSep);
 93   
 
 94  6
         Enumeration enum = compileList.elements();
 95  6
         while (enum.hasMoreElements()) {
 96  6
             String arg = (String) enum.nextElement();
 97  6
             cmd.createArgument().setValue(arg);
 98  6
             niceSourceList.append("    " + arg + lSep);
 99   
         }
 100   
 
 101  6
         jspc.log(niceSourceList.toString(), Project.MSG_VERBOSE);
 102   
     }
 103   
 
 104   
     /**
 105   
      * our owner
 106   
      */
 107   
     protected JspC owner;
 108   
 
 109   
     /**
 110   
      * set the owner
 111   
      */
 112  6
     public void setJspc(JspC owner) {
 113  6
         this.owner = owner;
 114   
     }
 115   
 
 116   
     /** get the owner
 117   
      * @return the owner; should never be null
 118   
      */
 119  66
     public JspC getJspc() {
 120  66
         return owner;
 121   
     }
 122   
 
 123   
     
 124   
     /**
 125   
      *  add an argument oneple to the argument list, if the value aint null
 126   
      *
 127   
      * @param  argument  The argument
 128   
      */
 129  12
     protected void addArg(CommandlineJava cmd, String argument) {
 130  12
         if (argument != null && argument.length() != 0) {
 131  12
            cmd.createArgument().setValue(argument);
 132   
         }
 133   
     }
 134   
 
 135   
 
 136   
     /**
 137   
      *  add an argument tuple to the argument list, if the value aint null
 138   
      *
 139   
      * @param  argument  The argument
 140   
      * @param  value     the parameter
 141   
      */
 142  12
     protected void addArg(CommandlineJava cmd, String argument, String value) {
 143  12
         if (value != null) {
 144  0
             cmd.createArgument().setValue(argument);
 145  0
             cmd.createArgument().setValue(value);
 146   
         }
 147   
     }
 148   
 
 149   
     /**
 150   
      *  add an argument tuple to the arg list, if the file parameter aint null
 151   
      *
 152   
      * @param  argument  The argument
 153   
      * @param  file     the parameter
 154   
      */
 155  30
     protected void addArg(CommandlineJava cmd, String argument, File file) {
 156  30
         if (file != null) {
 157  10
             cmd.createArgument().setValue(argument);
 158  10
             cmd.createArgument().setFile(file);
 159   
         }
 160   
     }
 161   
 
 162   
     /**
 163   
      * ask if compiler can sort out its own dependencies
 164   
      * @return true if the compiler wants to do its own
 165   
      * depends
 166   
      */
 167  7
     public boolean implementsOwnDependencyChecking() {
 168  7
         return false;
 169   
     }
 170   
 
 171   
     /**
 172   
      * get our project
 173   
      * @return owner project data
 174   
      */
 175  24
     public Project getProject() {
 176  24
         return getJspc().getProject();
 177   
     }
 178   
 }
 179   
 
 180