conciseformatvisitor.java
来自「Semantic Web Ontology Editor」· Java 代码 · 共 769 行 · 第 1/2 页
JAVA
769 行
} } restriction.getIndividual().accept( this ); if (strike) { pw.print("</font></strike>"); } pw.print("})"); } public void visit( OWLDataSomeRestriction restriction ) throws OWLException { pw.print("(" + ConciseFormat.EXISTS); restriction.getDataProperty().accept( this ); pw.print(" "+ ConciseFormat.MEMBEROF + " "); // if property is struck out, strike out value as well boolean strike = false; OWLDataProperty prop = restriction.getDataProperty(); if (this.highlightMap.containsKey(prop.getURI())) { String highlight = this.highlightMap.get(prop.getURI()).toString(); if (highlight.indexOf("<strike>")>=0) { strike = true; pw.print(highlight); } } restriction.getDataType().accept( this ); if (strike) { pw.print("</font></strike>"); } pw.print(")"); } public void visit( OWLDataAllRestriction restriction ) throws OWLException { pw.print("(" + ConciseFormat.FORALL); restriction.getDataProperty().accept( this ); pw.print(" "+ ConciseFormat.MEMBEROF + " "); // if property is struck out, strike out value as well boolean strike = false; OWLDataProperty prop = restriction.getDataProperty(); if (this.highlightMap.containsKey(prop.getURI())) { String highlight = this.highlightMap.get(prop.getURI()).toString(); if (highlight.indexOf("<strike>")>=0) { strike = true; pw.print(highlight); } } restriction.getDataType().accept( this ); if (strike) { pw.print("</font></strike>"); } pw.print(")"); } public void visit( OWLObjectCardinalityRestriction restriction ) throws OWLException { pw.print("("); boolean strike = false; OWLObjectProperty prop = restriction.getObjectProperty(); if (this.highlightMap.containsKey(prop.getURI())) { String highlight = this.highlightMap.get(prop.getURI()).toString(); if (highlight.indexOf("<strike>")>=0) { strike = true; pw.print(highlight); } } if ( restriction.isExactly() ) { pw.print(ConciseFormat.EQU + " " + restriction.getAtLeast() + " "); } else if ( restriction.isAtMost() ) { pw.print(ConciseFormat.LESSEQU + " " + restriction.getAtMost() + " "); } else if ( restriction.isAtLeast() ) { pw.print(ConciseFormat.GREATEQU + " " + restriction.getAtLeast() + " "); } prop.accept( this ); if (strike) { pw.print("</font></strike>"); } pw.print(")"); } public void visit( OWLDataCardinalityRestriction restriction ) throws OWLException { pw.print("("); boolean strike = false; OWLDataProperty prop = restriction.getDataProperty(); if (this.highlightMap.containsKey(prop.getURI())) { String highlight = this.highlightMap.get(prop.getURI()).toString(); if (highlight.indexOf("<strike>")>=0) { strike = true; pw.print(highlight); } } if ( restriction.isExactly() ) { pw.print(ConciseFormat.EQU + " " + restriction.getAtLeast() + " "); } else if ( restriction.isAtMost() ) { pw.print(ConciseFormat.LESSEQU + " " + restriction.getAtMost() + " "); } else if ( restriction.isAtLeast() ) { pw.print(ConciseFormat.GREATEQU + " " + restriction.getAtLeast() + " "); } prop.accept( this ); if (strike) { pw.print("</font></strike>"); } pw.print(")"); } public void visit( OWLDataValueRestriction restriction ) throws OWLException { pw.print("(" + ConciseFormat.EXISTS); restriction.getDataProperty().accept( this ); /* Changed from hasValue */ pw.print(" "+ ConciseFormat.MEMBEROF + " {"); // if property is struck out, strike out value as well boolean strike = false; OWLDataProperty prop = restriction.getDataProperty(); if (this.highlightMap.containsKey(prop.getURI())) { String highlight = this.highlightMap.get(prop.getURI()).toString(); if (highlight.indexOf("<strike>")>=0) { strike = true; pw.print(highlight); } } restriction.getValue().accept( this ); if (strike) { pw.print("</font></strike>"); } pw.print("})"); } public void visit( OWLEquivalentClassesAxiom axiom ) throws OWLException { // sort axiom classes so that atomic appears on the LHS Set equClas = axiom.getEquivalentClasses(); Set atomic = new HashSet(); Set complex = new HashSet(); for ( Iterator it = equClas.iterator(); it.hasNext(); ) { OWLDescription desc = (OWLDescription) it.next(); if (desc instanceof OWLClass) atomic.add(desc); else complex.add(desc); } pw.print("("); for ( Iterator it = atomic.iterator(); it.hasNext(); ) { OWLDescription desc = (OWLDescription) it.next(); desc.accept( this ); if (it.hasNext() || complex.size()>0) { pw.print(" " + ConciseFormat.EQUIVALENT + " "); } } for ( Iterator it = complex.iterator(); it.hasNext(); ) { OWLDescription desc = (OWLDescription) it.next(); desc.accept( this ); if (it.hasNext()) { pw.print(" " + ConciseFormat.EQUIVALENT + " "); } } pw.print(")"); } public void visit( OWLDisjointClassesAxiom axiom ) throws OWLException { pw.print("("); for ( Iterator it = axiom.getDisjointClasses().iterator(); it.hasNext(); ) { OWLDescription desc = (OWLDescription) it.next(); desc.accept( this ); if (it.hasNext()) { pw.print(" " + ConciseFormat.SUBSET + " " + ConciseFormat.COMPLEMENT); } } pw.print(")"); } public void visit( OWLSubClassAxiom axiom ) throws OWLException { pw.print("("); axiom.getSubClass().accept( this ); pw.print(" " + ConciseFormat.SUBSET + " "); axiom.getSuperClass().accept( this ); pw.print(")"); } public void visit( OWLEquivalentPropertiesAxiom axiom ) throws OWLException { pw.print("("); for ( Iterator it = axiom.getProperties().iterator(); it.hasNext(); ) { OWLProperty prop = (OWLProperty) it.next(); prop.accept( this ); if (it.hasNext()) { pw.print(" = "); } } pw.print(")"); } public void visit( OWLSubPropertyAxiom axiom ) throws OWLException { pw.print("("); axiom.getSubProperty().accept( this ); pw.print(" " + ConciseFormat.SUBSET + " "); axiom.getSuperProperty().accept( this ); pw.print(")"); } public void visit( OWLDifferentIndividualsAxiom ax) throws OWLException { pw.print("("); for ( Iterator it = ax.getIndividuals().iterator(); it.hasNext(); ) { OWLIndividual desc = (OWLIndividual) it.next(); desc.accept( this ); if (it.hasNext()) { pw.print(" " + ConciseFormat.DISJOINT + " "); } } pw.print(")"); } public void visit( OWLSameIndividualsAxiom ax) throws OWLException { pw.print("SameIndividual("); for ( Iterator it = ax.getIndividuals().iterator(); it.hasNext(); ) { OWLIndividual desc = (OWLIndividual) it.next(); desc.accept( this ); if (it.hasNext()) { pw.print(" = "); } } pw.print(")"); } public void visit( OWLDataType ocdt ) throws OWLException { pw.print( "<a href=\"" + escape(ocdt.getURI()) + "\">" + escape(shortForms.shortForm( ocdt.getURI() )) + "</a>" ); //pw.print( shortForms.shortForm( ocdt.getURI() ) ); } public void visit( OWLDataEnumeration enumeration ) throws OWLException { pw.print("{"); for ( Iterator it = enumeration.getValues().iterator(); it.hasNext(); ) { OWLDataValue desc = (OWLDataValue) it.next(); desc.accept( this ); if (it.hasNext()) { pw.print(", "); } } pw.print("}"); } // Uncomment for explanation public void visit( OWLFunctionalPropertyAxiom axiom ) throws OWLException { pw.print("Functional Property ("); axiom.getProperty().accept( this ); pw.print(")"); } public void visit( OWLPropertyDomainAxiom axiom ) throws OWLException { pw.print("("); axiom.getProperty().accept( this ); pw.print(" domain "); axiom.getDomain().accept( this ); pw.print(")"); } public void visit( OWLObjectPropertyRangeAxiom axiom ) throws OWLException { pw.print("("); axiom.getProperty().accept( this ); pw.print(" range "); axiom.getRange().accept( this ); pw.print(")"); } public void visit( OWLDataPropertyRangeAxiom axiom ) throws OWLException { pw.print("("); axiom.getProperty().accept( this ); pw.print(" range "); axiom.getRange().accept( this ); pw.print(")"); } /* (non-Javadoc) * @see org.mindswap.pellet.owlapi.OWLExtendedObjectVisitor#visit(org.mindswap.pellet.owlapi.OWLInverseFunctionalPropertyAxiom) *FIXME: Fix this! */ public void visit(OWLInverseFunctionalPropertyAxiom axiom) throws OWLException { if (axiom.getProperty().isInverseFunctional(axiom.getProperty().getOntologies())) { pw.print("InverseFunctional("); axiom.getProperty().accept( this ); pw.print(")"); } if (axiom instanceof OWLInversePropertyAxiomImpl) { OWLInversePropertyAxiomImpl invAxiom = (OWLInversePropertyAxiomImpl) axiom; pw.print("("); invAxiom.getProperty().accept( this ); pw.print(" inverse "); invAxiom.getInverseProperty().accept( this ); pw.print(")"); } } /* (non-Javadoc) * @see org.mindswap.pellet.owlapi.OWLExtendedObjectVisitor#visit(org.mindswap.pellet.owlapi.OWLTransitivePropertyAxiom) */ public void visit(OWLTransitivePropertyAxiom axiom) throws OWLException { pw.print("Transitive("); axiom.getProperty().accept( this ); pw.print(")"); } /* (non-Javadoc) * @see org.mindswap.pellet.owlapi.OWLExtendedObjectVisitor#visit(org.mindswap.pellet.owlapi.OWLSymmetricPropertyAxiom) */ public void visit(OWLSymmetricPropertyAxiom axiom) throws OWLException { pw.print("Symmetric("); axiom.getProperty().accept( this ); pw.print(")"); } /* (non-Javadoc) * @see org.mindswap.pellet.owlapi.OWLExtendedObjectVisitor#visit(org.mindswap.pellet.owlapi.OWLInversePropertyAxiom) */ public void visit(OWLInversePropertyAxiom axiom) throws OWLException { pw.print("("); axiom.getProperty().accept( this ); pw.print(" inverse "); axiom.getInverseProperty().accept( this ); pw.print(")"); } /* (non-Javadoc) * @see org.mindswap.pellet.owlapi.OWLExtendedObjectVisitor#visit(org.mindswap.pellet.owlapi.OWLObjectPropertyInstance) */ public void visit(OWLObjectPropertyInstance axiom) throws OWLException { pw.print("("); axiom.getSubject().accept( this ); pw.print(" "); axiom.getProperty().accept( this ); pw.print(" "); axiom.getObject().accept( this ); pw.print(")"); } /* (non-Javadoc) * @see org.mindswap.pellet.owlapi.OWLExtendedObjectVisitor#visit(org.mindswap.pellet.owlapi.OWLDataPropertyInstance) */ public void visit(OWLDataPropertyInstance axiom) throws OWLException { pw.print("("); axiom.getSubject().accept( this ); pw.print(" "); axiom.getProperty().accept( this ); pw.print(" "); axiom.getObject().accept( this ); pw.print(")"); } /* (non-Javadoc) * @see org.mindswap.pellet.owlapi.OWLExtendedObjectVisitor#visit(org.mindswap.pellet.owlapi.OWLIndividualClassAxiom) */ public void visit(OWLIndividualTypeAssertion axiom) throws OWLException { pw.print("("); axiom.getIndividual().accept( this ); pw.print(" rdf:type "); axiom.getType().accept( this ); pw.print(")"); } }
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?