git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@270481 13f79535-47bb-0310-9956-ffa450edef68master
@@ -395,7 +395,7 @@ public class CovReport extends Task | |||||
{ | { | ||||
createFilters(); | createFilters(); | ||||
getLogger().debug( "Adding default include filter to *.*()" ); | getLogger().debug( "Adding default include filter to *.*()" ); | ||||
ReportFilters.Include include = new ReportFilters.Include(); | |||||
Include include = new Include(); | |||||
filters.addInclude( include ); | filters.addInclude( include ); | ||||
} | } | ||||
try | try | ||||
@@ -0,0 +1,16 @@ | |||||
/* | |||||
* Copyright (C) The Apache Software Foundation. All rights reserved. | |||||
* | |||||
* This software is published under the terms of the Apache Software License | |||||
* version 1.1, a copy of which has been included with this distribution in | |||||
* the LICENSE.txt file. | |||||
*/ | |||||
package org.apache.tools.ant.taskdefs.optional.sitraka; | |||||
/** | |||||
* concrete exclude class | |||||
*/ | |||||
public class Exclude | |||||
extends FilterElement | |||||
{ | |||||
} |
@@ -2,23 +2,42 @@ | |||||
* Copyright (C) The Apache Software Foundation. All rights reserved. | * Copyright (C) The Apache Software Foundation. All rights reserved. | ||||
* | * | ||||
* This software is published under the terms of the Apache Software License | * This software is published under the terms of the Apache Software License | ||||
* version 1.1, a copy of which has been included with this distribution in | |||||
* version 1.1, a copy of which has been included with this distribution in | |||||
* the LICENSE.txt file. | * the LICENSE.txt file. | ||||
*/ | */ | ||||
package org.apache.tools.ant.taskdefs.optional.sitraka; | package org.apache.tools.ant.taskdefs.optional.sitraka; | ||||
/** | /** | ||||
* String utilities method. | |||||
* | |||||
* @author <a href="mailto:sbailliez@imediation.com">Stephane Bailliez</a> | |||||
* default abstract filter element class | |||||
*/ | */ | ||||
public final class StringUtil | |||||
public abstract class FilterElement | |||||
{ | { | ||||
/** | |||||
* private constructor, it's a utility class | |||||
*/ | |||||
private StringUtil() | |||||
protected String clazz = "*";// default is all classes | |||||
protected String method = "*";// default is all methods | |||||
public void setClass( String value ) | |||||
{ | |||||
clazz = value; | |||||
} | |||||
public void setMethod( String value ) | |||||
{ | |||||
method = value; | |||||
} | |||||
public String getAsPattern() | |||||
{ | |||||
StringBuffer buf = new StringBuffer( toString() ); | |||||
replace( buf, ".", "\\." ); | |||||
replace( buf, "*", ".*" ); | |||||
replace( buf, "(", "\\(" ); | |||||
replace( buf, ")", "\\)" ); | |||||
return buf.toString(); | |||||
} | |||||
public String toString() | |||||
{ | { | ||||
return clazz + "." + method + "()"; | |||||
} | } | ||||
/** | /** |
@@ -0,0 +1,16 @@ | |||||
/* | |||||
* Copyright (C) The Apache Software Foundation. All rights reserved. | |||||
* | |||||
* This software is published under the terms of the Apache Software License | |||||
* version 1.1, a copy of which has been included with this distribution in | |||||
* the LICENSE.txt file. | |||||
*/ | |||||
package org.apache.tools.ant.taskdefs.optional.sitraka; | |||||
/** | |||||
* concrete include class | |||||
*/ | |||||
public class Include | |||||
extends FilterElement | |||||
{ | |||||
} |
@@ -18,20 +18,15 @@ import org.apache.tools.ant.util.regexp.RegexpMatcherFactory; | |||||
*/ | */ | ||||
public class ReportFilters | public class ReportFilters | ||||
{ | { | ||||
/** | /** | ||||
* user defined filters | * user defined filters | ||||
*/ | */ | ||||
protected ArrayList filters = new ArrayList(); | |||||
private ArrayList filters = new ArrayList(); | |||||
/** | /** | ||||
* cached matcher for each filter | * cached matcher for each filter | ||||
*/ | */ | ||||
protected ArrayList matchers = null; | |||||
public ReportFilters() | |||||
{ | |||||
} | |||||
private ArrayList m_matchers; | |||||
/** | /** | ||||
* Check whether a given <classname><method>() is accepted by | * Check whether a given <classname><method>() is accepted by | ||||
@@ -45,7 +40,7 @@ public class ReportFilters | |||||
{ | { | ||||
// I'm deferring matcher instantiations at runtime to avoid computing | // I'm deferring matcher instantiations at runtime to avoid computing | ||||
// the filters at parsing time | // the filters at parsing time | ||||
if( matchers == null ) | |||||
if( m_matchers == null ) | |||||
{ | { | ||||
createMatchers(); | createMatchers(); | ||||
} | } | ||||
@@ -55,7 +50,7 @@ public class ReportFilters | |||||
for( int i = 0; i < size; i++ ) | for( int i = 0; i < size; i++ ) | ||||
{ | { | ||||
FilterElement filter = (FilterElement)filters.get( i ); | FilterElement filter = (FilterElement)filters.get( i ); | ||||
RegexpMatcher matcher = (RegexpMatcher)matchers.get( i ); | |||||
RegexpMatcher matcher = (RegexpMatcher)m_matchers.get( i ); | |||||
if( filter instanceof Include ) | if( filter instanceof Include ) | ||||
{ | { | ||||
result = result || matcher.matches( methodname ); | result = result || matcher.matches( methodname ); | ||||
@@ -95,69 +90,15 @@ public class ReportFilters | |||||
{ | { | ||||
RegexpMatcherFactory factory = new RegexpMatcherFactory(); | RegexpMatcherFactory factory = new RegexpMatcherFactory(); | ||||
final int size = filters.size(); | final int size = filters.size(); | ||||
matchers = new ArrayList(); | |||||
m_matchers = new ArrayList(); | |||||
for( int i = 0; i < size; i++ ) | for( int i = 0; i < size; i++ ) | ||||
{ | { | ||||
FilterElement filter = (FilterElement)filters.get( i ); | FilterElement filter = (FilterElement)filters.get( i ); | ||||
RegexpMatcher matcher = factory.newRegexpMatcher(); | RegexpMatcher matcher = factory.newRegexpMatcher(); | ||||
String pattern = filter.getAsPattern(); | String pattern = filter.getAsPattern(); | ||||
matcher.setPattern( pattern ); | matcher.setPattern( pattern ); | ||||
matchers.add( matcher ); | |||||
} | |||||
} | |||||
/** | |||||
* concrete exclude class | |||||
* | |||||
* @author RT | |||||
*/ | |||||
public static class Exclude extends FilterElement | |||||
{ | |||||
} | |||||
/** | |||||
* default abstract filter element class | |||||
* | |||||
* @author RT | |||||
*/ | |||||
public abstract static class FilterElement | |||||
{ | |||||
protected String clazz = "*";// default is all classes | |||||
protected String method = "*";// default is all methods | |||||
public void setClass( String value ) | |||||
{ | |||||
clazz = value; | |||||
} | |||||
public void setMethod( String value ) | |||||
{ | |||||
method = value; | |||||
m_matchers.add( matcher ); | |||||
} | } | ||||
public String getAsPattern() | |||||
{ | |||||
StringBuffer buf = new StringBuffer( toString() ); | |||||
StringUtil.replace( buf, ".", "\\." ); | |||||
StringUtil.replace( buf, "*", ".*" ); | |||||
StringUtil.replace( buf, "(", "\\(" ); | |||||
StringUtil.replace( buf, ")", "\\)" ); | |||||
return buf.toString(); | |||||
} | |||||
public String toString() | |||||
{ | |||||
return clazz + "." + method + "()"; | |||||
} | |||||
} | |||||
/** | |||||
* concrete include class | |||||
* | |||||
* @author RT | |||||
*/ | |||||
public static class Include extends FilterElement | |||||
{ | |||||
} | } | ||||
} | } | ||||
@@ -395,7 +395,7 @@ public class CovReport extends Task | |||||
{ | { | ||||
createFilters(); | createFilters(); | ||||
getLogger().debug( "Adding default include filter to *.*()" ); | getLogger().debug( "Adding default include filter to *.*()" ); | ||||
ReportFilters.Include include = new ReportFilters.Include(); | |||||
Include include = new Include(); | |||||
filters.addInclude( include ); | filters.addInclude( include ); | ||||
} | } | ||||
try | try | ||||
@@ -0,0 +1,16 @@ | |||||
/* | |||||
* Copyright (C) The Apache Software Foundation. All rights reserved. | |||||
* | |||||
* This software is published under the terms of the Apache Software License | |||||
* version 1.1, a copy of which has been included with this distribution in | |||||
* the LICENSE.txt file. | |||||
*/ | |||||
package org.apache.tools.ant.taskdefs.optional.sitraka; | |||||
/** | |||||
* concrete exclude class | |||||
*/ | |||||
public class Exclude | |||||
extends FilterElement | |||||
{ | |||||
} |
@@ -2,23 +2,42 @@ | |||||
* Copyright (C) The Apache Software Foundation. All rights reserved. | * Copyright (C) The Apache Software Foundation. All rights reserved. | ||||
* | * | ||||
* This software is published under the terms of the Apache Software License | * This software is published under the terms of the Apache Software License | ||||
* version 1.1, a copy of which has been included with this distribution in | |||||
* version 1.1, a copy of which has been included with this distribution in | |||||
* the LICENSE.txt file. | * the LICENSE.txt file. | ||||
*/ | */ | ||||
package org.apache.tools.ant.taskdefs.optional.sitraka; | package org.apache.tools.ant.taskdefs.optional.sitraka; | ||||
/** | /** | ||||
* String utilities method. | |||||
* | |||||
* @author <a href="mailto:sbailliez@imediation.com">Stephane Bailliez</a> | |||||
* default abstract filter element class | |||||
*/ | */ | ||||
public final class StringUtil | |||||
public abstract class FilterElement | |||||
{ | { | ||||
/** | |||||
* private constructor, it's a utility class | |||||
*/ | |||||
private StringUtil() | |||||
protected String clazz = "*";// default is all classes | |||||
protected String method = "*";// default is all methods | |||||
public void setClass( String value ) | |||||
{ | |||||
clazz = value; | |||||
} | |||||
public void setMethod( String value ) | |||||
{ | |||||
method = value; | |||||
} | |||||
public String getAsPattern() | |||||
{ | |||||
StringBuffer buf = new StringBuffer( toString() ); | |||||
replace( buf, ".", "\\." ); | |||||
replace( buf, "*", ".*" ); | |||||
replace( buf, "(", "\\(" ); | |||||
replace( buf, ")", "\\)" ); | |||||
return buf.toString(); | |||||
} | |||||
public String toString() | |||||
{ | { | ||||
return clazz + "." + method + "()"; | |||||
} | } | ||||
/** | /** |
@@ -0,0 +1,16 @@ | |||||
/* | |||||
* Copyright (C) The Apache Software Foundation. All rights reserved. | |||||
* | |||||
* This software is published under the terms of the Apache Software License | |||||
* version 1.1, a copy of which has been included with this distribution in | |||||
* the LICENSE.txt file. | |||||
*/ | |||||
package org.apache.tools.ant.taskdefs.optional.sitraka; | |||||
/** | |||||
* concrete include class | |||||
*/ | |||||
public class Include | |||||
extends FilterElement | |||||
{ | |||||
} |
@@ -18,20 +18,15 @@ import org.apache.tools.ant.util.regexp.RegexpMatcherFactory; | |||||
*/ | */ | ||||
public class ReportFilters | public class ReportFilters | ||||
{ | { | ||||
/** | /** | ||||
* user defined filters | * user defined filters | ||||
*/ | */ | ||||
protected ArrayList filters = new ArrayList(); | |||||
private ArrayList filters = new ArrayList(); | |||||
/** | /** | ||||
* cached matcher for each filter | * cached matcher for each filter | ||||
*/ | */ | ||||
protected ArrayList matchers = null; | |||||
public ReportFilters() | |||||
{ | |||||
} | |||||
private ArrayList m_matchers; | |||||
/** | /** | ||||
* Check whether a given <classname><method>() is accepted by | * Check whether a given <classname><method>() is accepted by | ||||
@@ -45,7 +40,7 @@ public class ReportFilters | |||||
{ | { | ||||
// I'm deferring matcher instantiations at runtime to avoid computing | // I'm deferring matcher instantiations at runtime to avoid computing | ||||
// the filters at parsing time | // the filters at parsing time | ||||
if( matchers == null ) | |||||
if( m_matchers == null ) | |||||
{ | { | ||||
createMatchers(); | createMatchers(); | ||||
} | } | ||||
@@ -55,7 +50,7 @@ public class ReportFilters | |||||
for( int i = 0; i < size; i++ ) | for( int i = 0; i < size; i++ ) | ||||
{ | { | ||||
FilterElement filter = (FilterElement)filters.get( i ); | FilterElement filter = (FilterElement)filters.get( i ); | ||||
RegexpMatcher matcher = (RegexpMatcher)matchers.get( i ); | |||||
RegexpMatcher matcher = (RegexpMatcher)m_matchers.get( i ); | |||||
if( filter instanceof Include ) | if( filter instanceof Include ) | ||||
{ | { | ||||
result = result || matcher.matches( methodname ); | result = result || matcher.matches( methodname ); | ||||
@@ -95,69 +90,15 @@ public class ReportFilters | |||||
{ | { | ||||
RegexpMatcherFactory factory = new RegexpMatcherFactory(); | RegexpMatcherFactory factory = new RegexpMatcherFactory(); | ||||
final int size = filters.size(); | final int size = filters.size(); | ||||
matchers = new ArrayList(); | |||||
m_matchers = new ArrayList(); | |||||
for( int i = 0; i < size; i++ ) | for( int i = 0; i < size; i++ ) | ||||
{ | { | ||||
FilterElement filter = (FilterElement)filters.get( i ); | FilterElement filter = (FilterElement)filters.get( i ); | ||||
RegexpMatcher matcher = factory.newRegexpMatcher(); | RegexpMatcher matcher = factory.newRegexpMatcher(); | ||||
String pattern = filter.getAsPattern(); | String pattern = filter.getAsPattern(); | ||||
matcher.setPattern( pattern ); | matcher.setPattern( pattern ); | ||||
matchers.add( matcher ); | |||||
} | |||||
} | |||||
/** | |||||
* concrete exclude class | |||||
* | |||||
* @author RT | |||||
*/ | |||||
public static class Exclude extends FilterElement | |||||
{ | |||||
} | |||||
/** | |||||
* default abstract filter element class | |||||
* | |||||
* @author RT | |||||
*/ | |||||
public abstract static class FilterElement | |||||
{ | |||||
protected String clazz = "*";// default is all classes | |||||
protected String method = "*";// default is all methods | |||||
public void setClass( String value ) | |||||
{ | |||||
clazz = value; | |||||
} | |||||
public void setMethod( String value ) | |||||
{ | |||||
method = value; | |||||
m_matchers.add( matcher ); | |||||
} | } | ||||
public String getAsPattern() | |||||
{ | |||||
StringBuffer buf = new StringBuffer( toString() ); | |||||
StringUtil.replace( buf, ".", "\\." ); | |||||
StringUtil.replace( buf, "*", ".*" ); | |||||
StringUtil.replace( buf, "(", "\\(" ); | |||||
StringUtil.replace( buf, ")", "\\)" ); | |||||
return buf.toString(); | |||||
} | |||||
public String toString() | |||||
{ | |||||
return clazz + "." + method + "()"; | |||||
} | |||||
} | |||||
/** | |||||
* concrete include class | |||||
* | |||||
* @author RT | |||||
*/ | |||||
public static class Include extends FilterElement | |||||
{ | |||||
} | } | ||||
} | } | ||||