in command-line-debugger/src/main/java/org/apache/tools/ant/Locator.java [18:66]
public void execute(Project project, String[] params) {
// the command syntax is 'locate property some.property'
// or 'locate path some.path
if (params.length > 1 && "/?".equals(params[1])) {
printUsage(project);
return;
}
if (params.length != 3) {
project.log("Incorrect Parameters");
printUsage(project);
return;
}
List matches = null;
String key = null;
if ("property".equalsIgnoreCase(params[1])) {
// locate and publish the property
matches = DebugUtils.searchTask(Property.class, project);
key = "name";
} else {
// see if any other component may be supported
project.log("Unexpected component: " + params[1]);
project.log("Supported components are property, path.");
return;
}
boolean found = false;
// probably accept some kind of a query from end user and select the
// target object based on the query
for (Iterator iterator = matches.iterator(); iterator.hasNext();) {
Task task = (Task) iterator.next();
// display attributes
Map attributeMap = task.getWrapper().getAttributeMap();
if (!params[2].equals(attributeMap.get(key))) {
continue;
}
found = true;
String value = (String) attributeMap.get("value");
project.log("Detected a property by name [" + params[2]
+ "]. Build file value: " + value);
// and their respected location
project.log("Located at: " + task.getLocation().toString());
}
if (!found) {
project.log("No property by name [" + params[2] + "] found.");
}
}