public Module parse(Element dcRoot) {
URL baseURI = findBaseURI(dcRoot);
boolean foundSomething = false;
OpenSearchModule osm = new OpenSearchModuleImpl();
Element e = dcRoot.getChild("totalResults", OS_NS);
if (e != null) {
foundSomething = true;
try{
osm.setTotalResults(Integer.parseInt(e.getText()));
} catch(NumberFormatException ex){
// Ignore setting the field and post a warning
System.err.println("Warning: The element totalResults must be an integer value: " + ex.getMessage());
}
}
e = dcRoot.getChild("itemsPerPage", OS_NS);
try{
osm.setItemsPerPage(Integer.parseInt(e.getText()));
} catch(NumberFormatException ex){
// Ignore setting the field and post a warning
System.err.println("Warning: The element itemsPerPage must be an integer value: " + ex.getMessage());
}
e = dcRoot.getChild("startIndex", OS_NS);
try{
osm.setStartIndex(Integer.parseInt(e.getText()));
} catch(NumberFormatException ex){
// Ignore setting the field and post a warning
System.err.println("Warning: The element startIndex must be an integer value: " + ex.getMessage());
}
List queries = dcRoot.getChildren("Query", OS_NS);
if(queries != null && queries.size() > 0){
// Create the OSQuery list
List osqList = new LinkedList();
for (Iterator iter = queries.iterator(); iter.hasNext();) {
e = (Element) iter.next();
osqList.add(parseQuery(e));
}
osm.setQueries(osqList);
}
e = dcRoot.getChild("link", OS_NS);
if(e != null){
osm.setLink(parseLink(e, baseURI));
}
return (foundSomething) ? osm : null;
}