//strip out parsers which do not match current service/request/version
String service = (String) kvp.get( "service" );
String version = (String) kvp.get( "version" );
String request = (String) kvp.get( "request" );
for (Iterator p = parsers.iterator(); p.hasNext(); ) {
KvpParser parser = (KvpParser) p.next();
if ( parser.getService() != null && !parser.getService().equalsIgnoreCase(service) ) {
p.remove();
continue;
}
if ( parser.getVersion() != null && !parser.getVersion().toString().equals(version) ) {
p.remove();
continue;
}
if ( parser.getRequest() != null && !parser.getRequest().equalsIgnoreCase(request) ) {
p.remove();
}
}
//parser the kvp's
ArrayList<Throwable> errors = new ArrayList<Throwable>();
for (Iterator itr = kvp.entrySet().iterator(); itr.hasNext();) {
Map.Entry entry = (Map.Entry) itr.next();
String key = (String) entry.getKey();
String value = (String) entry.getValue();
//find the parser for this key value pair
Object parsed = null;
for (Iterator pitr = parsers.iterator(); pitr.hasNext() && parsed == null;) {
KvpParser parser = (KvpParser) pitr.next();
if (key.equalsIgnoreCase(parser.getKey())) {
try {
parsed = parser.parse(value);
} catch (Throwable t) {
//dont throw any exceptions yet, befor the service is
// known
errors.add( t );
}