public Object[] getAttributeValues(String name,
Configuration modeConf,
Map objectModel) throws ConfigurationException {
Request request = ObjectModelHelper.getRequest(objectModel);
String wildcard = (String) this.settings.get("parameter", name);
if ( modeConf != null ) {
wildcard = modeConf.getAttribute( "parameter", wildcard );
// preferred
wildcard = modeConf.getChild("parameter").getValue(wildcard);
}
int wildcardIndex = wildcard.indexOf( "*" );
if ( wildcardIndex != -1 ) {
// "*" contained in parameter name = > combine all
// parameters' values that match prefix, suffix
// split the parameter's name so that the "*" could be
// determined by looking at the parameters' names that
// start with the prefix and end with the suffix
//
String prefix = wildcard.substring( 0, wildcardIndex );
String suffix;
if ( wildcard.length() >= wildcardIndex + 1 ) {
suffix = wildcard.substring( wildcardIndex + 1 );
} else {
suffix = "";
}
SortedSet names = new TreeSet();
Enumeration allNames = request.getParameterNames();
while (allNames.hasMoreElements()) {
String pname = (String) allNames.nextElement();
if ( pname.startsWith( prefix ) && pname.endsWith( suffix ) ) {
names.add(pname);
}
}
List values = new LinkedList();
Iterator j = names.iterator();
while (j.hasNext()){
String pname = (String) j.next();
values.add( request.getParameter( pname ) );
}
return values.toArray();
} else {
// no "*" in parameter name = > just return all values of
// this one parameter.
return request.getParameterValues( wildcard );
}
}
|