/** * Convert ant regexp substitution option to jdk1.4 options. * * @param options the ant regexp options * @return the jdk14 substitution options */ protected int getSubsOptions(int options) { int subsOptions = REPLACE_FIRST; if (RegexpUtil.hasFlag(options, REPLACE_ALL)) { subsOptions = REPLACE_ALL; } return subsOptions; }
/** * Whether to match casesensitively. * @param b boolean * @since Ant 1.8.2 */ public void setCaseSensitive(boolean b) { regexpOptions = RegexpUtil.asOptions(b); }
/** * Convert the generic options to the regex compiler specific options. * @param options the generic options * @return the specific options */ protected int getCompilerOptions(int options) { // be strict about line separator int cOptions = Pattern.UNIX_LINES; if (RegexpUtil.hasFlag(options, MATCH_CASE_INSENSITIVE)) { cOptions |= Pattern.CASE_INSENSITIVE; } if (RegexpUtil.hasFlag(options, MATCH_MULTILINE)) { cOptions |= Pattern.MULTILINE; } if (RegexpUtil.hasFlag(options, MATCH_SINGLELINE)) { cOptions |= Pattern.DOTALL; } return cOptions; }
/** * Convert flag to regex options. * * @param caseSensitive opposite of RegexpMatcher.MATCH_CASE_INSENSITIVE * @return the Regexp option bits * @since Ant 1.8.2 */ public static int asOptions(boolean caseSensitive) { return asOptions(caseSensitive, false, false); }
if (RegexpUtil.hasFlag(sOptions, REPLACE_ALL)) { sb.append(m.replaceAll(subst.toString())); } else if (m.find()) {
/** * Attribute specifying whether to ignore the case difference * in the names. * * @param caseSensitive a boolean, default is false. * @since Ant 1.6.3 */ public void setCaseSensitive(boolean caseSensitive) { regexpOptions = RegexpUtil.asOptions(caseSensitive); }
/** * Creates a new LineContainsRegExp using the passed in * Reader for instantiation. * * @param rdr A Reader object providing the underlying stream. * Must not be <code>null</code>. * * @return a new filter based on this configuration, but filtering * the specified reader */ public Reader chain(final Reader rdr) { LineContainsRegExp newFilter = new LineContainsRegExp(rdr); newFilter.setRegexps(getRegexps()); newFilter.setNegate(isNegated()); newFilter.setCaseSensitive(!RegexpUtil.hasFlag(regexpOptions, Regexp.MATCH_CASE_INSENSITIVE)); return newFilter; }
/** * convert regex option flag characters to regex options * <ul> * <li>g - Regexp.REPLACE_ALL</li> * <li>i - Regexp.MATCH_CASE_INSENSITIVE</li> * <li>m - Regexp.MATCH_MULTILINE</li> * <li>s - Regexp.MATCH_SINGLELINE</li> * </ul> * @param flags the string containing the flags * @return the Regexp option bits */ public static int convertRegexOptions(String flags) { return RegexpUtil.asOptions(flags); } }
/** * Convert ant regexp substitution option to oro options. * * @param options the ant regexp options * @return the oro substitution options */ protected int getSubsOptions(final int options) { return RegexpUtil.hasFlag(options, REPLACE_ALL) ? Util.SUBSTITUTE_ALL : 1; }
/** * convert regex option flag characters to regex options * <dl> * <dt>g</dt><dd>Regexp.REPLACE_ALL</dd> * <dt>i</dt><dd>RegexpMatcher.MATCH_CASE_INSENSITIVE</dd> * <dt>m</dt><dd>RegexpMatcher.MATCH_MULTILINE</dd> * <dt>s</dt><dd>RegexpMatcher.MATCH_SINGLELINE</dd> * </dl> * @param flags the string containing the flags * @return the Regexp option bits * @since Ant 1.8.2 */ public static int asOptions(String flags) { int options = RegexpMatcher.MATCH_DEFAULT; if (flags != null) { options = asOptions(!flags.contains("i"), flags.contains("m"), flags.contains("s")); if (flags.contains("g")) { options |= Regexp.REPLACE_ALL; } } return options; }
/** * Convert ant regexp substitution option to apache regex options. * * @param options the ant regexp options * @return the apache regex substitution options */ protected int getSubsOptions(int options) { int subsOptions = RE.REPLACE_FIRSTONLY; if (RegexpUtil.hasFlag(options, REPLACE_ALL)) { subsOptions = RE.REPLACE_ALL; } return subsOptions; }
/** * @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); } }
/** * Convert the generic options to the regex compiler specific options. * @param options the generic options * @return the specific options */ protected int getCompilerOptions(final int options) { int cOptions = Perl5Compiler.DEFAULT_MASK; if (RegexpUtil.hasFlag(options, MATCH_CASE_INSENSITIVE)) { cOptions |= Perl5Compiler.CASE_INSENSITIVE_MASK; } if (RegexpUtil.hasFlag(options, MATCH_MULTILINE)) { cOptions |= Perl5Compiler.MULTILINE_MASK; } if (RegexpUtil.hasFlag(options, MATCH_SINGLELINE)) { cOptions |= Perl5Compiler.SINGLELINE_MASK; } return cOptions; }
int options = RegexpUtil.asOptions(flags);
/** * Convert the generic options to the regex compiler specific options. * @param options the generic options * @return the specific options */ protected int getCompilerOptions(int options) { int cOptions = RE.MATCH_NORMAL; if (RegexpUtil.hasFlag(options, MATCH_CASE_INSENSITIVE)) { cOptions |= RE.MATCH_CASEINDEPENDENT; } if (RegexpUtil.hasFlag(options, MATCH_MULTILINE)) { cOptions |= RE.MATCH_MULTILINE; } if (RegexpUtil.hasFlag(options, MATCH_SINGLELINE)) { cOptions |= RE.MATCH_SINGLELINE; } return cOptions; }
.asOptions(caseSensitive, multiLine, singleLine))) { return true;
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)); }
/** * 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; }