Clover coverage report - Ant Coverage
Coverage timestamp: Tue Apr 8 2003 20:43:55 EST
file stats: LOC: 178   Methods: 8
NCLOC: 69   Classes: 2
 
 Source file Conditionals Statements Methods TOTAL
Triggers.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.sitraka;
 56   
 
 57   
 import java.util.Hashtable;
 58   
 import java.util.Vector;
 59   
 import org.apache.tools.ant.BuildException;
 60   
 
 61   
 /**
 62   
  * Trigger information. It will return as a command line argument by calling
 63   
  * the <tt>toString()</tt> method.
 64   
  *
 65   
  * @author <a href="mailto:sbailliez@imediation.com">Stephane Bailliez</a>
 66   
  */
 67   
 public class Triggers {
 68   
 
 69   
     protected Vector triggers = new Vector();
 70   
 
 71  0
     public Triggers() {
 72   
     }
 73   
 
 74   
 
 75   
     /**
 76   
      * add a method trigger
 77   
      */
 78  0
     public void addMethod(Method method) {
 79  0
         triggers.addElement(method);
 80   
     }
 81   
 
 82   
     // -jp_trigger=ClassName.*():E:S,ClassName.MethodName():X:X
 83  0
     public String toString() {
 84  0
         StringBuffer buf = new StringBuffer();
 85  0
         final int size = triggers.size();
 86  0
         for (int i = 0; i < size; i++) {
 87  0
             buf.append(triggers.elementAt(i).toString());
 88  0
             if (i < size - 1) {
 89  0
                 buf.append(',');
 90   
             }
 91   
         }
 92  0
         return buf.toString();
 93   
     }
 94   
 
 95   
 
 96   
     /**
 97   
      * A trigger for the coverage report
 98   
      */
 99   
     public static class Method {
 100   
         protected String name;
 101   
         protected String event;
 102   
         protected String action;
 103   
         protected String param;
 104   
 
 105   
         /**
 106   
          * The name of the method(s) as a regular expression. The name
 107   
          * is the fully qualified name on the form <tt>package.classname.method</tt>
 108   
          *  required.
 109   
          */        
 110  0
         public void setName(String value) {
 111  0
             name = value;
 112   
         }
 113   
 
 114   
         /**
 115   
          * the event on the method that will trigger the action. Must be
 116   
          * &quot;enter&quot; or &quot;exit&quot;
 117   
          *  required.
 118   
          */
 119  0
         public void setEvent(String value) {
 120  0
             if (eventMap.get(value) == null) {
 121  0
                 throw new BuildException("Invalid event, must be one of " + eventMap);
 122   
             }
 123  0
             event = value;
 124   
         }
 125   
 
 126   
         /**
 127   
          * The action to execute; required. Must be one of &quot;clear&quot;,
 128   
          * &quot;pause&quot;, &quot;resume&quot;, &quot;snapshot&quot;, &quot;suspend&quot;,
 129   
          * or &quot;exit&quot;. They respectively clear recording, pause recording, 
 130   
          * resume recording, take a snapshot, suspend the recording and exit the program.
 131   
          */
 132  0
         public void setAction(String value) throws BuildException {
 133  0
             if (actionMap.get(value) == null) {
 134  0
                 throw new BuildException("Invalid action, must be one of " + actionMap);
 135   
             }
 136  0
             action = value;
 137   
         }
 138   
 
 139   
         /**
 140   
          * A alphanumeric custom name for the snapshot; optional.
 141   
          */
 142  0
         public void setParam(String value) {
 143  0
             param = value;
 144   
         }
 145   
 
 146   
         // return <name>:<event>:<action>[:param]
 147  0
         public String toString() {
 148  0
             StringBuffer buf = new StringBuffer();
 149  0
             buf.append(name).append(":"); //@todo name must not be null, check for it
 150  0
             buf.append(eventMap.get(event)).append(":");
 151  0
             buf.append(actionMap.get(action));
 152  0
             if (param != null) {
 153  0
                 buf.append(":").append(param);
 154   
             }
 155  0
             return buf.toString();
 156   
         }
 157   
     }
 158   
 
 159   
     /** mapping of actions to cryptic command line mnemonics */
 160   
     private static final Hashtable actionMap = new Hashtable(3);
 161   
 
 162   
     /** mapping of events to cryptic command line mnemonics */
 163   
     private static final Hashtable eventMap = new Hashtable(3);
 164   
 
 165   
     static {
 166  0
         actionMap.put("enter", "E");
 167  0
         actionMap.put("exit", "X");
 168   
         // clear|pause|resume|snapshot|suspend|exit
 169  0
         eventMap.put("clear", "C");
 170  0
         eventMap.put("pause", "P");
 171  0
         eventMap.put("resume", "R");
 172  0
         eventMap.put("snapshot", "S");
 173  0
         eventMap.put("suspend", "A");
 174  0
         eventMap.put("exit", "X");
 175   
     }
 176   
 
 177   
 }
 178