@Override public boolean isValidLiteral(LiteralLabel lit) { return decoratee.isValidLiteral(lit); }
@Override public boolean isValidLiteral(LiteralLabel lit) { return delegate.isValidLiteral(lit); }
@Override public boolean isValidLiteral(LiteralLabel lit) { return delegate.isValidLiteral(lit); }
/** * Check a given literal value for a property against the set of * known range constraints for it. * @param prop the property node whose range is under scrutiny * @param triple the statement whose object value is to be checked. * @return null if the range is legal, otherwise a ValidityReport.Report * which describes the problem. */ public ValidityReport.Report checkLiteral(Node prop, Triple triple) { Node value = triple.getObject(); List<RDFDatatype> range = getDTRange().get(prop); if (range != null) { if (value.isBlank()) return null; if (!value.isLiteral()) { return new ValidityReport.Report(true, "dtRange", "Property " + prop + " has a typed range but was given a non literal value " + value); } LiteralLabel ll = value.getLiteral(); for ( RDFDatatype dt : range ) { if ( !dt.isValidLiteral( ll ) ) { return new ValidityReport.Report( true, "dtRange", "Property " + prop + " has a typed range " + dt + "that is not compatible with " + value, triple ); } } } return null; }
/** * Check a given literal value for a property against the set of * known range constraints for it. * @param prop the property node whose range is under scrutiny * @param triple the statement whose object value is to be checked. * @return null if the range is legal, otherwise a ValidityReport.Report * which describes the problem. */ public ValidityReport.Report checkLiteral(Node prop, Triple triple) { Node value = triple.getObject(); List<RDFDatatype> range = getDTRange().get(prop); if (range != null) { if (value.isBlank()) return null; if (!value.isLiteral()) { return new ValidityReport.Report(true, "dtRange", "Property " + prop + " has a typed range but was given a non literal value " + value); } LiteralLabel ll = value.getLiteral(); for ( RDFDatatype dt : range ) { if ( !dt.isValidLiteral( ll ) ) { return new ValidityReport.Report( true, "dtRange", "Property " + prop + " has a typed range " + dt + "that is not compatible with " + value, triple ); } } } return null; }
/** * Check if a literal value node is a legal value for the given datatype. * @param val the literal value node * @param dt the Node designating a datatype URI */ public static boolean isTypeOK(Node val, Node dt) { if (!dt.isURI()) return false; if (val.isBlank()) return true; if (val.isLiteral()) { LiteralLabel ll = val.getLiteral(); if (ll.getDatatype() != null && (! ll.isWellFormed())) return false; if (dt.equals(RDFS.Nodes.Literal)) { return true; } else { RDFDatatype dtype = TypeMapper.getInstance().getSafeTypeByName(dt.getURI()); return dtype.isValidLiteral(val.getLiteral()); } } return false; }
/** * Check if a literal value node is a legal value for the given datatype. * @param val the literal value node * @param dt the Node designating a datatype URI */ public static boolean isTypeOK(Node val, Node dt) { if (!dt.isURI()) return false; if (val.isBlank()) return true; if (val.isLiteral()) { LiteralLabel ll = val.getLiteral(); if (ll.getDatatype() != null && (! ll.isWellFormed())) return false; if (dt.equals(RDFS.Nodes.Literal)) { return true; } else { RDFDatatype dtype = TypeMapper.getInstance().getSafeTypeByName(dt.getURI()); return dtype.isValidLiteral(val.getLiteral()); } } return false; }