Methods Summary |
---|
public void | addConfiguredComment(org.apache.tools.ant.filters.StripLineComments$Comment comment)Adds a comment element to the list of prefixes.
comments.addElement(comment.getValue());
|
public java.io.Reader | chain(java.io.Reader rdr)Creates a new StripLineComments using the passed in
Reader for instantiation.
StripLineComments newFilter = new StripLineComments(rdr);
newFilter.setComments(getComments());
newFilter.setInitialized(true);
return newFilter;
|
private java.util.Vector | getComments()Returns the list of comment prefixes to strip.
return comments;
|
private void | initialize()Parses the parameters to set the comment prefixes.
Parameter[] params = getParameters();
if (params != null) {
for (int i = 0; i < params.length; i++) {
if (COMMENTS_KEY.equals(params[i].getType())) {
comments.addElement(params[i].getValue());
}
}
}
|
public int | read()Returns the next character in the filtered stream, only including
lines from the original stream which don't start with any of the
specified comment prefixes.
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 {
line = readLine();
final int commentsSize = comments.size();
while (line != null) {
for (int i = 0; i < commentsSize; i++) {
String comment = (String) comments.elementAt(i);
if (line.startsWith(comment)) {
line = null;
break;
}
}
if (line == null) {
// line started with comment
line = readLine();
} else {
break;
}
}
if (line != null) {
return read();
}
}
return ch;
|
private void | setComments(java.util.Vector comments)Sets the list of comment prefixes to strip.
this.comments = comments;
|