Browse Source

Moved inner classes to top level classes and merged StringUtil into the class that uses it

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@270481 13f79535-47bb-0310-9956-ffa450edef68
master
Peter Donald 23 years ago
parent
commit
2b7e896783
10 changed files with 134 additions and 150 deletions
  1. +1
    -1
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/sitraka/CovReport.java
  2. +16
    -0
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/sitraka/Exclude.java
  3. +28
    -9
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/sitraka/FilterElement.java
  4. +16
    -0
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/sitraka/Include.java
  5. +6
    -65
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/sitraka/ReportFilters.java
  6. +1
    -1
      proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/sitraka/CovReport.java
  7. +16
    -0
      proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/sitraka/Exclude.java
  8. +28
    -9
      proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/sitraka/FilterElement.java
  9. +16
    -0
      proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/sitraka/Include.java
  10. +6
    -65
      proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/sitraka/ReportFilters.java

+ 1
- 1
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/sitraka/CovReport.java View File

@@ -395,7 +395,7 @@ public class CovReport extends Task
{
createFilters();
getLogger().debug( "Adding default include filter to *.*()" );
ReportFilters.Include include = new ReportFilters.Include();
Include include = new Include();
filters.addInclude( include );
}
try


+ 16
- 0
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/sitraka/Exclude.java View File

@@ -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
{
}

proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/sitraka/StringUtil.java → proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/sitraka/FilterElement.java View File

@@ -2,23 +2,42 @@
* 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
* 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;

/**
* 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 + "()";
}

/**

+ 16
- 0
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/sitraka/Include.java View File

@@ -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
{
}

+ 6
- 65
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/sitraka/ReportFilters.java View File

@@ -18,20 +18,15 @@ import org.apache.tools.ant.util.regexp.RegexpMatcherFactory;
*/
public class ReportFilters
{

/**
* user defined filters
*/
protected ArrayList filters = new ArrayList();
private ArrayList filters = new ArrayList();

/**
* cached matcher for each filter
*/
protected ArrayList matchers = null;

public ReportFilters()
{
}
private ArrayList m_matchers;

/**
* Check whether a given &lt;classname&gt;&lt;method&gt;() is accepted by
@@ -45,7 +40,7 @@ public class ReportFilters
{
// I'm deferring matcher instantiations at runtime to avoid computing
// the filters at parsing time
if( matchers == null )
if( m_matchers == null )
{
createMatchers();
}
@@ -55,7 +50,7 @@ public class ReportFilters
for( int i = 0; i < size; i++ )
{
FilterElement filter = (FilterElement)filters.get( i );
RegexpMatcher matcher = (RegexpMatcher)matchers.get( i );
RegexpMatcher matcher = (RegexpMatcher)m_matchers.get( i );
if( filter instanceof Include )
{
result = result || matcher.matches( methodname );
@@ -95,69 +90,15 @@ public class ReportFilters
{
RegexpMatcherFactory factory = new RegexpMatcherFactory();
final int size = filters.size();
matchers = new ArrayList();
m_matchers = new ArrayList();
for( int i = 0; i < size; i++ )
{
FilterElement filter = (FilterElement)filters.get( i );
RegexpMatcher matcher = factory.newRegexpMatcher();
String pattern = filter.getAsPattern();
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
{
}
}


+ 1
- 1
proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/sitraka/CovReport.java View File

@@ -395,7 +395,7 @@ public class CovReport extends Task
{
createFilters();
getLogger().debug( "Adding default include filter to *.*()" );
ReportFilters.Include include = new ReportFilters.Include();
Include include = new Include();
filters.addInclude( include );
}
try


+ 16
- 0
proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/sitraka/Exclude.java View File

@@ -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
{
}

proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/sitraka/StringUtil.java → proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/sitraka/FilterElement.java View File

@@ -2,23 +2,42 @@
* 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
* 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;

/**
* 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 + "()";
}

/**

+ 16
- 0
proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/sitraka/Include.java View File

@@ -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
{
}

+ 6
- 65
proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/sitraka/ReportFilters.java View File

@@ -18,20 +18,15 @@ import org.apache.tools.ant.util.regexp.RegexpMatcherFactory;
*/
public class ReportFilters
{

/**
* user defined filters
*/
protected ArrayList filters = new ArrayList();
private ArrayList filters = new ArrayList();

/**
* cached matcher for each filter
*/
protected ArrayList matchers = null;

public ReportFilters()
{
}
private ArrayList m_matchers;

/**
* Check whether a given &lt;classname&gt;&lt;method&gt;() is accepted by
@@ -45,7 +40,7 @@ public class ReportFilters
{
// I'm deferring matcher instantiations at runtime to avoid computing
// the filters at parsing time
if( matchers == null )
if( m_matchers == null )
{
createMatchers();
}
@@ -55,7 +50,7 @@ public class ReportFilters
for( int i = 0; i < size; i++ )
{
FilterElement filter = (FilterElement)filters.get( i );
RegexpMatcher matcher = (RegexpMatcher)matchers.get( i );
RegexpMatcher matcher = (RegexpMatcher)m_matchers.get( i );
if( filter instanceof Include )
{
result = result || matcher.matches( methodname );
@@ -95,69 +90,15 @@ public class ReportFilters
{
RegexpMatcherFactory factory = new RegexpMatcherFactory();
final int size = filters.size();
matchers = new ArrayList();
m_matchers = new ArrayList();
for( int i = 0; i < size; i++ )
{
FilterElement filter = (FilterElement)filters.get( i );
RegexpMatcher matcher = factory.newRegexpMatcher();
String pattern = filter.getAsPattern();
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
{
}
}


Loading…
Cancel
Save