ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mben...@apache.org
Subject svn commit: r551986 - in /ant/core/trunk/src/main/org/apache/tools/ant/util/regexp: RegexpFactory.java RegexpMatcherFactory.java
Date Fri, 29 Jun 2007 18:14:51 GMT
Author: mbenson
Date: Fri Jun 29 11:14:51 2007
New Revision: 551986

URL: http://svn.apache.org/viewvc?view=rev&rev=551986
Log:
fmting/refactoring

Modified:
    ant/core/trunk/src/main/org/apache/tools/ant/util/regexp/RegexpFactory.java
    ant/core/trunk/src/main/org/apache/tools/ant/util/regexp/RegexpMatcherFactory.java

Modified: ant/core/trunk/src/main/org/apache/tools/ant/util/regexp/RegexpFactory.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/util/regexp/RegexpFactory.java?view=diff&rev=551986&r1=551985&r2=551986
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/util/regexp/RegexpFactory.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/util/regexp/RegexpFactory.java Fri Jun 29
11:14:51 2007
@@ -18,7 +18,9 @@
 package org.apache.tools.ant.util.regexp;
 
 import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.MagicNames;
 import org.apache.tools.ant.Project;
+import org.apache.tools.ant.util.ClasspathUtils;
 import org.apache.tools.ant.util.JavaEnvUtils;
 
 /***
@@ -52,9 +54,9 @@
     public Regexp newRegexp(Project p) throws BuildException {
         String systemDefault = null;
         if (p == null) {
-            systemDefault = System.getProperty("ant.regexp.regexpimpl");
+            systemDefault = System.getProperty(MagicNames.REGEXP_IMPL);
         } else {
-            systemDefault = p.getProperty("ant.regexp.regexpimpl");
+            systemDefault = p.getProperty(MagicNames.REGEXP_IMPL);
         }
 
         if (systemDefault != null) {
@@ -85,10 +87,8 @@
         } catch (BuildException be) {
             cause = orCause(cause, be, true);
         }
-
-        throw new BuildException(
-            "No supported regular expression matcher found"
-            + (cause != null ? ": " + cause : ""), cause);
+        throw new BuildException("No supported regular expression matcher found"
+                + (cause != null ? ": " + cause : ""), cause);
     }
 
     /**
@@ -101,15 +101,9 @@
      *
      * @see RegexpMatcherFactory#createInstance(String)
      */
-    protected Regexp createRegexpInstance(String classname)
-        throws BuildException {
-
-        RegexpMatcher m = createInstance(classname);
-        if (m instanceof Regexp) {
-            return (Regexp) m;
-        } else {
-            throw new BuildException(classname + " doesn't implement the Regexp interface");
-        }
+    protected Regexp createRegexpInstance(String classname) throws BuildException {
+        return (Regexp) ClasspathUtils.newInstance(classname, RegexpFactory.class.getClassLoader(),
+                Regexp.class);
     }
 
 }

Modified: ant/core/trunk/src/main/org/apache/tools/ant/util/regexp/RegexpMatcherFactory.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/util/regexp/RegexpMatcherFactory.java?view=diff&rev=551986&r1=551985&r2=551986
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/util/regexp/RegexpMatcherFactory.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/util/regexp/RegexpMatcherFactory.java Fri
Jun 29 11:14:51 2007
@@ -15,7 +15,6 @@
  *  limitations under the License.
  *
  */
-
 package org.apache.tools.ant.util.regexp;
 
 import org.apache.tools.ant.Project;
@@ -25,14 +24,13 @@
 import org.apache.tools.ant.util.JavaEnvUtils;
 
 /**
- * Simple Factory Class that produces an implementation of
- * RegexpMatcher based on the system property
- * <code>ant.regexp.regexpimpl</code> and the classes
- * available.
- *
- * <p>In a more general framework this class would be abstract and
- * have a static newInstance method.</p>
- *
+ * Simple Factory Class that produces an implementation of RegexpMatcher based on the system
+ * property <code>ant.regexp.regexpimpl</code> and the classes available.
+ * 
+ * <p>
+ * In a more general framework this class would be abstract and have a static newInstance
method.
+ * </p>
+ * 
  */
 public class RegexpMatcherFactory {
 
@@ -56,8 +54,7 @@
      * @return the matcher
      * @throws BuildException on error
      */
-    public RegexpMatcher newRegexpMatcher(Project p)
-        throws BuildException {
+    public RegexpMatcher newRegexpMatcher(Project p) throws BuildException {
         String systemDefault = null;
         if (p == null) {
             systemDefault = System.getProperty(MagicNames.REGEXP_IMPL);
@@ -93,11 +90,9 @@
         } catch (BuildException be) {
             cause = orCause(cause, be, true);
         }
-
-        throw new BuildException(
-            "No supported regular expression matcher found"
-            + (cause != null ? ": " + cause : ""), cause);
-   }
+        throw new BuildException("No supported regular expression matcher found"
+                + (cause != null ? ": " + cause : ""), cause);
+    }
 
     static Throwable orCause(Throwable deflt, BuildException be, boolean ignoreCnfe) {
         if (deflt != null) {
@@ -114,10 +109,9 @@
      * @return a <code>RegexpMatcher</code> value
      * @exception BuildException if an error occurs
      */
-    protected RegexpMatcher createInstance(String className)
-        throws BuildException {
-        return (RegexpMatcher) ClasspathUtils.newInstance(className,
-                RegexpMatcherFactory.class.getClassLoader(), RegexpMatcher.class);
+    protected RegexpMatcher createInstance(String className) throws BuildException {
+        return (RegexpMatcher) ClasspathUtils.newInstance(className, RegexpMatcherFactory.class
+                .getClassLoader(), RegexpMatcher.class);
     }
 
     /**
@@ -143,7 +137,7 @@
         try {
             // The factory throws a BuildException if no usable matcher 
             // cant be instantiated. We dont need the matcher itself here.
-            (new RegexpMatcherFactory()).newRegexpMatcher(project);
+            new RegexpMatcherFactory().newRegexpMatcher(project);
             return true;
         } catch (Throwable ex) {
             return false;



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Mime
View raw message