use of org.z3950.zing.cql.CQLNode in project okapi by folio-org.
the class CQLUtil method reduceBoolean.
private static CQLNode reduceBoolean(CQLBooleanNode n1, CQLTermNode tn, Comparator<CQLTermNode> cmp) {
CQLNode n2 = null;
CQLNode left = reducer(n1.getLeftOperand(), tn, cmp);
CQLNode right = reducer(n1.getRightOperand(), tn, cmp);
ModifierSet mSet = new ModifierSet(n1.getOperator().toString().toLowerCase());
List<Modifier> mods = n1.getModifiers();
for (Modifier m : mods) {
mSet.addModifier(m.getType(), m.getComparison(), m.getValue());
}
if (left == null) {
n2 = right;
} else if (right == null) {
n2 = left;
}
switch(n1.getOperator()) {
case AND:
if (left != null && right != null) {
n2 = new CQLAndNode(left, right, mSet);
}
break;
case OR:
if (left != null && right != null) {
n2 = new CQLOrNode(left, right, mSet);
}
break;
case NOT:
if (left != null && right != null) {
n2 = new CQLNotNode(left, right, mSet);
}
break;
case PROX:
if (left != null && right != null) {
n2 = new CQLProxNode(left, right, mSet);
}
break;
}
return n2;
}
use of org.z3950.zing.cql.CQLNode in project raml-module-builder by folio-org.
the class PgUtil method getSortNode.
/**
* Return the sort node from the sortBy clause of the cql query, or null if no
* sortBy clause exists or cql is invalid.
* @param cql the CQL query to parse
* @return sort node, or null
*/
static CQLSortNode getSortNode(String cql) {
try {
CQLParser parser = new CQLParser();
CQLNode node = parser.parse(cql);
return getSortNode(node);
} catch (IOException | CQLParseException | NullPointerException e) {
return null;
}
}
Aggregations