this.applicationContext = applicationContext;
}
public Object parse(String value) throws Exception {
List parsers = GeoServerExtensions.extensions(KvpParser.class, applicationContext);
Map formatOptions = new CaseInsensitiveMap(new HashMap());
//TODO: refactor some of this routine out into utility class since
// much of the logic is duplicated from the dispatcher
StringTokenizer st = new StringTokenizer(value, ";");
while (st.hasMoreTokens()) {
String kvp = (String) st.nextToken();
String[] kv = kvp.split(":");
String key = null;
String raw = null;
if (kv.length == 1) {
//assume its a on/off (boolean) kvp
key = kv[0];
raw = "true";
} else {
key = kv[0];
raw = kv[1];
}
Object parsed = null;
for (Iterator p = parsers.iterator(); p.hasNext();) {
KvpParser parser = (KvpParser) p.next();
if ( key.equalsIgnoreCase( parser.getKey() ) ) {
parsed = parser.parse( raw );
if ( parsed != null ) {
break;
}
}
}
if (parsed == null) {
if(LOGGER.isLoggable(Level.FINER))
LOGGER.finer( "Could not find kvp parser for: '" + key + "'. Storing as raw string.");
parsed = raw;
}
formatOptions.put(key, parsed);
}
return formatOptions;
}