/** * Constructor for RegexpPatternMapper. * @throws BuildException on error. */ public RegexpPatternMapper() throws BuildException { reg = (new RegexpMatcherFactory()).newRegexpMatcher(); }
/*** * Create a new regular expression instance. * @return the matcher * @throws BuildException on error */ public RegexpMatcher newRegexpMatcher() throws BuildException { return newRegexpMatcher(null); }
/*** * Create a new regular expression instance. * * @param p Project whose ant.regexp.regexpimpl property will be used. * @return the matcher * @throws BuildException on error */ public RegexpMatcher newRegexpMatcher(Project p) throws BuildException { String systemDefault; if (p == null) { systemDefault = System.getProperty(MagicNames.REGEXP_IMPL); } else { systemDefault = p.getProperty(MagicNames.REGEXP_IMPL); } if (systemDefault != null) { return createInstance(systemDefault); // TODO should we silently catch possible exceptions and try to // load a different implementation? } return new Jdk14RegexpMatcher(); }
/** * Checks if a RegExp-Matcher is available. * @param project The project to check for (may be <code>null</code>) * @return <code>true</code> if available otherwise <code>false</code> */ public static boolean regexpMatcherPresent(Project project) { try { // The factory throws a BuildException if no usable matcher // cannot be instantiated. We don't need the matcher itself here. new RegexpMatcherFactory().newRegexpMatcher(project); return true; } catch (Throwable ex) { return false; } } }
RegexpMatcherFactory matchMaker = new RegexpMatcherFactory(); RegexpMatcher matcher = matchMaker.newRegexpMatcher(); matcher.setPattern(r.regex); for (String name : props.keySet()) {