@Override public Datatype<?> getDatatype(final ATermAppl uri) { try { Datatype<?> dt = _coreDatatypes.get(uri); if (dt == null) { final ATermAppl definition = namedDataRanges.get(uri); if (definition != null) if (ATermUtils.isRestrictedDatatype(definition)) { final RestrictedDatatype<?> dataRange = (RestrictedDatatype<?>) getDataRange(definition); final NamedDatatype<?> namedDatatype = new NamedDatatype<>(uri, dataRange); dt = namedDatatype; } } return dt; } catch (final Exception e) { throw new OpenError(e); } }
@Override public ATermAppl getCanonicalRepresentation(final ATermAppl literal) throws InvalidLiteralException, UnrecognizedDatatypeException { final ATermAppl dtName = getDatatypeName(literal); final Datatype<?> dt = getDatatype(dtName); if (dt == null) switch (OpenlletOptions.UNDEFINED_DATATYPE_HANDLING) { case INFINITE_STRING: return literal; case EMPTY: throw new InvalidLiteralException(dtName, ATermUtils.getLiteralValue(literal)); case EXCEPTION: throw new UnrecognizedDatatypeException(dtName); default: throw new IllegalStateException(); } else return dt.getCanonicalRepresentation(literal); }
@Override public boolean declare(final ATermAppl name) { if (isDeclared(name)) return false; else { declaredUndefined.add(name); return true; } }
if (containedIn(constValues[i], a)) for (final ATermAppl a : dnfTypes[i]) final DataRange<?> dr = normalizeVarRanges(a); if (dr == TRIVIALLY_SATISFIABLE) return false; else normalized[i] = getDisjunction(drs); removeInequalities(ne, i); continue; if (dr.containsAtLeast(inequalityCount(ne, i) + 1)) removeInequalities(ne, i); continue;
Datatype<?> dt = getDatatype(a); if (dt == null) switch (OpenlletOptions.UNDEFINED_DATATYPE_HANDLING) final DataRange<?> dt = getDataRange(dtTerm); if (!(dt instanceof RestrictedDatatype<?>)) throw new InvalidConstrainingFacetException(dtTerm, dt); try value = getValue(valueTerm); final DataRange<?> ndr = getDataRange(n); final DataRange<?> dr = new NegatedDataRange<Object>(ndr); final DataRange<?> dr = new DataValueEnumeration<>(Collections.singleton(getValue(literal))); return dr;
for (ATermList l = (ATermList) dconjunction.getArgument(0); !l.isEmpty(); l = l.getNext()) final DataRange<?> dr = getDataRange((ATermAppl) l.getFirst()); if (dr.isEmpty()) return EMPTY_RANGE; final Set<RestrictedDatatype<?>> negativeRestrictions = new HashSet<>(); partitionDConjunction(ranges, positiveEnumerations, negativeEnumerations, positiveRestrictions, negativeRestrictions); final DataRange<?> enumeration = findSmallestEnumeration(positiveEnumerations); final Set<Object> remainingValues = new HashSet<>(); final Iterator<?> it = enumeration.valueIterator(); ret = getDataRange(dconjunction);
_assertedClashes = SetUtils.create(); _doExplanation = false; _dtReasoner = new DatatypeReasonerImpl(); _keepLastCompletion = false;
@Override public Iterator<?> valueIterator(final Collection<ATermAppl> dataranges) throws InvalidConstrainingFacetException, InvalidLiteralException, UnrecognizedDatatypeException { final ATermAppl and = ATermUtils.makeAnd(ATermUtils.makeList(dataranges)); final ATermAppl dnf = DNF.dnf(expander.expand(and, namedDataRanges)); if (ATermUtils.isOr(dnf)) { final List<DataRange<?>> disjuncts = new ArrayList<>(); for (ATermList l = (ATermList) dnf.getArgument(0); !l.isEmpty(); l = l.getNext()) disjuncts.add(normalizeVarRanges((ATermAppl) l.getFirst())); return getDisjunction(disjuncts).valueIterator(); } else return normalizeVarRanges(dnf).valueIterator(); }
public RDFLints validate(final RDFModel model) { _model = model; _OWLEntities = new OWLEntityDatabase(); _OWLEntities.addAnnotationRole(RDFS.label); _OWLEntities.addAnnotationRole(RDFS.comment); _OWLEntities.addAnnotationRole(RDFS.seeAlso); _OWLEntities.addAnnotationRole(RDFS.isDefinedBy); _OWLEntities.addAnnotationRole(OWL.versionInfo); _OWLEntities.addOntologyRole(OWL.backwardCompatibleWith); _OWLEntities.addOntologyRole(OWL.priorVersion); _OWLEntities.addOntologyRole(OWL.incompatibleWith); _OWLEntities.addClass(OWL.Thing); _OWLEntities.addClass(OWL.Nothing); // Fixes #194 _OWLEntities.addDatatype(RDFS.Literal); // Fixes #457 _OWLEntities.addDatatype(ResourceFactory.createResource("http://www.w3.org/1999/02/22-rdf-syntax-ns#PlainLiteral")); for (final ATermAppl uri : new DatatypeReasonerImpl().listDataRanges()) _OWLEntities.addDatatype(ResourceFactory.createResource(uri.getName())); _lists = CollectionUtil.makeMap(); _lists.put(RDF.nil, CollectionUtil.<RDFNode> makeList()); processTypes(); processTriples(); processRestrictions(); return reportLints(); }
@Override public boolean validLiteral(final ATermAppl typedLiteral) throws UnrecognizedDatatypeException { if (!ATermUtils.isLiteral(typedLiteral)) throw new IllegalArgumentException(); final ATermAppl dtTerm = (ATermAppl) typedLiteral.getArgument(ATermUtils.LIT_URI_INDEX); if (dtTerm == null) throw new IllegalArgumentException(); final Datatype<?> dt = getDatatype(dtTerm); if (dt == null) throw new UnrecognizedDatatypeException(dtTerm); try { dt.getValue(typedLiteral); } catch (final InvalidLiteralException e) { _logger.log(Level.FINE, "", e); return false; } return true; }
if (containedIn(constValues[i], a)) for (final ATermAppl a : dnfTypes[i]) final DataRange<?> dr = normalizeVarRanges(a); if (dr == TRIVIALLY_SATISFIABLE) return false; else normalized[i] = getDisjunction(drs); removeInequalities(ne, i); continue; if (dr.containsAtLeast(inequalityCount(ne, i) + 1)) removeInequalities(ne, i); continue;
Datatype<?> dt = getDatatype(a); if (dt == null) switch (OpenlletOptions.UNDEFINED_DATATYPE_HANDLING) final DataRange<?> dt = getDataRange(dtTerm); if (!(dt instanceof RestrictedDatatype<?>)) throw new InvalidConstrainingFacetException(dtTerm, dt); try value = getValue(valueTerm); final DataRange<?> ndr = getDataRange(n); final DataRange<?> dr = new NegatedDataRange<Object>(ndr); final DataRange<?> dr = new DataValueEnumeration<>(Collections.singleton(getValue(literal))); return dr;
for (ATermList l = (ATermList) dconjunction.getArgument(0); !l.isEmpty(); l = l.getNext()) final DataRange<?> dr = getDataRange((ATermAppl) l.getFirst()); if (dr.isEmpty()) return EMPTY_RANGE; final Set<RestrictedDatatype<?>> negativeRestrictions = new HashSet<>(); partitionDConjunction(ranges, positiveEnumerations, negativeEnumerations, positiveRestrictions, negativeRestrictions); final DataRange<?> enumeration = findSmallestEnumeration(positiveEnumerations); final Set<Object> remainingValues = new HashSet<>(); final Iterator<?> it = enumeration.valueIterator(); ret = getDataRange(dconjunction);
_assertedClashes = SetUtils.create(); _doExplanation = false; _dtReasoner = new DatatypeReasonerImpl(); _keepLastCompletion = false;
@Override public Iterator<?> valueIterator(final Collection<ATermAppl> dataranges) throws InvalidConstrainingFacetException, InvalidLiteralException, UnrecognizedDatatypeException { final ATermAppl and = ATermUtils.makeAnd(ATermUtils.makeList(dataranges)); final ATermAppl dnf = DNF.dnf(expander.expand(and, namedDataRanges)); if (ATermUtils.isOr(dnf)) { final List<DataRange<?>> disjuncts = new ArrayList<>(); for (ATermList l = (ATermList) dnf.getArgument(0); !l.isEmpty(); l = l.getNext()) disjuncts.add(normalizeVarRanges((ATermAppl) l.getFirst())); return getDisjunction(disjuncts).valueIterator(); } else return normalizeVarRanges(dnf).valueIterator(); }
@Override public boolean validLiteral(final ATermAppl typedLiteral) throws UnrecognizedDatatypeException { if (!ATermUtils.isLiteral(typedLiteral)) throw new IllegalArgumentException(); final ATermAppl dtTerm = (ATermAppl) typedLiteral.getArgument(ATermUtils.LIT_URI_INDEX); if (dtTerm == null) throw new IllegalArgumentException(); final Datatype<?> dt = getDatatype(dtTerm); if (dt == null) throw new UnrecognizedDatatypeException(dtTerm); try { dt.getValue(typedLiteral); } catch (final InvalidLiteralException e) { _logger.log(Level.FINE, "", e); return false; } return true; }
@Before public void reset() { reasoner = new DatatypeReasonerImpl(); abox = new ABoxImpl(null); }
@Override public boolean containsAtLeast(final int n, final Collection<ATermAppl> ranges) throws UnrecognizedDatatypeException, InvalidConstrainingFacetException, InvalidLiteralException { final ATermAppl and = ATermUtils.makeAnd(ATermUtils.makeList(ranges)); final ATermAppl dnf = DNF.dnf(expander.expand(and, namedDataRanges)); if (ATermUtils.isOr(dnf)) { final List<DataRange<?>> disjuncts = new ArrayList<>(); for (ATermList l = (ATermList) dnf.getArgument(0); !l.isEmpty(); l = l.getNext()) { final DataRange<?> dr = normalizeVarRanges((ATermAppl) l.getFirst()); if (!dr.isEmpty()) disjuncts.add(dr); } return getDisjunction(disjuncts).containsAtLeast(n); } else return normalizeVarRanges(dnf).containsAtLeast(n); }
@Override public ATermAppl getCanonicalRepresentation(final ATermAppl literal) throws InvalidLiteralException, UnrecognizedDatatypeException { final ATermAppl dtName = getDatatypeName(literal); final Datatype<?> dt = getDatatype(dtName); if (dt == null) switch (OpenlletOptions.UNDEFINED_DATATYPE_HANDLING) { case INFINITE_STRING: return literal; case EMPTY: throw new InvalidLiteralException(dtName, ATermUtils.getLiteralValue(literal)); case EXCEPTION: throw new UnrecognizedDatatypeException(dtName); default: throw new IllegalStateException(); } else return dt.getCanonicalRepresentation(literal); }
@Override public Datatype<?> getDatatype(final ATermAppl uri) { try { Datatype<?> dt = _coreDatatypes.get(uri); if (dt == null) { final ATermAppl definition = namedDataRanges.get(uri); if (definition != null) if (ATermUtils.isRestrictedDatatype(definition)) { final RestrictedDatatype<?> dataRange = (RestrictedDatatype<?>) getDataRange(definition); final NamedDatatype<?> namedDatatype = new NamedDatatype<>(uri, dataRange); dt = namedDatatype; } } return dt; } catch (final Exception e) { throw new OpenError(e); } }