Clover coverage report - Ant Coverage
Coverage timestamp: Tue Apr 8 2003 20:43:55 EST
file stats: LOC: 238   Methods: 11
NCLOC: 53   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
BuildEvent.java - 100% 100% 100%
 1   
 /*
 2   
  * The Apache Software License, Version 1.1
 3   
  *
 4   
  * Copyright (c) 2000,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;
 55   
 
 56   
 import java.util.EventObject;
 57   
 
 58   
 /**
 59   
  * Class representing an event occurring during a build. An
 60   
  * event is built by specifying either a project, a task or a target.
 61   
  * A project level event will only have a project reference;
 62   
  * a target level event will have project and target references;
 63   
  * a task level event will have project, target and task references.
 64   
  *
 65   
  * @author Matt Foemmel
 66   
  */
 67   
 public class BuildEvent extends EventObject {
 68   
     
 69   
     /** Project which emitted the event. */
 70   
     private Project project;
 71   
     /** Target which emitted the event, if specified. */
 72   
     private Target target;
 73   
     /** Task which emitted the event, if specified. */
 74   
     private Task task;
 75   
     /** 
 76   
      * Message associated with the event. This is only used for
 77   
      * "messageLogged" events.
 78   
      */
 79   
     private String message;
 80   
     /**
 81   
      * The priority of the message, for "messageLogged" events.
 82   
      */
 83   
     private int priority = Project.MSG_VERBOSE;
 84   
     /**
 85   
      * The exception associated with this event, if any.
 86   
      * This is only used for "taskFinished", "targetFinished", 
 87   
      * and "buildFinished" events.
 88   
      */
 89   
     private Throwable exception;
 90   
 
 91   
     /**
 92   
      * Construct a BuildEvent for a project level event.
 93   
      *
 94   
      * @param project the project that emitted the event.
 95   
      *                Should not be <code>null</code>.
 96   
      */
 97  95992
     public BuildEvent(Project project) {
 98  95992
         super(project);
 99  95992
         this.project = project;
 100  95992
         this.target = null;
 101  95992
         this.task = null;
 102   
     }
 103   
     
 104   
     /**
 105   
      * Construct a BuildEvent for a target level event.
 106   
      * The project associated with the event is derived
 107   
      * from the given target.
 108   
      *
 109   
      * @param target the target that emitted the event.
 110   
      *               Must not be <code>null</code>.
 111   
      */
 112  2084
     public BuildEvent(Target target) {
 113  2084
         super(target);
 114  2084
         this.project = target.getProject();
 115  2084
         this.target = target;
 116  2084
         this.task = null;
 117   
     }
 118   
     
 119   
     /**
 120   
      * Construct a BuildEvent for a task level event.
 121   
      * The project and target associated with the event 
 122   
      * are derived from the given task.
 123   
      *
 124   
      * @param task the task that emitted the event.
 125   
      *             Must not be <code>null</code>.
 126   
      */
 127  15540
     public BuildEvent(Task task) {
 128  15540
         super(task);
 129  15540
         this.project = task.getProject();
 130  15540
         this.target = task.getOwningTarget();
 131  15540
         this.task = task;
 132   
     }
 133   
 
 134   
     /**
 135   
      * Sets the message and priority associated with this event.
 136   
      * This is used for "messageLogged" events.
 137   
      * 
 138   
      * @param message the message to be associated with this event.
 139   
      *                Should not be <code>null</code>.
 140   
      * @param priority the priority to be associated with this event,
 141   
      *                 as defined in the {@link Project Project} class.
 142   
      *
 143   
      * @see BuildListener#messageLogged(BuildEvent)
 144   
      */
 145  104983
     public void setMessage(String message, int priority) {
 146  104983
         this.message = message;
 147  104983
         this.priority = priority;
 148   
     }
 149   
     
 150   
     /**
 151   
      * Sets the exception associated with this event. This is used 
 152   
      * for "taskFinished", "targetFinished", and "buildFinished" 
 153   
      * events.
 154   
      * 
 155   
      * @param exception The exception to be associated with this event.
 156   
      *                  May be <code>null</code>.
 157   
      *
 158   
      * @see BuildListener#taskFinished(BuildEvent)
 159   
      * @see BuildListener#targetFinished(BuildEvent)
 160   
      * @see BuildListener#buildFinished(BuildEvent)
 161   
      */
 162  4317
     public void setException(Throwable exception) {
 163  4317
         this.exception = exception;
 164   
     }
 165   
 
 166   
     /**
 167   
      * Returns the project that fired this event.
 168   
      * 
 169   
      * @return the project that fired this event
 170   
      */
 171  1801
     public Project getProject() {
 172  1801
         return project;
 173   
     }
 174   
 
 175   
     /**
 176   
      * Returns the target that fired this event.
 177   
      * 
 178   
      * @return the project that fired this event, or <code>null</code>
 179   
      *          if this event is a project level event.
 180   
      */
 181  61
     public Target getTarget() {
 182   
         
 183  61
         return target;
 184   
     }
 185   
 
 186   
     /**
 187   
      * Returns the task that fired this event.
 188   
      * 
 189   
      * @return the task that fired this event, or <code>null</code>
 190   
      *         if this event is a project or target level event.
 191   
      */
 192  2242
     public Task getTask() {
 193  2242
         return task;
 194   
     }
 195   
 
 196   
     /**
 197   
      * Returns the logging message. This field will only be set
 198   
      * for "messageLogged" events.
 199   
      *
 200   
      * @return the message associated with this event, or <code>null</code>
 201   
      *         if no message has been set.
 202   
      * 
 203   
      * @see BuildListener#messageLogged(BuildEvent)
 204   
      */
 205  92432
     public String getMessage() {
 206  92432
         return message;
 207   
     }
 208   
 
 209   
     /**
 210   
      * Returns the priority of the logging message. This field will only
 211   
      * be set for "messageLogged" events. The meaning of this priority
 212   
      * is as specified by the constants in the {@link Project Project} class.
 213   
      * 
 214   
      * @return the priority associated with this event.
 215   
      *
 216   
      * @see BuildListener#messageLogged(BuildEvent)
 217   
      */
 218  372090
     public int getPriority(){
 219  372090
         return priority;
 220   
     }
 221   
 
 222   
     /**
 223   
      * Returns the exception that was thrown, if any. This field will only
 224   
      * be set for "taskFinished", "targetFinished", and "buildFinished"
 225   
      * events.
 226   
      * 
 227   
      * @return the exception associated with this exception, or 
 228   
      *         <code>null</code> if no exception has been set.
 229   
      *
 230   
      * @see BuildListener#taskFinished(BuildEvent)
 231   
      * @see BuildListener#targetFinished(BuildEvent)
 232   
      * @see BuildListener#buildFinished(BuildEvent)
 233   
      */
 234  1
     public Throwable getException() {
 235  1
         return exception;
 236   
     }
 237   
 }
 238