Search in sources :

Example 1 with CQLProxNode

use of org.z3950.zing.cql.CQLProxNode 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;
}
Also used : CQLAndNode(org.z3950.zing.cql.CQLAndNode) CQLNotNode(org.z3950.zing.cql.CQLNotNode) CQLProxNode(org.z3950.zing.cql.CQLProxNode) Modifier(org.z3950.zing.cql.Modifier) CQLNode(org.z3950.zing.cql.CQLNode) ModifierSet(org.z3950.zing.cql.ModifierSet) CQLOrNode(org.z3950.zing.cql.CQLOrNode)

Aggregations

CQLAndNode (org.z3950.zing.cql.CQLAndNode)1 CQLNode (org.z3950.zing.cql.CQLNode)1 CQLNotNode (org.z3950.zing.cql.CQLNotNode)1 CQLOrNode (org.z3950.zing.cql.CQLOrNode)1 CQLProxNode (org.z3950.zing.cql.CQLProxNode)1 Modifier (org.z3950.zing.cql.Modifier)1 ModifierSet (org.z3950.zing.cql.ModifierSet)1