* @param props The properties to search.
* @return the enumeration of all of the property names of the primary source;
* the enumeration may be empty if there is an error connecting to the property sources.
*/
public static Properties getProperties(String filterPattern, Properties props) {
Properties results = new Properties();
boolean addAll = false;
String searchStr = null;
int globIndex = filterPattern.indexOf('*');
if ( globIndex == -1 ) {
searchStr = filterPattern;
} else if ( globIndex == 0 ) {
addAll = true;
} else {
searchStr = filterPattern.substring(0, globIndex);
}
Enumeration propNameEnum = props.propertyNames();
while ( propNameEnum.hasMoreElements() ) {
String name = (String) propNameEnum.nextElement();
if ( name.startsWith(searchStr)) {
Object value = props.get(name);
if (value != null) {
results.put(name.substring(searchStr.length()), value);
}
}
else if (addAll) {
results.put(name, props.get(name));
}
}
return results;
}