return (foundSomething) ? osm : null;
}
private static OSQuery parseQuery(Element e){
OSQuery query = new OSQuery();
String att = e.getAttributeValue("role");
query.setRole(att);
att = e.getAttributeValue("osd");
query.setOsd(att);
att = e.getAttributeValue("searchTerms");
query.setSearchTerms(att);
att = e.getAttributeValue("title");
query.setTitle(att);
try{
// someones mistake should not cause the parser to fail, since these are only optional attributes
att = e.getAttributeValue("totalResults");
if(att != null){
query.setTotalResults(Integer.parseInt(att));
}
att = e.getAttributeValue("startPage");
if(att != null){
query.setStartPage(Integer.parseInt(att));
}
} catch(NumberFormatException ex){
System.err.println("Warning: Exception caught while trying to parse a non-numeric Query attribute " + ex.getMessage());
}