Clover coverage report - Ant Coverage
Coverage timestamp: Tue Apr 8 2003 20:43:55 EST
file stats: LOC: 179   Methods: 12
NCLOC: 65   Classes: 4
 
 Source file Conditionals Statements Methods TOTAL
Filters.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.Vector;
 58   
 
 59   
 /**
 60   
  * Filters information from coverage, somewhat similar to a <tt>FileSet</tt>.
 61   
  *
 62   
  * @author <a href="mailto:sbailliez@imediation.com">Stephane Bailliez</a>
 63   
  */
 64   
 public class Filters {
 65   
 
 66   
     /** default regexp to exclude everything */
 67   
     public static final String DEFAULT_EXCLUDE = "*.*():E";
 68   
 
 69   
     /** say whether we should use the default excludes or not */
 70   
     protected boolean defaultExclude = true;
 71   
 
 72   
     /** user defined filters */
 73   
     protected Vector filters = new Vector();
 74   
 
 75  0
     public Filters() {
 76   
     }
 77   
 
 78   
     /**
 79   
      * Automatically exclude all classes and methods
 80   
      * unless included in nested elements; optional, default true. 
 81   
      */
 82  0
     public void setDefaultExclude(boolean value) {
 83  0
         defaultExclude = value;
 84   
     }
 85   
 
 86   
     /**
 87   
      * include classes and methods in the analysis
 88   
      */
 89  0
     public void addInclude(Include incl) {
 90  0
         filters.addElement(incl);
 91   
     }
 92   
 
 93   
     /**
 94   
      * exclude classes and methods from the analysis
 95   
      */
 96  0
     public void addExclude(Exclude excl) {
 97  0
         filters.addElement(excl);
 98   
     }
 99   
 
 100  0
     public String toString() {
 101  0
         StringBuffer buf = new StringBuffer();
 102  0
         final int size = filters.size();
 103  0
         if (defaultExclude) {
 104  0
             buf.append(DEFAULT_EXCLUDE);
 105  0
             if (size > 0) {
 106  0
                 buf.append(',');
 107   
             }
 108   
         }
 109  0
         for (int i = 0; i < size; i++) {
 110  0
             buf.append(filters.elementAt(i).toString());
 111  0
             if (i < size - 1) {
 112  0
                 buf.append(',');
 113   
             }
 114   
         }
 115  0
         return buf.toString();
 116   
     }
 117   
 
 118   
     /**
 119   
      * an includes or excludes element
 120   
      */
 121   
     public abstract static class FilterElement {
 122   
         protected String clazz;
 123   
         protected String method = "*"; // default is all methods
 124   
         protected boolean enabled = true; // default is enable
 125   
 
 126   
         /** 
 127   
          * this one is deprecated.
 128   
          * @ant.task ignore="true"
 129   
          */
 130   
          
 131  0
         public void setName(String value) { 
 132  0
             clazz = value;
 133   
         }
 134   
 
 135   
         /**
 136   
          * The classname mask as a simple regular expression;
 137   
          * optional, defaults to "*"
 138   
          */
 139  0
         public void setClass(String value) {
 140  0
             clazz = value;
 141   
         }
 142   
 
 143   
         /**
 144   
          * The method mask as a simple regular expression;
 145   
          * optional, defaults to "*"
 146   
          */
 147  0
         public void setMethod(String value) {
 148  0
             method = value;
 149   
         }
 150   
 
 151   
         /** 
 152   
          * enable or disable the filter; optional, default true
 153   
          */
 154   
                  
 155  0
         public void setEnabled(boolean value) {
 156  0
             enabled = value;
 157   
         }
 158   
 
 159  0
         public String toString() {
 160  0
             return clazz + "." + method + "()";
 161   
         }
 162   
     }
 163   
 
 164   
     public static class Include extends FilterElement {
 165  0
         public String toString() {
 166  0
             return super.toString() + ":I" + (enabled ? "" : "#");
 167   
         }
 168   
     }
 169   
 
 170   
     public static class Exclude extends FilterElement {
 171  0
         public String toString() {
 172  0
             return super.toString() + ":E" + (enabled ? "" : "#");
 173   
         }
 174   
     }
 175   
 }
 176   
 
 177   
 
 178   
 
 179