Methods Summary |
---|
protected org.apache.regexp.RE | getCompiledPattern(int options)Compile the pattern.
int cOptions = getCompilerOptions(options);
try {
RE reg = new RE(pattern);
reg.setMatchFlags(cOptions);
return reg;
} catch (RESyntaxException e) {
throw new BuildException(e);
}
|
protected int | getCompilerOptions(int options)Convert the generic options to the regex compiler specific 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;
|
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 .
RE reg = getCompiledPattern(options);
if (!matches(input, reg)) {
return null;
}
Vector v = new Vector();
int cnt = reg.getParenCount();
for (int i = 0; i < cnt; i++) {
String match = reg.getParen(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?
return matches(argument, MATCH_DEFAULT);
|
public boolean | matches(java.lang.String input, int options)Does the given argument match the pattern?
return matches(input, getCompiledPattern(options));
|
private boolean | matches(java.lang.String input, org.apache.regexp.RE reg)
return reg.match(input);
|
public void | setPattern(java.lang.String pattern)Set the regexp pattern from the String description.
this.pattern = pattern;
|