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

org.coode.oppl.utils.OWLObjectDecomposer Maven / Gradle / Ivy

package org.coode.oppl.utils;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import org.semanticweb.owlapi.model.IRI;
import org.semanticweb.owlapi.model.OWLAnnotation;
import org.semanticweb.owlapi.model.OWLAnnotationAssertionAxiom;
import org.semanticweb.owlapi.model.OWLAnnotationProperty;
import org.semanticweb.owlapi.model.OWLAnnotationPropertyDomainAxiom;
import org.semanticweb.owlapi.model.OWLAnnotationPropertyRangeAxiom;
import org.semanticweb.owlapi.model.OWLAnonymousIndividual;
import org.semanticweb.owlapi.model.OWLAsymmetricObjectPropertyAxiom;
import org.semanticweb.owlapi.model.OWLClass;
import org.semanticweb.owlapi.model.OWLClassAssertionAxiom;
import org.semanticweb.owlapi.model.OWLDataAllValuesFrom;
import org.semanticweb.owlapi.model.OWLDataComplementOf;
import org.semanticweb.owlapi.model.OWLDataExactCardinality;
import org.semanticweb.owlapi.model.OWLDataHasValue;
import org.semanticweb.owlapi.model.OWLDataIntersectionOf;
import org.semanticweb.owlapi.model.OWLDataMaxCardinality;
import org.semanticweb.owlapi.model.OWLDataMinCardinality;
import org.semanticweb.owlapi.model.OWLDataOneOf;
import org.semanticweb.owlapi.model.OWLDataProperty;
import org.semanticweb.owlapi.model.OWLDataPropertyAssertionAxiom;
import org.semanticweb.owlapi.model.OWLDataPropertyDomainAxiom;
import org.semanticweb.owlapi.model.OWLDataPropertyRangeAxiom;
import org.semanticweb.owlapi.model.OWLDataSomeValuesFrom;
import org.semanticweb.owlapi.model.OWLDataUnionOf;
import org.semanticweb.owlapi.model.OWLDatatype;
import org.semanticweb.owlapi.model.OWLDatatypeDefinitionAxiom;
import org.semanticweb.owlapi.model.OWLDatatypeRestriction;
import org.semanticweb.owlapi.model.OWLDeclarationAxiom;
import org.semanticweb.owlapi.model.OWLDifferentIndividualsAxiom;
import org.semanticweb.owlapi.model.OWLDisjointClassesAxiom;
import org.semanticweb.owlapi.model.OWLDisjointDataPropertiesAxiom;
import org.semanticweb.owlapi.model.OWLDisjointObjectPropertiesAxiom;
import org.semanticweb.owlapi.model.OWLDisjointUnionAxiom;
import org.semanticweb.owlapi.model.OWLEquivalentClassesAxiom;
import org.semanticweb.owlapi.model.OWLEquivalentDataPropertiesAxiom;
import org.semanticweb.owlapi.model.OWLEquivalentObjectPropertiesAxiom;
import org.semanticweb.owlapi.model.OWLFacetRestriction;
import org.semanticweb.owlapi.model.OWLFunctionalDataPropertyAxiom;
import org.semanticweb.owlapi.model.OWLFunctionalObjectPropertyAxiom;
import org.semanticweb.owlapi.model.OWLHasKeyAxiom;
import org.semanticweb.owlapi.model.OWLInverseFunctionalObjectPropertyAxiom;
import org.semanticweb.owlapi.model.OWLInverseObjectPropertiesAxiom;
import org.semanticweb.owlapi.model.OWLIrreflexiveObjectPropertyAxiom;
import org.semanticweb.owlapi.model.OWLLiteral;
import org.semanticweb.owlapi.model.OWLNamedIndividual;
import org.semanticweb.owlapi.model.OWLNegativeDataPropertyAssertionAxiom;
import org.semanticweb.owlapi.model.OWLNegativeObjectPropertyAssertionAxiom;
import org.semanticweb.owlapi.model.OWLObjectAllValuesFrom;
import org.semanticweb.owlapi.model.OWLObjectComplementOf;
import org.semanticweb.owlapi.model.OWLObjectExactCardinality;
import org.semanticweb.owlapi.model.OWLObjectHasSelf;
import org.semanticweb.owlapi.model.OWLObjectHasValue;
import org.semanticweb.owlapi.model.OWLObjectIntersectionOf;
import org.semanticweb.owlapi.model.OWLObjectInverseOf;
import org.semanticweb.owlapi.model.OWLObjectMaxCardinality;
import org.semanticweb.owlapi.model.OWLObjectMinCardinality;
import org.semanticweb.owlapi.model.OWLObjectOneOf;
import org.semanticweb.owlapi.model.OWLObjectProperty;
import org.semanticweb.owlapi.model.OWLObjectPropertyAssertionAxiom;
import org.semanticweb.owlapi.model.OWLObjectPropertyDomainAxiom;
import org.semanticweb.owlapi.model.OWLObjectPropertyRangeAxiom;
import org.semanticweb.owlapi.model.OWLObjectSomeValuesFrom;
import org.semanticweb.owlapi.model.OWLObjectUnionOf;
import org.semanticweb.owlapi.model.OWLObjectVisitorEx;
import org.semanticweb.owlapi.model.OWLOntology;
import org.semanticweb.owlapi.model.OWLReflexiveObjectPropertyAxiom;
import org.semanticweb.owlapi.model.OWLSameIndividualAxiom;
import org.semanticweb.owlapi.model.OWLSubAnnotationPropertyOfAxiom;
import org.semanticweb.owlapi.model.OWLSubClassOfAxiom;
import org.semanticweb.owlapi.model.OWLSubDataPropertyOfAxiom;
import org.semanticweb.owlapi.model.OWLSubObjectPropertyOfAxiom;
import org.semanticweb.owlapi.model.OWLSubPropertyChainOfAxiom;
import org.semanticweb.owlapi.model.OWLSymmetricObjectPropertyAxiom;
import org.semanticweb.owlapi.model.OWLTransitiveObjectPropertyAxiom;
import org.semanticweb.owlapi.model.SWRLBuiltInAtom;
import org.semanticweb.owlapi.model.SWRLClassAtom;
import org.semanticweb.owlapi.model.SWRLDataPropertyAtom;
import org.semanticweb.owlapi.model.SWRLDataRangeAtom;
import org.semanticweb.owlapi.model.SWRLDifferentIndividualsAtom;
import org.semanticweb.owlapi.model.SWRLIndividualArgument;
import org.semanticweb.owlapi.model.SWRLLiteralArgument;
import org.semanticweb.owlapi.model.SWRLObjectPropertyAtom;
import org.semanticweb.owlapi.model.SWRLRule;
import org.semanticweb.owlapi.model.SWRLSameIndividualAtom;
import org.semanticweb.owlapi.model.SWRLVariable;

