Create a new regular expression matcher instance.
String systemDefault = null;
if (p == null) {
systemDefault = System.getProperty("ant.regexp.regexpimpl");
} else {
systemDefault = p.getProperty("ant.regexp.regexpimpl");
}
if (systemDefault != null) {
return createRegexpInstance(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 createRegexpInstance("org.apache.tools.ant.util.regexp.Jdk14RegexpRegexp");
} catch (BuildException be) {
cause = orCause(cause, be, JavaEnvUtils.getJavaVersionNumber() < 14);
}
try {
testAvailability("org.apache.oro.text.regex.Pattern");
return createRegexpInstance("org.apache.tools.ant.util.regexp.JakartaOroRegexp");
} catch (BuildException be) {
cause = orCause(cause, be, true);
}
try {
testAvailability("org.apache.regexp.RE");
return createRegexpInstance("org.apache.tools.ant.util.regexp.JakartaRegexpRegexp");
} catch (BuildException be) {
cause = orCause(cause, be, true);
}
throw new BuildException(
"No supported regular expression matcher found"
+ (cause != null ? ": " + cause : ""), cause);