Methods Summary |
---|
public boolean | isSelected(java.io.File basedir, java.lang.String filename, java.io.File file)The heart of the matter. This is where the selector gets to decide
on the inclusion of a file in a particular fileset.
return isSelected(new FileResource(file));
|
public boolean | isSelected(org.apache.tools.ant.types.Resource r)The heart of the matter. This is where the selector gets to decide
on the inclusion of a Resource.
// throw BuildException on error
validate();
if (r.isDirectory()) {
return true;
}
String userstr = contains;
if (!casesensitive) {
userstr = contains.toLowerCase();
}
if (ignorewhitespace) {
userstr = SelectorUtils.removeWhitespace(userstr);
}
BufferedReader in = null;
try {
in = new BufferedReader(new InputStreamReader(r.getInputStream()));
} catch (Exception e) {
throw new BuildException("Could not get InputStream from "
+ r.toLongString(), e);
}
try {
String teststr = in.readLine();
while (teststr != null) {
if (!casesensitive) {
teststr = teststr.toLowerCase();
}
if (ignorewhitespace) {
teststr = SelectorUtils.removeWhitespace(teststr);
}
if (teststr.indexOf(userstr) > -1) {
return true;
}
teststr = in.readLine();
}
return false;
} catch (IOException ioe) {
throw new BuildException("Could not read " + r.toLongString());
} finally {
FileUtils.close(in);
}
|
public void | setCasesensitive(boolean casesensitive)Whether to ignore case in the string being searched.
this.casesensitive = casesensitive;
|
public void | setIgnorewhitespace(boolean ignorewhitespace)Whether to ignore whitespace in the string being searched.
this.ignorewhitespace = ignorewhitespace;
|
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 (CONTAINS_KEY.equalsIgnoreCase(paramname)) {
setText(parameters[i].getValue());
} else if (CASE_KEY.equalsIgnoreCase(paramname)) {
setCasesensitive(Project.toBoolean(
parameters[i].getValue()));
} else if (WHITESPACE_KEY.equalsIgnoreCase(paramname)) {
setIgnorewhitespace(Project.toBoolean(
parameters[i].getValue()));
} else {
setError("Invalid parameter " + paramname);
}
}
}
|
public void | setText(java.lang.String contains)The string to search for within a file.
this.contains = contains;
|
public java.lang.String | toString()
StringBuffer buf = new StringBuffer("{containsselector text: ");
buf.append('"").append(contains).append('"");
buf.append(" casesensitive: ");
buf.append(casesensitive ? "true" : "false");
buf.append(" ignorewhitespace: ");
buf.append(ignorewhitespace ? "true" : "false");
buf.append("}");
return buf.toString();
|
public void | verifySettings()Checks to make sure all settings are kosher. In this case, it
means that the pattern attribute has been set.
if (contains == null) {
setError("The text attribute is required");
}
|