/** @author Luigi Iannone */
public final class OWLObjectDecomposer implements OWLObjectVisitorEx> {
    @Override
    public List visit(OWLSubClassOfAxiom axiom) {
        List toReturn = new ArrayList();
        toReturn.add(axiom.getSubClass());
        toReturn.add(axiom.getSuperClass());
        return toReturn;
    }

    @Override
    public List visit(OWLNegativeObjectPropertyAssertionAxiom axiom) {
        List toReturn = new ArrayList();
        toReturn.add(axiom.getProperty());
        toReturn.add(axiom.getSubject());
        toReturn.add(axiom.getObject());
        return toReturn;
    }

    @Override
    public List visit(OWLAsymmetricObjectPropertyAxiom axiom) {
        List toReturn = new ArrayList();
        toReturn.add(axiom.getProperty());
        return toReturn;
    }

    @Override
    public List visit(OWLReflexiveObjectPropertyAxiom axiom) {
        List toReturn = new ArrayList();
        toReturn.add(axiom.getProperty());
        return toReturn;
    }

    @Override
    public List visit(OWLDisjointClassesAxiom axiom) {
        List toReturn = new ArrayList();
        toReturn.addAll(axiom.getClassExpressions());
        return toReturn;
    }

    @Override
    public List visit(OWLDataPropertyDomainAxiom axiom) {
        List toReturn = new ArrayList();
        toReturn.add(axiom.getProperty());
        toReturn.add(axiom.getDomain());
        return toReturn;
    }

