public void visit(SWRLDataRangeAtom at) { OWLDataRange dr=at.getPredicate(); SWRLDArgument argument=at.getArgument(); if (!(argument instanceof SWRLVariable)) throw new IllegalArgumentException("A SWRL rule contains a data range with an argument that is not a literal, and such rules are not supported."); if (!m_isPositive) dr=m_factory.getOWLDataComplementOf(dr); dr=m_expressionManager.getNNF(m_expressionManager.getSimplified(dr)); if (dr instanceof OWLDataIntersectionOf || dr instanceof OWLDataUnionOf) { OWLDatatype definition=getDefinitionFor(dr,m_alreadyExists); if (!m_alreadyExists[0]) m_dataRangeInclusions.add(new OWLDataRange[] { negative(definition),dr }); dr=definition; } SWRLAtom atom=m_factory.getSWRLDataRangeAtom(dr,argument); m_normalizedHeadAtoms.add(atom); m_headDataRangeVariables.add((SWRLVariable)argument); }
public void visit(SWRLDataPropertyAtom at) { OWLDataProperty dp=at.getPredicate().asOWLDataProperty(); SWRLVariable variable1=getVariableFor(at.getFirstArgument()); SWRLDArgument argument2=at.getSecondArgument(); if (argument2 instanceof SWRLVariable) { SWRLVariable variable2=getVariableFor((SWRLVariable)argument2); if (m_isPositive) { m_normalizedHeadAtoms.add(m_factory.getSWRLDataPropertyAtom(dp,variable1,variable2)); m_headDataRangeVariables.add(variable2); } else { if (m_bodyDataRangeVariables.add(variable2)) m_normalizedBodyAtoms.add(m_factory.getSWRLDataPropertyAtom(dp,variable1,variable2)); else { SWRLVariable variable2Fresh=getFreshVariable(); m_normalizedBodyAtoms.add(m_factory.getSWRLDataPropertyAtom(dp,variable1,variable2Fresh)); m_normalizedHeadAtoms.add(m_factory.getSWRLDifferentIndividualsAtom(variable2,variable2Fresh)); } } } else { OWLLiteral literal=((SWRLLiteralArgument)argument2).getLiteral(); SWRLAtom newAtom=m_factory.getSWRLClassAtom(m_factory.getOWLDataHasValue(dp,literal),variable1); if (m_isPositive) m_headAtoms.add(newAtom); else m_bodyAtoms.add(newAtom); } }
@Override protected SWRLDataPropertyAtom readObject(BinaryOWLInputStream inputStream) throws IOException, BinaryOWLParseException { OWLDataPropertyExpression predicate = inputStream.readOWLObject(); SWRLIArgument firstArg = inputStream.readOWLObject(); SWRLDArgument secondArg = inputStream.readOWLObject(); return inputStream.getDataFactory().getSWRLDataPropertyAtom(predicate, firstArg, secondArg); }
protected static Variable toVariable(SWRLDArgument argument) { if (argument instanceof SWRLVariable) return Variable.create(((SWRLVariable)argument).getIRI().toString()); else throw new IllegalStateException("Internal error: all arguments in a SWRL rule should have been normalized to variables."); }
@Override protected SWRLBuiltInAtom readObject(BinaryOWLInputStream inputStream) throws IOException, BinaryOWLParseException { IRI predicate = inputStream.readIRI(); List<SWRLDArgument> arguments = inputStream.readOWLObjectList(); return inputStream.getDataFactory().getSWRLBuiltInAtom(predicate, arguments); }
@Override protected SWRLDataRangeAtom readObject(BinaryOWLInputStream inputStream) throws IOException, BinaryOWLParseException { OWLDataRange predicate = inputStream.readOWLObject(); SWRLDArgument argument = inputStream.readOWLObject(); return inputStream.getDataFactory().getSWRLDataRangeAtom(predicate, argument); }
/** * @param predicate * predicate * @param arg * range argument */ public SWRLDataRangeAtomImpl(@Nonnull OWLDataRange predicate, @Nonnull SWRLDArgument arg) { super(predicate, arg); }
/** * @param predicate * predicate * @param arg0 * subject * @param arg1 * object */ public SWRLDataPropertyAtomImpl( @Nonnull OWLDataPropertyExpression predicate, @Nonnull SWRLIArgument arg0, @Nonnull SWRLDArgument arg1) { super(predicate, arg0, arg1); }