use of org.apache.tools.ant.util.regexp.RegexpMatcherFactory in project ant by apache.
the class PropertySet method addPropertyNames.
/**
* @param names the output Set to fill with the property names
* matching this PropertySet selection criteria.
* @param props the current Project properties, passed in to
* avoid needless duplication of the Hashtable during recursion.
*/
private void addPropertyNames(Set<String> names, Map<String, Object> props) {
if (isReference()) {
getRef().addPropertyNames(names, props);
}
dieOnCircularReference();
// Add this PropertySet's property names.
for (PropertyRef r : ptyRefs) {
if (r.name != null) {
if (props.get(r.name) != null) {
names.add(r.name);
}
} else if (r.prefix != null) {
for (String name : props.keySet()) {
if (name.startsWith(r.prefix)) {
names.add(name);
}
}
} else if (r.regex != null) {
RegexpMatcherFactory matchMaker = new RegexpMatcherFactory();
RegexpMatcher matcher = matchMaker.newRegexpMatcher();
matcher.setPattern(r.regex);
for (String name : props.keySet()) {
if (matcher.matches(name)) {
names.add(name);
}
}
} else if (r.builtin != null) {
if (r.builtin.equals(BuiltinPropertySetName.ALL)) {
names.addAll(props.keySet());
} else if (r.builtin.equals(BuiltinPropertySetName.SYSTEM)) {
names.addAll(getAllSystemProperties().keySet());
} else if (r.builtin.equals(BuiltinPropertySetName.COMMANDLINE)) {
names.addAll(getProject().getUserProperties().keySet());
} else {
throw new BuildException("Impossible: Invalid builtin " + "attribute!");
}
} else {
throw new BuildException("Impossible: Invalid PropertyRef!");
}
}
}
Aggregations