Methods Summary |
---|
public void | addConfiguredContains(org.apache.tools.ant.filters.LineContains$Contains contains)Adds a contains element.
this.contains.addElement(contains.getValue());
|
public java.io.Reader | chain(java.io.Reader rdr)Creates a new LineContains using the passed in
Reader for instantiation.
LineContains newFilter = new LineContains(rdr);
newFilter.setContains(getContains());
newFilter.setNegate(isNegated());
return newFilter;
|
private java.util.Vector | getContains()Returns the vector of words which must be contained within a line read
from the original stream in order for it to match this filter.
return contains;
|
private void | initialize()Parses the parameters to add user-defined contains strings.
Parameter[] params = getParameters();
if (params != null) {
for (int i = 0; i < params.length; i++) {
if (CONTAINS_KEY.equals(params[i].getType())) {
contains.addElement(params[i].getValue());
} 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 contain all of the specified words.
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 containsSize = contains.size();
for (line = readLine(); line != null; line = readLine()) {
boolean matches = true;
for (int i = 0; matches && i < containsSize; i++) {
String containsStr = (String) contains.elementAt(i);
matches = line.indexOf(containsStr) >= 0;
}
if (matches ^ isNegated()) {
break;
}
}
if (line != null) {
return read();
}
}
return ch;
|
private void | setContains(java.util.Vector contains)Sets the vector of words which must be contained within a line read
from the original stream in order for it to match this filter.
this.contains = contains;
|
public void | setNegate(boolean b)Set the negation mode. Default false (no negation).
negate = b;
|