/** * @return true if the string matches the regular expression pattern * @exception BuildException if the attributes are not set correctly */ public boolean eval() throws BuildException { if (string == null) { throw new BuildException( "Parameter string is required in matches."); } if (regularExpression == null) { throw new BuildException("Missing pattern in matches."); } int options = RegexpUtil.asOptions(caseSensitive, multiLine, singleLine); Regexp regexp = regularExpression.getRegexp(getProject()); return regexp.matches(string, options); } }
/** * @param line the string to modify * @return the modified string */ public String filter(String line) { initialize(); if (!regexp.matches(line, options)) { return line; } return regexp.substitute( line, substitution.getExpression(getProject()), options); } }
/** * apply regex and substitution on a string * @param string the string to apply filter on * @return the filtered string */ public String filter(String string) { initialize(); if (!regexp.matches(string, options)) { return null; } if (substitution == null) { return string; } return regexp.substitute( string, substitution.getExpression(getProject()), options); } }
if (myExpression.matches(teststr, RegexpUtil .asOptions(caseSensitive, multiLine, singleLine))) { return true;
boolean matches = true; for (RegularExpression regexp : regexps) { if (!regexp.getRegexp(getProject()).matches(line, regexpOptions)) { matches = false; break;
private boolean matches(String name) { if (pattern != null) { return SelectorUtils.match(modify(pattern), modify(name), cs); } if (reg == null) { reg = new RegularExpression(); reg.setPattern(regex); expression = reg.getRegexp(project); } return expression.matches(modify(name), RegexpUtil.asOptions(cs)); }
/** * Invoke a regular expression (r) on a string (input) using * substitutions (s) for a matching regex. * * @param r a regular expression * @param s a Substitution * @param input the string to do the replacement on * @param options The options for the regular expression * @return the replacement result */ protected String doReplace(RegularExpression r, Substitution s, String input, int options) { String res = input; Regexp regexp = r.getRegexp(getProject()); if (regexp.matches(input, options)) { log("Found match; substituting", Project.MSG_DEBUG); res = regexp.substitute(input, s.getExpression(getProject()), options); } return res; }
/** * The heart of the matter. This is where the selector gets to decide * on the inclusion of a file in a particular fileset. Most of the work * for this selector is offloaded into SelectorUtils, a static class * that provides the same services for both FilenameSelector and * DirectoryScanner. * * @param basedir the base directory the scan is being done from * @param filename is the name of the file to check * @param file is a java.io.File object the selector can use * @return whether the file should be selected or not */ public boolean isSelected(File basedir, String filename, File file) { validate(); if (pattern != null) { return SelectorUtils.matchPath(pattern, filename, casesensitive) == !(negated); } if (reg == null) { reg = new RegularExpression(); reg.setPattern(regex); expression = reg.getRegexp(getProject()); } int options = RegexpUtil.asOptions(casesensitive); return expression.matches(filename, options) == !negated; }