    @Override
    public List visit(OWLObjectPropertyDomainAxiom axiom) {
        List toReturn = new ArrayList();
        toReturn.add(axiom.getProperty());
        toReturn.add(axiom.getDomain());
        return toReturn;
    }

    @Override
    public List visit(OWLEquivalentObjectPropertiesAxiom axiom) {
        List toReturn = new ArrayList();
        toReturn.addAll(axiom.getProperties());
        return toReturn;
    }

    @Override
    public List visit(OWLNegativeDataPropertyAssertionAxiom axiom) {
        List toReturn = new ArrayList();
        toReturn.add(axiom.getProperty());
        toReturn.add(axiom.getSubject());
        toReturn.add(axiom.getObject());
        return toReturn;
    }

    @Override
    public List visit(OWLDifferentIndividualsAxiom axiom) {
        List toReturn = new ArrayList();
        toReturn.addAll(axiom.getIndividuals());
        return toReturn;
    }

    @Override
    public List visit(OWLDisjointDataPropertiesAxiom axiom) {
        List toReturn = new ArrayList();
        toReturn.addAll(axiom.getProperties());
        return toReturn;
    }

    @Override
    public List visit(OWLDisjointObjectPropertiesAxiom axiom) {
        List toReturn = new ArrayList();
        toReturn.addAll(axiom.getProperties());
        return toReturn;
    }

    @Override
    public List visit(OWLObjectPropertyRangeAxiom axiom) {
        List toReturn = new ArrayList();
        toReturn.add(axiom.getProperty());
        toReturn.add(axiom.getRange());
        return toReturn;
    }

    @Override
    public List visit(OWLObjectPropertyAssertionAxiom axiom) {
        List toReturn = new ArrayList();
        toReturn.add(axiom.getProperty());
        toReturn.add(axiom.getSubject());
        toReturn.add(axiom.getObject());
        return toReturn;
    }

    @Override
    public List visit(OWLFunctionalObjectPropertyAxiom axiom) {
        List toReturn = new ArrayList();
        toReturn.add(axiom.getProperty());
        return toReturn;
    }

    @Override
    public List visit(OWLSubObjectPropertyOfAxiom axiom) {
        List toReturn = new ArrayList();
        toReturn.add(axiom.getSubProperty());
        toReturn.add(axiom.getSuperProperty());
        return toReturn;
    }

    @Override
    public List visit(OWLDisjointUnionAxiom axiom) {
        List toReturn = new ArrayList();
        toReturn.addAll(axiom.getClassExpressions());
        return toReturn;
    }

    @Override
    public List visit(OWLDeclarationAxiom axiom) {
        List toReturn = new ArrayList();
        toReturn.add(axiom.getEntity());
        return toReturn;
    }

    @Override
    public List visit(OWLAnnotationAssertionAxiom axiom) {
        List toReturn = new ArrayList();
        toReturn.add(axiom.getSubject());
        toReturn.add(axiom.getAnnotation());
        return toReturn;
    }

    @Override
    public List visit(OWLSymmetricObjectPropertyAxiom axiom) {
        List toReturn = new ArrayList();
        toReturn.add(axiom.getProperty());
        return toReturn;
    }

    @Override
    public List visit(OWLDataPropertyRangeAxiom axiom) {
        List toReturn = new ArrayList();
        toReturn.add(axiom.getProperty());
        toReturn.add(axiom.getRange());
        return toReturn;
    }

    @Override
    public List visit(OWLFunctionalDataPropertyAxiom axiom) {
        List toReturn = new ArrayList();
        toReturn.add(axiom.getProperty());
        return toReturn;
    }

    @Override
    public List visit(OWLEquivalentDataPropertiesAxiom axiom) {
        List toReturn = new ArrayList();
        toReturn.addAll(axiom.getProperties());
        return toReturn;
    }

