Search in sources :

Example 1 with ExprNotComparableException

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

the class ValueRangeConstraint method validate.

@Override
public final ReportItem validate(ValidationContext vCxt, Node n) {
    NodeValue nv = NodeValue.makeNode(n);
    ValueSpaceClassification vs = NodeValue.classifyValueOp(nodeValue, nv);
    try {
        int r = NodeValue.compare(nodeValue, nv);
        if (r == Expr.CMP_INDETERMINATE)
            return new ReportItem(toString() + " indeterminant to " + n, n);
        boolean b = test(r);
        if (b)
            return null;
        return new ReportItem(getErrorMessage(n), n);
    } catch (ExprNotComparableException ex) {
        return new ReportItem(toString() + " can't compare to " + n, n);
    }
}
Also used : NodeValue(org.apache.jena.sparql.expr.NodeValue) ExprNotComparableException(org.apache.jena.sparql.expr.ExprNotComparableException) ReportItem(org.apache.jena.shacl.validation.ReportItem) ValueSpaceClassification(org.apache.jena.sparql.expr.ValueSpaceClassification)

Example 2 with ExprNotComparableException

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

the class ConstraintPairwise method compare.

protected int compare(Node n1, Node n2) {
    NodeValue nv1 = NodeValue.makeNode(n1);
    NodeValue nv2 = NodeValue.makeNode(n2);
    try {
        return NodeValue.compare(nv1, nv2);
    } catch (ExprNotComparableException ex) {
        // Known to be not a Expr compare constant value.
        return -999;
    }
}
Also used : NodeValue(org.apache.jena.sparql.expr.NodeValue) ExprNotComparableException(org.apache.jena.sparql.expr.ExprNotComparableException)

Aggregations

ExprNotComparableException (org.apache.jena.sparql.expr.ExprNotComparableException)2 NodeValue (org.apache.jena.sparql.expr.NodeValue)2 ReportItem (org.apache.jena.shacl.validation.ReportItem)1 ValueSpaceClassification (org.apache.jena.sparql.expr.ValueSpaceClassification)1