// iterate over the whereSet
// when you find a elemName, grab the next query element
// ensure it's a literal, if so, there's your term query
// that's all we'll support for now
Query query = new Query();
if (xmlQuery.getWhereElementSet() != null
&& xmlQuery.getWhereElementSet().size() > 0) {
for (Iterator i = xmlQuery.getWhereElementSet().iterator(); i
.hasNext();) {
QueryElement elem = (QueryElement) i.next();
if (elem.getRole().equals("elemName")) {
String elemName = elem.getValue();
// to get the elem value, we need to grab the next elem
// ensure it's a literal, and then grab it
QueryElement litElem = (QueryElement) i.next();
if (!litElem.getRole().equals("LITERAL")) {
LOG.log(Level.WARNING,
"next element not literal: element: ["
+ litElem + "]: malformed xml query!");
break;
}
String elemValue = litElem.getValue();
TermQueryCriteria crit = new TermQueryCriteria();
crit.setElementName(elemName);
crit.setValue(elemValue);
query.addCriterion(crit);
}
}
}
return query;