    @Override
    public List visit(OWLClassAssertionAxiom axiom) {
        List toReturn = new ArrayList();
        toReturn.add(axiom.getClassExpression());
        toReturn.add(axiom.getIndividual());
        return toReturn;
    }

    @Override
    public List visit(OWLEquivalentClassesAxiom axiom) {
        List toReturn = new ArrayList();
        toReturn.addAll(axiom.getClassExpressions());
        return toReturn;
    }

    @Override
    public List visit(OWLDataPropertyAssertionAxiom axiom) {
        List toReturn = new ArrayList();
        toReturn.add(axiom.getProperty());
        toReturn.add(axiom.getSubject());
        toReturn.add(axiom.getObject());
        return toReturn;
    }

    @Override
    public List visit(OWLTransitiveObjectPropertyAxiom axiom) {
        List toReturn = new ArrayList();
        toReturn.add(axiom.getProperty());
        return toReturn;
    }

    @Override
    public List visit(OWLIrreflexiveObjectPropertyAxiom axiom) {
        List toReturn = new ArrayList();
        toReturn.add(axiom.getProperty());
        return toReturn;
    }

    @Override
    public List visit(OWLSubDataPropertyOfAxiom axiom) {
        List toReturn = new ArrayList();
        toReturn.add(axiom.getSubProperty());
        toReturn.add(axiom.getSuperProperty());
        return toReturn;
    }

    @Override
    public List visit(OWLInverseFunctionalObjectPropertyAxiom axiom) {
        List toReturn = new ArrayList();
        toReturn.add(axiom.getProperty());
        return toReturn;
    }

    @Override
    public List visit(OWLSameIndividualAxiom axiom) {
        List toReturn = new ArrayList();
        toReturn.addAll(axiom.getIndividuals());
        return toReturn;
    }

    @Override
    public List visit(OWLSubPropertyChainOfAxiom axiom) {
        List toReturn = new ArrayList();
        toReturn.addAll(axiom.getPropertyChain());
        toReturn.add(axiom.getSuperProperty());
        return toReturn;
    }

    @Override
    public List visit(OWLInverseObjectPropertiesAxiom axiom) {
        List toReturn = new ArrayList();
        toReturn.add(axiom.getFirstProperty());
        toReturn.add(axiom.getSecondProperty());
        return toReturn;
    }

    @Override
    public List visit(OWLHasKeyAxiom axiom) {
        List toReturn = new ArrayList();
        toReturn.add(axiom.getClassExpression());
        toReturn.addAll(axiom.getPropertyExpressions());
        return toReturn;
    }

    @Override
    public List visit(OWLDatatypeDefinitionAxiom axiom) {
        List toReturn = new ArrayList();
        toReturn.add(axiom.getDatatype());
        toReturn.add(axiom.getDataRange());
        return toReturn;
    }

    @Override
    public List visit(SWRLRule rule) {
        List toReturn = new ArrayList();
        toReturn.addAll(rule.getHead());
        toReturn.addAll(rule.getBody());
        return toReturn;
    }

    @Override
    public List visit(OWLSubAnnotationPropertyOfAxiom axiom) {
        List toReturn = new ArrayList();
        toReturn.add(axiom.getSubProperty());
        toReturn.add(axiom.getSuperProperty());
        return toReturn;
    }

    @Override
    public List visit(OWLAnnotationPropertyDomainAxiom axiom) {
        List toReturn = new ArrayList();
        toReturn.add(axiom.getProperty());
        toReturn.add(axiom.getDomain());
        return toReturn;
    }

    @Override
    public List visit(OWLAnnotationPropertyRangeAxiom axiom) {
        List toReturn = new ArrayList();
        toReturn.add(axiom.getProperty());
        toReturn.add(axiom.getRange());
        return toReturn;
    }

    @Override
    public List visit(OWLClass ce) {
        return Collections.emptyList();
    }

    @Override
    public List visit(OWLObjectIntersectionOf ce) {
        List toReturn = new ArrayList();
        toReturn.addAll(ce.getOperands());
        return toReturn;
    }

