Clover coverage report - Ant Coverage
Coverage timestamp: Tue Apr 8 2003 20:43:55 EST
file stats: LOC: 150   Methods: 3
NCLOC: 52   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
VAJAntTool.java 0% 0% 0% 0%
 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.ide;
 56   
 
 57   
 
 58   
 import com.ibm.ivj.util.base.Project;
 59   
 import com.ibm.ivj.util.base.ToolData;
 60   
 import org.apache.tools.ant.BuildException;
 61   
 
 62   
 
 63   
 /**
 64   
  * This class is the equivalent to org.apache.tools.ant.Main for the
 65   
  * VAJ tool environment. It's main is called when the user selects
 66   
  * Tools->Ant Build from the VAJ project menu.
 67   
  * Additionally this class provides methods to save build info for
 68   
  * a project in the repository and load it from the repository
 69   
  *
 70   
  * @author Wolf Siberski
 71   
  */
 72   
 public class VAJAntTool {
 73   
     private static final String TOOL_DATA_KEY = "AntTool";
 74   
 
 75   
 
 76   
     /**
 77   
      * Loads the BuildInfo for the specified VAJ project from the
 78   
      * tool data for this project.
 79   
      * If there is no build info stored for that project, a new
 80   
      * default BuildInfo is returned
 81   
      *
 82   
      * @return BuildInfo buildInfo build info for the specified project
 83   
      * @param projectName String project name
 84   
      */
 85  0
     public static VAJBuildInfo loadBuildData(String projectName) {
 86  0
         VAJBuildInfo result = null;
 87  0
         try {
 88  0
             Project project =
 89   
                 VAJLocalUtil.getWorkspace().loadedProjectNamed(projectName);
 90  0
             if (project.testToolRepositoryData(TOOL_DATA_KEY)) {
 91  0
                 ToolData td = project.getToolRepositoryData(TOOL_DATA_KEY);
 92  0
                 String data = (String) td.getData();
 93  0
                 result = VAJBuildInfo.parse(data);
 94   
             } else {
 95  0
                 result = new VAJBuildInfo();
 96   
             }
 97  0
             result.setVAJProjectName(projectName);
 98   
         } catch (Throwable t) {
 99  0
             throw new BuildException("BuildInfo for Project "
 100   
                                      + projectName + " could not be loaded" + t);
 101   
         }
 102  0
         return result;
 103   
     }
 104   
 
 105   
 
 106   
     /**
 107   
      * Starts the application.
 108   
      *
 109   
      * @param args an array of command-line arguments. VAJ puts the
 110   
      *             VAJ project name into args[1] when starting the
 111   
      *             tool from the project context menu
 112   
      */
 113  0
     public static void main(java.lang.String[] args) {
 114  0
         try {
 115  0
             VAJBuildInfo info;
 116  0
             if (args.length >= 2 && args[1] instanceof String) {
 117  0
                 String projectName = (String) args[1];
 118  0
                 info = loadBuildData(projectName);
 119   
             } else {
 120  0
                 info = new VAJBuildInfo();
 121   
             }
 122   
 
 123  0
             VAJAntToolGUI mainFrame = new VAJAntToolGUI(info);
 124  0
             mainFrame.show();
 125   
         } catch (Throwable t) {
 126   
             // if all error handling fails, output at least
 127   
             // something on the console
 128  0
             t.printStackTrace();
 129   
         }
 130   
     }
 131   
 
 132   
 
 133   
     /**
 134   
      * Saves the BuildInfo for a project in the VAJ repository.
 135   
      *
 136   
      * @param info BuildInfo build info to save
 137   
      */
 138  0
     public static void saveBuildData(VAJBuildInfo info) {
 139  0
         String data = info.asDataString();
 140  0
         try {
 141  0
             ToolData td = new ToolData(TOOL_DATA_KEY, data);
 142  0
             VAJLocalUtil.getWorkspace().loadedProjectNamed(
 143   
                                                            info.getVAJProjectName()).setToolRepositoryData(td);
 144   
         } catch (Throwable t) {
 145  0
             throw new BuildException("BuildInfo for Project "
 146   
                                      + info.getVAJProjectName() + " could not be saved", t);
 147   
         }
 148   
     }
 149   
 }
 150