Browse Source

fmting/refactoring

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@551986 13f79535-47bb-0310-9956-ffa450edef68
master
Matthew Jason Benson 18 years ago
parent
commit
c64fafb60c
2 changed files with 24 additions and 36 deletions
  1. +9
    -15
      src/main/org/apache/tools/ant/util/regexp/RegexpFactory.java
  2. +15
    -21
      src/main/org/apache/tools/ant/util/regexp/RegexpMatcherFactory.java

+ 9
- 15
src/main/org/apache/tools/ant/util/regexp/RegexpFactory.java View File

@@ -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 class RegexpFactory extends RegexpMatcherFactory {
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 @@ public class RegexpFactory extends RegexpMatcherFactory {
} 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 @@ public class RegexpFactory extends RegexpMatcherFactory {
*
* @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);
}

}

+ 15
- 21
src/main/org/apache/tools/ant/util/regexp/RegexpMatcherFactory.java View File

@@ -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.ClasspathUtils;
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 @@ public class RegexpMatcherFactory {
* @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 @@ public class RegexpMatcherFactory {
} 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 @@ public class RegexpMatcherFactory {
* @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 @@ public class RegexpMatcherFactory {
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;


Loading…
Cancel
Save