Methods Summary |
---|
protected java.util.regex.Pattern | getCompiledPattern(int options)Get a compiled representation of the regexp pattern
int cOptions = getCompilerOptions(options);
try {
Pattern p = Pattern.compile(this.pattern, cOptions);
return p;
} catch (PatternSyntaxException e) {
throw new BuildException(e);
}
|
protected int | getCompilerOptions(int options)Convert the generic options to the regex compiler specific 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;
|
public java.util.Vector | getGroups(java.lang.String argument)Returns a Vector of matched groups found in the argument
using default options.
Group 0 will be the full match, the rest are the
parenthesized subexpressions .
return getGroups(argument, MATCH_DEFAULT);
|
public java.util.Vector | getGroups(java.lang.String input, int options)Returns a Vector of matched groups found in the argument.
Group 0 will be the full match, the rest are the
parenthesized subexpressions .
Pattern p = getCompiledPattern(options);
Matcher matcher = p.matcher(input);
if (!matcher.find()) {
return null;
}
Vector v = new Vector();
int cnt = matcher.groupCount();
for (int i = 0; i <= cnt; i++) {
String match = matcher.group(i);
// treat non-matching groups as empty matches
if (match == null) {
match = "";
}
v.addElement(match);
}
return v;
|
public java.lang.String | getPattern()Get a String representation of the regexp pattern
return pattern;
|
public boolean | matches(java.lang.String argument)Does the given argument match the pattern using default options?
return matches(argument, MATCH_DEFAULT);
|
public boolean | matches(java.lang.String input, int options)Does the given argument match the pattern?
try {
Pattern p = getCompiledPattern(options);
return p.matcher(input).find();
} catch (Exception e) {
throw new BuildException(e);
}
|
public void | setPattern(java.lang.String pattern)Set the regexp pattern from the String description.
this.pattern = pattern;
|