All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.protege.owlapi.inference.cls.NamedConjunctChecker Maven / Gradle / Ivy

Go to download

OWL ontology editing infrastructure used by the Protege desktop application.

There is a newer version: 5.6.4
Show newest version
package org.protege.owlapi.inference.cls;

import org.semanticweb.owlapi.model.OWLClass;
import org.semanticweb.owlapi.model.OWLClassExpression;
import org.semanticweb.owlapi.model.OWLObjectIntersectionOf;
import org.semanticweb.owlapi.util.OWLClassExpressionVisitorAdapter;

    /**
     * Checks whether a class description contains a specified named conjunct.
     */
public class NamedConjunctChecker extends OWLClassExpressionVisitorAdapter {

    private boolean found;

    private OWLClass searchClass;


    public boolean containsConjunct(OWLClass conjunct, OWLClassExpression description) {
        found = false;
        searchClass = conjunct;
        description.accept(this);
        return found;
    }

    //////////////////////////////////////////////////////////////////////////////////////////


    public void visit(OWLClass desc) {
        if (desc.equals(searchClass)) {
            found = true;
        }
    }


    public void visit(OWLObjectIntersectionOf desc) {
        for (OWLClassExpression op : desc.getOperands()) {
            op.accept(this);
            if (found) {
                break;
            }
        }
    }

    //////////////////////////////////////////////////////////////////////////////////////////
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy