@Override public synchronized void setShortFormProvider(ShortFormProvider shortFormProvider) { ren = new ManchesterOWLSyntaxObjectRenderer(writerDelegate, shortFormProvider); }
protected void write(Stream<? extends OWLObject> objects, ManchesterOWLSyntax delimeter, boolean newline) { int tab = getIndent(); pushTab(tab); Iterator<? extends OWLObject> it = objects.iterator(); while (it.hasNext()) { it.next().accept(this); if (it.hasNext()) { if (newline && isUseWrapping()) { writeNewLine(); } write(delimeter); } } popTab(); }
@Override public void visit(OWLClass ce) { write(getShortFormProvider().getShortForm(ce)); }
private void setAxiomWriting() { wrapSave = isUseWrapping(); tabSave = isUseTabbing(); setUseWrapping(false); setUseTabbing(false); }
@Override public void visit(OWLEquivalentDataPropertiesAxiom axiom) { setAxiomWriting(); writeFrameKeyword(EQUIVALENT_PROPERTIES); writeCommaSeparatedList(axiom.properties()); restore(); }
@Override public void visit(OWLDisjointClassesAxiom axiom) { setAxiomWriting(); writeBinaryOrNaryList(DISJOINT_WITH, axiom.classExpressions(), DISJOINT_CLASSES); restore(); }
@Override public void visit(OWLIrreflexiveObjectPropertyAxiom axiom) { setAxiomWriting(); writeSectionKeyword(IRREFLEXIVE); axiom.getProperty().accept(this); restore(); }
@Override public void visit(OWLDataPropertyDomainAxiom axiom) { setAxiomWriting(); axiom.getProperty().accept(this); write(DOMAIN); axiom.getDomain().accept(this); restore(); }
@Override public void visit(OWLLiteral node) { // xsd:decimal is the default datatype for literal forms like "33.3" // with no specified datatype if (XSDVocabulary.DECIMAL.getIRI().equals(node.getDatatype().getIRI())) { write(node.getLiteral()); } else if (node.getDatatype().isFloat()) { write(node.getLiteral()); write("f"); } else if (node.getDatatype().isInteger()) { write(node.getLiteral()); } else if (node.getDatatype().isBoolean()) { write(node.getLiteral()); } else { pushTab(getIndent()); writeLiteral(node.getLiteral()); if (node.hasLang()) { write("@"); write(node.getLang()); } else if (!node.isRDFPlainLiteral() && !OWL2Datatype.XSD_STRING.matches(node.getDatatype())) { write("^^"); node.getDatatype().accept(this); } popTab(); } }
private void writeRestriction(OWLQuantifiedObjectRestriction restriction, ManchesterOWLSyntax keyword) { restriction.getProperty().accept(this); write(keyword); boolean conjunctionOrDisjunction = false; if (restriction.getFiller() instanceof OWLAnonymousClassExpression) { if (restriction.getFiller() instanceof OWLObjectIntersectionOf || restriction.getFiller() instanceof OWLObjectUnionOf) { conjunctionOrDisjunction = true; incrementTab(4); writeNewLine(); } write("("); } restriction.getFiller().accept(this); if (restriction.getFiller() instanceof OWLAnonymousClassExpression) { write(")"); if (conjunctionOrDisjunction) { popTab(); } } }
@Override public void visit(OWLObjectIntersectionOf ce) { boolean first = true; Iterator<? extends OWLObject> it = ce.operands().iterator(); while (it.hasNext()) { OWLObject desc = it.next(); if (!first) { if (isUseWrapping()) { writeNewLine(); } write(" ", AND, " "); } first = false; if (desc instanceof OWLAnonymousClassExpression) { write("("); } desc.accept(this); if (desc instanceof OWLAnonymousClassExpression) { write(")"); } } }
@Override public void visit(OWLDisjointUnionAxiom axiom) { setAxiomWriting(); axiom.getOWLClass().accept(this); write(DISJOINT_UNION_OF); writeCommaSeparatedList(axiom.classExpressions()); restore(); }
@Override public void visit(OWLDeclarationAxiom axiom) { setAxiomWriting(); writeFrameType(axiom.getEntity()); restore(); }
@Override public void visit(OWLHasKeyAxiom axiom) { setAxiomWriting(); axiom.getClassExpression().accept(this); write(HAS_KEY); write(axiom.objectPropertyExpressions(), COMMA, false); write(axiom.dataPropertyExpressions(), COMMA, false); }
@Override public void visit(OWLReflexiveObjectPropertyAxiom axiom) { setAxiomWriting(); writeSectionKeyword(REFLEXIVE); axiom.getProperty().accept(this); restore(); }
@Override public void visit(OWLObjectPropertyDomainAxiom axiom) { setAxiomWriting(); axiom.getProperty().accept(this); write(DOMAIN); axiom.getDomain().accept(this); restore(); }
@Override public void visit(OWLLiteral node) { // xsd:decimal is the default datatype for literal forms like "33.3" // with no specified datatype if (XSDVocabulary.DECIMAL.getIRI().equals(node.getDatatype().getIRI())) { write(node.getLiteral()); } else if (node.getDatatype().isFloat()) { write(node.getLiteral()); write("f"); } else if (node.getDatatype().isInteger()) { write(node.getLiteral()); } else if (node.getDatatype().isBoolean()) { write(node.getLiteral()); } else { pushTab(getIndent()); writeLiteral(node.getLiteral()); if (node.hasLang()) { write("@"); write(node.getLang()); } else if (!node.isRDFPlainLiteral() && !OWL2Datatype.XSD_STRING.matches(node.getDatatype())) { write("^^"); node.getDatatype().accept(this); } popTab(); } }
@Override public void visit(OWLEquivalentObjectPropertiesAxiom axiom) { setAxiomWriting(); writeBinaryOrNaryList(EQUIVALENT_TO, axiom.properties(), EQUIVALENT_PROPERTIES); restore(); }
private void setAxiomWriting() { wrapSave = isUseWrapping(); tabSave = isUseTabbing(); setUseWrapping(false); setUseTabbing(false); }
private void writeRestriction(OWLQuantifiedObjectRestriction restriction, ManchesterOWLSyntax keyword) { restriction.getProperty().accept(this); write(keyword); boolean conjunctionOrDisjunction = false; if (restriction.getFiller() instanceof OWLAnonymousClassExpression) { if (restriction.getFiller() instanceof OWLObjectIntersectionOf || restriction.getFiller() instanceof OWLObjectUnionOf) { conjunctionOrDisjunction = true; incrementTab(4); writeNewLine(); } write("("); } restriction.getFiller().accept(this); if (restriction.getFiller() instanceof OWLAnonymousClassExpression) { write(")"); if (conjunctionOrDisjunction) { popTab(); } } }