    @Override
    public List visit(OWLObjectUnionOf ce) {
        List toReturn = new ArrayList();
        toReturn.addAll(ce.getOperands());
        return toReturn;
    }

    @Override
    public List visit(OWLObjectComplementOf ce) {
        List toReturn = new ArrayList();
        toReturn.add(ce.getOperand());
        return toReturn;
    }

    @Override
    public List visit(OWLObjectSomeValuesFrom ce) {
        List toReturn = new ArrayList();
        toReturn.add(ce.getProperty());
        toReturn.add(ce.getFiller());
        return toReturn;
    }

    @Override
    public List visit(OWLObjectAllValuesFrom ce) {
        List toReturn = new ArrayList();
        toReturn.add(ce.getProperty());
        toReturn.add(ce.getFiller());
        return toReturn;
    }

    @Override
    public List visit(OWLObjectHasValue ce) {
        List toReturn = new ArrayList();
        toReturn.add(ce.getProperty());
        toReturn.add(ce.getValue());
        return toReturn;
    }

    @Override
    public List visit(OWLObjectMinCardinality ce) {
        List toReturn = new ArrayList();
        toReturn.add(ce.getProperty());
        toReturn.add(ce.getCardinality());
        toReturn.add(ce.getFiller());
        return toReturn;
    }

    @Override
    public List visit(OWLObjectExactCardinality ce) {
        List toReturn = new ArrayList();
        toReturn.add(ce.getProperty());
        toReturn.add(ce.getCardinality());
        toReturn.add(ce.getFiller());
        return toReturn;
    }

    @Override
    public List visit(OWLObjectMaxCardinality ce) {
        List toReturn = new ArrayList();
        toReturn.add(ce.getProperty());
        toReturn.add(ce.getCardinality());
        toReturn.add(ce.getFiller());
        return toReturn;
    }

    @Override
    public List visit(OWLObjectHasSelf ce) {
        List toReturn = new ArrayList();
        toReturn.add(ce.getProperty());
        return toReturn;
    }

    @Override
    public List visit(OWLObjectOneOf ce) {
        List toReturn = new ArrayList();
        toReturn.addAll(ce.getIndividuals());
        return toReturn;
    }

    @Override
    public List visit(OWLDataSomeValuesFrom ce) {
        List toReturn = new ArrayList();
        toReturn.add(ce.getProperty());
        toReturn.add(ce.getFiller());
        return toReturn;
    }

    @Override
    public List visit(OWLDataAllValuesFrom ce) {
        List toReturn = new ArrayList();
        toReturn.add(ce.getProperty());
        toReturn.add(ce.getFiller());
        return toReturn;
    }

    @Override
    public List visit(OWLDataHasValue ce) {
        List toReturn = new ArrayList();
        toReturn.add(ce.getProperty());
        toReturn.add(ce.getValue());
        return toReturn;
    }

    @Override
    public List visit(OWLDataMinCardinality ce) {
        List toReturn = new ArrayList();
        toReturn.add(ce.getProperty());
        toReturn.add(ce.getCardinality());
        toReturn.add(ce.getFiller());
        return toReturn;
    }

    @Override
    public List visit(OWLDataExactCardinality ce) {
        List toReturn = new ArrayList();
        toReturn.add(ce.getProperty());
        toReturn.add(ce.getCardinality());
        toReturn.add(ce.getFiller());
        return toReturn;
    }

    @Override
    public List visit(OWLDataMaxCardinality ce) {
        List toReturn = new ArrayList();
        toReturn.add(ce.getProperty());
        toReturn.add(ce.getCardinality());
        toReturn.add(ce.getFiller());
        return toReturn;
    }

    @Override
    public List visit(OWLDatatype node) {
        return Collections.emptyList();
    }

    @Override
    public List visit(OWLDataComplementOf node) {
        List toReturn = new ArrayList();
        toReturn.add(node.getDataRange());
        return toReturn;
    }

    @Override
    public List visit(OWLDataOneOf node) {
        List toReturn = new ArrayList();
        toReturn.addAll(node.getValues());
        return toReturn;
    }

