Search in sources :

Example 1 with VariableNotBoundException

use of org.apache.jena.sparql.expr.VariableNotBoundException in project jena by apache.

the class BindingComparator method compare.

// Compare bindings by iterating.
// Node comparsion is:
//  Compare by 
@Override
public int compare(Binding bind1, Binding bind2) {
    for (SortCondition sc : conditions) {
        if (sc.expression == null) {
            throw new QueryExecException("Broken sort condition");
        }
        NodeValue nv1 = null;
        NodeValue nv2 = null;
        try {
            nv1 = sc.expression.eval(bind1, env);
        } catch (VariableNotBoundException ex) {
        } catch (ExprEvalException ex) {
            Log.warn(this, ex.getMessage());
        }
        try {
            nv2 = sc.expression.eval(bind2, env);
        } catch (VariableNotBoundException ex) {
        } catch (ExprEvalException ex) {
            Log.warn(this, ex.getMessage());
        }
        Node n1 = NodeValue.toNode(nv1);
        Node n2 = NodeValue.toNode(nv2);
        int x = compareNodes(nv1, nv2, sc.direction);
        if (x != Expr.CMP_EQUAL) {
            return x;
        }
    }
    // Same by the SortConditions - now do any extra tests to make sure they are unique.
    return compareBindingsSyntactic(bind1, bind2);
//return 0 ;
}
Also used : SortCondition(org.apache.jena.query.SortCondition) NodeValue(org.apache.jena.sparql.expr.NodeValue) VariableNotBoundException(org.apache.jena.sparql.expr.VariableNotBoundException) Node(org.apache.jena.graph.Node) QueryExecException(org.apache.jena.query.QueryExecException) ExprEvalException(org.apache.jena.sparql.expr.ExprEvalException)

Aggregations

Node (org.apache.jena.graph.Node)1 QueryExecException (org.apache.jena.query.QueryExecException)1 SortCondition (org.apache.jena.query.SortCondition)1 ExprEvalException (org.apache.jena.sparql.expr.ExprEvalException)1 NodeValue (org.apache.jena.sparql.expr.NodeValue)1 VariableNotBoundException (org.apache.jena.sparql.expr.VariableNotBoundException)1