Methods Summary |
---|
public boolean | isSelected(java.io.File basedir, java.lang.String filename, java.io.File file)Tests a regular expression against each line of text in the file.
return isSelected(new FileResource(file));
|
public boolean | isSelected(org.apache.tools.ant.types.Resource r)Tests a regular expression against each line of text in a Resource.
String teststr = null;
BufferedReader in = null;
// throw BuildException on error
validate();
if (r.isDirectory()) {
return true;
}
if (myRegExp == null) {
myRegExp = new RegularExpression();
myRegExp.setPattern(userProvidedExpression);
myExpression = myRegExp.getRegexp(getProject());
}
try {
in = new BufferedReader(new InputStreamReader(r.getInputStream()));
} catch (Exception e) {
throw new BuildException("Could not get InputStream from "
+ r.toLongString(), e);
}
try {
teststr = in.readLine();
while (teststr != null) {
if (myExpression.matches(teststr)) {
return true;
}
teststr = in.readLine();
}
return false;
} catch (IOException ioe) {
throw new BuildException("Could not read " + r.toLongString());
} finally {
if (in != null) {
try {
in.close();
} catch (Exception e) {
throw new BuildException("Could not close "
+ r.toLongString());
}
}
}
|
public void | setExpression(java.lang.String theexpression)The regular expression used to search the file.
this.userProvidedExpression = theexpression;
|
public void | setParameters(org.apache.tools.ant.types.Parameter[] parameters)When using this as a custom selector, this method will be called.
It translates each parameter into the appropriate setXXX() call.
super.setParameters(parameters);
if (parameters != null) {
for (int i = 0; i < parameters.length; i++) {
String paramname = parameters[i].getName();
if (EXPRESSION_KEY.equalsIgnoreCase(paramname)) {
setExpression(parameters[i].getValue());
} else {
setError("Invalid parameter " + paramname);
}
}
}
|
public java.lang.String | toString()
StringBuffer buf = new StringBuffer(
"{containsregexpselector expression: ");
buf.append(userProvidedExpression);
buf.append("}");
return buf.toString();
|
public void | verifySettings()Checks that an expression was specified.
if (userProvidedExpression == null) {
setError("The expression attribute is required");
}
|