Methods Summary |
---|
public void | addConfiguredRegexp(org.apache.tools.ant.types.RegularExpression regExp)Adds a regexp element.
this.regexps.addElement(regExp);
|
public java.io.Reader | chain(java.io.Reader rdr)Creates a new LineContainsRegExp using the passed in
Reader for instantiation.
LineContainsRegExp newFilter = new LineContainsRegExp(rdr);
newFilter.setRegexps(getRegexps());
newFilter.setNegate(isNegated());
return newFilter;
|
private java.util.Vector | getRegexps()Returns the vector of regular expressions which must be contained within
a line read from the original stream in order for it to match this
filter.
return regexps;
|
private void | initialize()Parses parameters to add user defined regular expressions.
Parameter[] params = getParameters();
if (params != null) {
for (int i = 0; i < params.length; i++) {
if (REGEXP_KEY.equals(params[i].getType())) {
String pattern = params[i].getValue();
RegularExpression regexp = new RegularExpression();
regexp.setPattern(pattern);
regexps.addElement(regexp);
} else if (NEGATE_KEY.equals(params[i].getType())) {
setNegate(Project.toBoolean(params[i].getValue()));
}
}
}
|
public boolean | isNegated()Find out whether we have been negated.
return negate;
|
public int | read()Returns the next character in the filtered stream, only including
lines from the original stream which match all of the specified
regular expressions.
if (!getInitialized()) {
initialize();
setInitialized(true);
}
int ch = -1;
if (line != null) {
ch = line.charAt(0);
if (line.length() == 1) {
line = null;
} else {
line = line.substring(1);
}
} else {
final int regexpsSize = regexps.size();
for (line = readLine(); line != null; line = readLine()) {
boolean matches = true;
for (int i = 0; matches && i < regexpsSize; i++) {
RegularExpression regexp
= (RegularExpression) regexps.elementAt(i);
Regexp re = regexp.getRegexp(getProject());
matches = re.matches(line);
}
if (matches ^ isNegated()) {
break;
}
}
if (line != null) {
return read();
}
}
return ch;
|
public void | setNegate(boolean b)Set the negation mode. Default false (no negation).
negate = b;
|
private void | setRegexps(java.util.Vector regexps)Sets the vector of regular expressions which must be contained within
a line read from the original stream in order for it to match this
filter.
this.regexps = regexps;
|