    @Override
    public List visit(OWLDataIntersectionOf node) {
        List toReturn = new ArrayList();
        toReturn.addAll(node.getOperands());
        return toReturn;
    }

    @Override
    public List visit(OWLDataUnionOf node) {
        List toReturn = new ArrayList();
        toReturn.addAll(node.getOperands());
        return toReturn;
    }

    @Override
    public List visit(OWLDatatypeRestriction node) {
        List toReturn = new ArrayList();
        toReturn.addAll(node.getFacetRestrictions());
        return toReturn;
    }

    @Override
    public List visit(OWLLiteral node) {
        return Collections.emptyList();
    }

    @Override
    public List visit(OWLFacetRestriction node) {
        List toReturn = new ArrayList();
        toReturn.add(node.getFacet());
        toReturn.add(node.getFacetValue());
        return toReturn;
    }

    @Override
    public List visit(OWLObjectProperty property) {
        return Collections.emptyList();
    }

    @Override
    public List visit(OWLObjectInverseOf property) {
        List toReturn = new ArrayList();
        toReturn.add(property.getInverse());
        return toReturn;
    }

    @Override
    public List visit(OWLDataProperty property) {
        return Collections.emptyList();
    }

    @Override
    public List visit(OWLNamedIndividual individual) {
        return Collections.emptyList();
    }

    @Override
    public List visit(OWLAnnotationProperty property) {
        return Collections.emptyList();
    }

    @Override
    public List visit(OWLAnnotation node) {
        List toReturn = new ArrayList();
        toReturn.add(node.getProperty());
        toReturn.add(node.getValue());
        return toReturn;
    }

    @Override
    public List visit(IRI iri) {
        return Collections.emptyList();
    }

    @Override
    public List visit(OWLAnonymousIndividual individual) {
        return Collections.emptyList();
    }

    @Override
    public List visit(SWRLClassAtom node) {
        List toReturn = new ArrayList();
        toReturn.add(node.getPredicate());
        toReturn.add(node.getArgument());
        return toReturn;
    }

    @Override
    public List visit(SWRLDataRangeAtom node) {
        List toReturn = new ArrayList();
        toReturn.add(node.getPredicate());
        toReturn.add(node.getArgument());
        return toReturn;
    }

    @Override
    public List visit(SWRLObjectPropertyAtom node) {
        List toReturn = new ArrayList();
        toReturn.add(node.getPredicate());
        toReturn.add(node.getFirstArgument());
        toReturn.add(node.getSecondArgument());
        return toReturn;
    }

    @Override
    public List visit(SWRLDataPropertyAtom node) {
        List toReturn = new ArrayList();
        toReturn.add(node.getPredicate());
        toReturn.add(node.getFirstArgument());
        toReturn.add(node.getSecondArgument());
        return toReturn;
    }

    @Override
    public List visit(SWRLBuiltInAtom node) {
        List toReturn = new ArrayList();
        toReturn.add(node.getPredicate());
        toReturn.add(node.getArguments());
        return toReturn;
    }

    @Override
    public List visit(SWRLVariable node) {
        List toReturn = new ArrayList();
        toReturn.add(node.getIRI());
        return toReturn;
    }

    @Override
    public List visit(SWRLIndividualArgument node) {
        List toReturn = new ArrayList();
        toReturn.add(node.getIndividual());
        return toReturn;
    }

    @Override
    public List visit(SWRLLiteralArgument node) {
        List toReturn = new ArrayList();
        toReturn.add(node.getLiteral());
        return toReturn;
    }

    @Override
    public List visit(SWRLSameIndividualAtom node) {
        List toReturn = new ArrayList();
        toReturn.add(node.getFirstArgument());
        toReturn.add(node.getSecondArgument());
        return toReturn;
    }

    @Override
    public List visit(SWRLDifferentIndividualsAtom node) {
        List toReturn = new ArrayList();
        toReturn.add(node.getFirstArgument());
        toReturn.add(node.getSecondArgument());
        return toReturn;
    }

    @Override
    public List visit(OWLOntology ontology) {
        return Collections.emptyList();
    }
}