Methods Summary |
---|
protected RegexpMatcher | createInstance(java.lang.String className)Create an instance of a matcher from a classname.
return (RegexpMatcher) ClasspathUtils.newInstance(className,
RegexpMatcherFactory.class.getClassLoader(), RegexpMatcher.class);
|
public RegexpMatcher | newRegexpMatcher()Create a new regular expression instance.
return newRegexpMatcher(null);
|
public RegexpMatcher | newRegexpMatcher(org.apache.tools.ant.Project p)Create a new regular expression instance.
String systemDefault = null;
if (p == null) {
systemDefault = System.getProperty(MagicNames.REGEXP_IMPL);
} else {
systemDefault = p.getProperty(MagicNames.REGEXP_IMPL);
}
if (systemDefault != null) {
return createInstance(systemDefault);
// XXX should we silently catch possible exceptions and try to
// load a different implementation?
}
Throwable cause = null;
try {
testAvailability("java.util.regex.Matcher");
return createInstance("org.apache.tools.ant.util.regexp.Jdk14RegexpMatcher");
} catch (BuildException be) {
cause = orCause(cause, be, JavaEnvUtils.getJavaVersionNumber() < 14);
}
try {
testAvailability("org.apache.oro.text.regex.Pattern");
return createInstance("org.apache.tools.ant.util.regexp.JakartaOroMatcher");
} catch (BuildException be) {
cause = orCause(cause, be, true);
}
try {
testAvailability("org.apache.regexp.RE");
return createInstance("org.apache.tools.ant.util.regexp.JakartaRegexpMatcher");
} catch (BuildException be) {
cause = orCause(cause, be, true);
}
throw new BuildException(
"No supported regular expression matcher found"
+ (cause != null ? ": " + cause : ""), cause);
|
static java.lang.Throwable | orCause(java.lang.Throwable deflt, org.apache.tools.ant.BuildException be, boolean ignoreCnfe)
if (deflt != null) {
return deflt;
}
Throwable t = be.getException();
return ignoreCnfe && t instanceof ClassNotFoundException ? null : t;
|
protected void | testAvailability(java.lang.String className)Test if a particular class is available to be used.
try {
Class.forName(className);
} catch (Throwable t) {
throw new BuildException(t);
}
|