From 2b7e89678394d7eee73fa601d2d0a9959391245c Mon Sep 17 00:00:00 2001 From: Peter Donald Date: Sun, 30 Dec 2001 11:08:30 +0000 Subject: [PATCH] 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 --- .../taskdefs/optional/sitraka/CovReport.java | 2 +- .../taskdefs/optional/sitraka/Exclude.java | 16 +++++ .../{StringUtil.java => FilterElement.java} | 37 +++++++--- .../taskdefs/optional/sitraka/Include.java | 16 +++++ .../optional/sitraka/ReportFilters.java | 71 ++----------------- .../taskdefs/optional/sitraka/CovReport.java | 2 +- .../taskdefs/optional/sitraka/Exclude.java | 16 +++++ .../{StringUtil.java => FilterElement.java} | 37 +++++++--- .../taskdefs/optional/sitraka/Include.java | 16 +++++ .../optional/sitraka/ReportFilters.java | 71 ++----------------- 10 files changed, 134 insertions(+), 150 deletions(-) create mode 100644 proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/sitraka/Exclude.java rename proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/sitraka/{StringUtil.java => FilterElement.java} (57%) create mode 100644 proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/sitraka/Include.java create mode 100644 proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/sitraka/Exclude.java rename proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/sitraka/{StringUtil.java => FilterElement.java} (57%) create mode 100644 proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/sitraka/Include.java diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/sitraka/CovReport.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/sitraka/CovReport.java index 0ef1e9d28..6aee84050 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/sitraka/CovReport.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/sitraka/CovReport.java @@ -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 diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/sitraka/Exclude.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/sitraka/Exclude.java new file mode 100644 index 000000000..8aa8fcc79 --- /dev/null +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/sitraka/Exclude.java @@ -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 +{ +} diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/sitraka/StringUtil.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/sitraka/FilterElement.java similarity index 57% rename from proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/sitraka/StringUtil.java rename to proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/sitraka/FilterElement.java index 7ebd01802..c9c787f1f 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/sitraka/StringUtil.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/sitraka/FilterElement.java @@ -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 Stephane Bailliez + * 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 + "()"; } /** diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/sitraka/Include.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/sitraka/Include.java new file mode 100644 index 000000000..eb22be843 --- /dev/null +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/sitraka/Include.java @@ -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 +{ +} diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/sitraka/ReportFilters.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/sitraka/ReportFilters.java index b6dea968b..d4ce69407 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/sitraka/ReportFilters.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/sitraka/ReportFilters.java @@ -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 <classname><method>() 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 - { } } diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/sitraka/CovReport.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/sitraka/CovReport.java index 0ef1e9d28..6aee84050 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/sitraka/CovReport.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/sitraka/CovReport.java @@ -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 diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/sitraka/Exclude.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/sitraka/Exclude.java new file mode 100644 index 000000000..8aa8fcc79 --- /dev/null +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/sitraka/Exclude.java @@ -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 +{ +} diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/sitraka/StringUtil.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/sitraka/FilterElement.java similarity index 57% rename from proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/sitraka/StringUtil.java rename to proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/sitraka/FilterElement.java index 7ebd01802..c9c787f1f 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/sitraka/StringUtil.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/sitraka/FilterElement.java @@ -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 Stephane Bailliez + * 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 + "()"; } /** diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/sitraka/Include.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/sitraka/Include.java new file mode 100644 index 000000000..eb22be843 --- /dev/null +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/sitraka/Include.java @@ -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 +{ +} diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/sitraka/ReportFilters.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/sitraka/ReportFilters.java index b6dea968b..d4ce69407 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/sitraka/ReportFilters.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/sitraka/ReportFilters.java @@ -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 <classname><method>() 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 - { } }