Methods Summary |
---|
public org.apache.tools.ant.types.Mapper | createMapper()Defines the FileNameMapper to use (nested mapper element).
if (mapperElement != null) {
throw new BuildException("Cannot define more than one mapper");
}
mapperElement = new Mapper(getProject());
return mapperElement;
|
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.
// throw BuildException on error
validate();
// Determine file whose existence is to be checked
String[] destfiles = map.mapFileName(filename);
// If filename does not match the To attribute of the mapper
// then filter it out of the files we are considering
if (destfiles == null) {
return false;
}
// Sanity check
if (destfiles.length != 1 || destfiles[0] == null) {
throw new BuildException("Invalid destination file results for "
+ targetdir + " with filename " + filename);
}
String destname = destfiles[0];
File destfile = new File(targetdir, destname);
return destfile.exists() == destmustexist;
|
public void | setPresent(org.apache.tools.ant.types.selectors.PresentSelector$FilePresence fp)This sets whether to select a file if its dest file is present.
It could be a negate boolean, but by doing things
this way, we get some documentation on how the system works.
A user looking at the documentation should clearly understand
that the ONLY files whose presence is being tested are those
that already exist in the source directory, hence the lack of
a destonly option.
if (fp.getIndex() == 0) {
destmustexist = false;
}
|
public void | setTargetdir(java.io.File targetdir)The name of the file or directory which is checked for matching
files.
this.targetdir = targetdir;
|
public java.lang.String | toString()
StringBuffer buf = new StringBuffer("{presentselector targetdir: ");
if (targetdir == null) {
buf.append("NOT YET SET");
} else {
buf.append(targetdir.getName());
}
buf.append(" present: ");
if (destmustexist) {
buf.append("both");
} else {
buf.append("srconly");
}
if (map != null) {
buf.append(map.toString());
} else if (mapperElement != null) {
buf.append(mapperElement.toString());
}
buf.append("}");
return buf.toString();
|
public void | verifySettings()Checks to make sure all settings are kosher. In this case, it
means that the targetdir attribute has been set and we have a mapper.
if (targetdir == null) {
setError("The targetdir attribute is required.");
}
if (mapperElement == null) {
map = new IdentityMapper();
} else {
map = mapperElement.getImplementation();
}
if (map == null) {
setError("Could not set <mapper> element.");
}
|