use of org.apache.jena.shex.sys.ReportItem in project jena by apache.
the class DatatypeConstraint method nodeSatisfies.
@Override
public ReportItem nodeSatisfies(ValidationContext vCxt, Node n) {
if (n.isLiteral() && dtURI.equals(n.getLiteralDatatypeURI())) {
// Must be valid for the type
if (!rdfDatatype.isValid(n.getLiteralLexicalForm())) {
String errMsg = toString() + " : Not valid value : Node " + displayStr(n);
return new ReportItem(errMsg, n);
}
return null;
}
if (!n.isLiteral())
return new ReportItem(toString() + " : Not a literal", n);
// String dtStr = vCxt.getShapesGraph().getPrefixMapping().qnameFor(dtURI);
Node dt = NodeFactory.createURI(n.getLiteralDatatypeURI());
String errMsg = toString() + " -- Wrong datatype: " + strDatatype(n) + " for focus node: " + displayStr(n);
return new ReportItem(errMsg, n);
}
use of org.apache.jena.shex.sys.ReportItem in project jena by apache.
the class NumRangeConstraint method nodeSatisfies.
@Override
public ReportItem nodeSatisfies(ValidationContext vCxt, Node n) {
if (!n.isLiteral())
return new ReportItem("NumRange: Not a literal number", n);
NodeValue nv = NodeValue.makeNode(n);
int r = NodeValue.compare(nv, numericValue);
switch(rangeKind) {
case MAXEXCLUSIVE:
if (r < 0)
return null;
break;
case MAXINCLUSIVE:
if (r <= 0)
return null;
break;
case MINEXCLUSIVE:
if (r > 0)
return null;
break;
case MININCLUSIVE:
if (r >= 0)
return null;
break;
default:
break;
}
String msg = format("Expected %s %s : got = %s", rangeKind.label(), NodeFmtLib.strTTL(nv.getNode()), NodeFmtLib.strTTL(n));
return new ReportItem(msg, n);
}
use of org.apache.jena.shex.sys.ReportItem in project jena by apache.
the class ShapeExprOR method satisfies.
@Override
public boolean satisfies(ValidationContext vCxt, Node data) {
// We need to ignore validation failures from expressions - we need to find one success.
for (ShapeExpression shExpr : shapeExpressions) {
ValidationContext vCxt2 = ValidationContext.create(vCxt);
boolean innerSatisfies = shExpr.satisfies(vCxt2, data);
if (innerSatisfies)
return true;
}
ReportItem item = new ReportItem("OR expression not satisfied:", data);
vCxt.reportEntry(item);
return false;
}
Aggregations