conciseplainvisitor.java
来自「Semantic Web Ontology Editor」· Java 代码 · 共 543 行 · 第 1/2 页
JAVA
543 行
public void visit( OWLObjectCardinalityRestriction restriction ) throws OWLException
{
pw.print("(");
if ( restriction.isExactly() ) {
pw.print(ConcisePlainVisitor.EQU + " " + restriction.getAtLeast() + " ");
} else if ( restriction.isAtMost() ) {
pw.print(ConcisePlainVisitor.LESSEQU + " " + restriction.getAtMost() + " ");
} else if ( restriction.isAtLeast() ) {
pw.print(ConcisePlainVisitor.GREATEQU + " " + restriction.getAtLeast() + " ");
}
restriction.getObjectProperty().accept( this );
pw.print(")");
}
public void visit( OWLDataCardinalityRestriction restriction ) throws OWLException
{
pw.print("(");
if ( restriction.isExactly() ) {
pw.print(ConcisePlainVisitor.EQU + " " + restriction.getAtLeast() + " ");
} else if ( restriction.isAtMost() ) {
pw.print(ConcisePlainVisitor.LESSEQU + " " + restriction.getAtMost() + " ");
} else if ( restriction.isAtLeast() ) {
pw.print(ConcisePlainVisitor.GREATEQU + " " + restriction.getAtLeast() + " ");
}
restriction.getDataProperty().accept( this );
pw.print(")");
}
public void visit( OWLDataValueRestriction restriction ) throws OWLException {
pw.print("(" + ConcisePlainVisitor.EXISTS);
restriction.getDataProperty().accept( this );
/* Changed from hasValue */
pw.print(" "+ ConcisePlainVisitor.MEMBEROF + " {");
restriction.getValue().accept( this );
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( " " + EQUIVALENTTO + " " );
}
for ( Iterator it = complex.iterator(); it.hasNext(); )
{
OWLDescription desc = (OWLDescription) it.next();
desc.accept( this );
if (it.hasNext())
pw.print( " " + EQUIVALENTTO + " " );
}
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(" " + ConcisePlainVisitor.SUBCLASSOF + " " + ConcisePlainVisitor.NOT);
}
pw.print(")");
}
public void visit( OWLSubClassAxiom axiom ) throws OWLException
{
pw.print("(");
axiom.getSubClass().accept( this );
pw.print(" " + ConcisePlainVisitor.SUBCLASSOF + " ");
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(" " + ConcisePlainVisitor.SUBCLASSOF + " ");
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(" " + ConcisePlainVisitor.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( 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 + -
显示快捷键?