owlobjectcontainer.java

来自「Semantic Web Ontology Editor」· Java 代码 · 共 457 行 · 第 1/2 页

JAVA
457
字号
/*
 * Created on May 27, 2005
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
package org.mindswap.swoop.renderer.entity;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Set;

import org.mindswap.swoop.renderer.SwoopRenderingVisitor;
import org.semanticweb.owl.impl.model.OWLInversePropertyAxiomImpl;
import org.semanticweb.owl.model.OWLAnd;
import org.semanticweb.owl.model.OWLAnnotationProperty;
import org.semanticweb.owl.model.OWLClass;
import org.semanticweb.owl.model.OWLDataAllRestriction;
import org.semanticweb.owl.model.OWLDataCardinalityRestriction;
import org.semanticweb.owl.model.OWLDataEnumeration;
import org.semanticweb.owl.model.OWLDataProperty;
import org.semanticweb.owl.model.OWLDataPropertyInstance;
import org.semanticweb.owl.model.OWLDataPropertyRangeAxiom;
import org.semanticweb.owl.model.OWLDataSomeRestriction;
import org.semanticweb.owl.model.OWLDataType;
import org.semanticweb.owl.model.OWLDataValue;
import org.semanticweb.owl.model.OWLDataValueRestriction;
import org.semanticweb.owl.model.OWLDescription;
import org.semanticweb.owl.model.OWLDifferentIndividualsAxiom;
import org.semanticweb.owl.model.OWLDisjointClassesAxiom;
import org.semanticweb.owl.model.OWLEnumeration;
import org.semanticweb.owl.model.OWLEquivalentClassesAxiom;
import org.semanticweb.owl.model.OWLEquivalentPropertiesAxiom;
import org.semanticweb.owl.model.OWLException;
import org.semanticweb.owl.model.OWLFunctionalPropertyAxiom;
import org.semanticweb.owl.model.OWLIndividual;
import org.semanticweb.owl.model.OWLIndividualTypeAssertion;
import org.semanticweb.owl.model.OWLInverseFunctionalPropertyAxiom;
import org.semanticweb.owl.model.OWLInversePropertyAxiom;
import org.semanticweb.owl.model.OWLNamedObject;
import org.semanticweb.owl.model.OWLNot;
import org.semanticweb.owl.model.OWLObject;
import org.semanticweb.owl.model.OWLObjectAllRestriction;
import org.semanticweb.owl.model.OWLObjectCardinalityRestriction;
import org.semanticweb.owl.model.OWLObjectProperty;
import org.semanticweb.owl.model.OWLObjectPropertyInstance;
import org.semanticweb.owl.model.OWLObjectPropertyRangeAxiom;
import org.semanticweb.owl.model.OWLObjectSomeRestriction;
import org.semanticweb.owl.model.OWLObjectValueRestriction;
import org.semanticweb.owl.model.OWLOr;
import org.semanticweb.owl.model.OWLProperty;
import org.semanticweb.owl.model.OWLPropertyDomainAxiom;
import org.semanticweb.owl.model.OWLSameIndividualsAxiom;
import org.semanticweb.owl.model.OWLSubClassAxiom;
import org.semanticweb.owl.model.OWLSubPropertyAxiom;
import org.semanticweb.owl.model.OWLSymmetricPropertyAxiom;
import org.semanticweb.owl.model.OWLTransitivePropertyAxiom;
import org.semanticweb.owl.model.helper.OWLObjectVisitorAdapter;

/**
 * @author Aditya
 *
 */
public class OWLObjectContainer extends OWLObjectVisitorAdapter implements SwoopRenderingVisitor
//Uncomment for explanation
//,OWLExtendedObjectVisitor
{
 
	List objects;
	List LHS, RHS;
	OWLNamedObject base;
	
	public OWLObjectContainer(OWLNamedObject base)
	{
		this.base= base;
		reset();
	}
	
	public String result() {
		return ""; // use getContainedObjects() instead
	}

	public void reset() {
		this.objects = new ArrayList();
		this.LHS = new ArrayList();
		this.RHS = new ArrayList();
	}
	
	public void visit( OWLObject obj) throws OWLException {
		if (obj instanceof OWLClass) visit((OWLClass) obj);
		else
			if (obj instanceof OWLDataProperty) visit((OWLDataProperty) obj);
		else
			if (obj instanceof OWLObjectProperty) visit((OWLObjectProperty) obj);
		else
			if (obj instanceof OWLAnnotationProperty) visit((OWLAnnotationProperty) obj);
		else
			if (obj instanceof OWLIndividual) visit((OWLIndividual) obj);
		else
			if (obj instanceof OWLAnd) visit((OWLAnd) obj);
		else
			if (obj instanceof OWLOr) visit((OWLOr) obj);
		else
			if (obj instanceof OWLNot) visit((OWLNot) obj);
		else
			if (obj instanceof OWLDataAllRestriction) visit((OWLDataAllRestriction) obj);
		else
			if (obj instanceof OWLDataSomeRestriction) visit((OWLDataSomeRestriction) obj);
		else 
			if (obj instanceof OWLDataValueRestriction) visit((OWLDataValueRestriction) obj);
		else
			if (obj instanceof OWLObjectAllRestriction) visit((OWLObjectAllRestriction) obj);
		else
			if (obj instanceof OWLObjectSomeRestriction) visit((OWLObjectSomeRestriction) obj);
		else 
			if (obj instanceof OWLObjectValueRestriction) visit((OWLObjectValueRestriction) obj);
		else
			if (obj instanceof OWLDataCardinalityRestriction) visit((OWLDataCardinalityRestriction) obj);
		else 
			if (obj instanceof OWLObjectCardinalityRestriction) visit((OWLObjectCardinalityRestriction) obj);
		else 
			if (obj instanceof OWLDataEnumeration) visit((OWLDataEnumeration) obj);
		else
			if (obj instanceof OWLDataPropertyInstance) visit((OWLDataPropertyInstance) obj);
		else
			if (obj instanceof OWLDataPropertyRangeAxiom) visit((OWLDataPropertyRangeAxiom) obj);
		else
			if (obj instanceof OWLDataType) visit((OWLDataType) obj);
		else
			if (obj instanceof OWLDifferentIndividualsAxiom) visit((OWLDifferentIndividualsAxiom) obj);
		else
			if (obj instanceof OWLDisjointClassesAxiom) visit((OWLDisjointClassesAxiom) obj);
		else
			if (obj instanceof OWLEnumeration) visit((OWLEnumeration) obj);
		else
			if (obj instanceof OWLEquivalentClassesAxiom) visit((OWLEquivalentClassesAxiom) obj);
		else
			if (obj instanceof OWLEquivalentPropertiesAxiom) visit((OWLEquivalentPropertiesAxiom) obj);
		else
			if (obj instanceof OWLFunctionalPropertyAxiom) visit((OWLFunctionalPropertyAxiom) obj);
		else
			if (obj instanceof OWLIndividualTypeAssertion) visit((OWLIndividualTypeAssertion) obj);		
		else
			if (obj instanceof OWLInversePropertyAxiom) visit((OWLInversePropertyAxiom) obj);
		else
			if (obj instanceof OWLInversePropertyAxiomImpl) visit((OWLInversePropertyAxiomImpl) obj);
		else
			if (obj instanceof OWLInverseFunctionalPropertyAxiom) visit((OWLInverseFunctionalPropertyAxiom) obj);
		else
			if (obj instanceof OWLEquivalentClassesAxiom) visit((OWLEquivalentClassesAxiom) obj);
		else
			if (obj instanceof OWLObjectPropertyInstance) visit((OWLObjectPropertyInstance) obj);
		else
			if (obj instanceof OWLObjectPropertyRangeAxiom) visit((OWLObjectPropertyRangeAxiom) obj);
		else
			if (obj instanceof OWLPropertyDomainAxiom) visit((OWLPropertyDomainAxiom) obj);
		else
			if (obj instanceof OWLSameIndividualsAxiom) visit((OWLSameIndividualsAxiom) obj);
		else
			if (obj instanceof OWLSubClassAxiom) visit((OWLSubClassAxiom) obj);
		else
			if (obj instanceof OWLSubPropertyAxiom) visit((OWLSubPropertyAxiom) obj);
		else
			if (obj instanceof OWLSymmetricPropertyAxiom) visit((OWLSymmetricPropertyAxiom) obj);
		else
			if (obj instanceof OWLTransitivePropertyAxiom) visit((OWLTransitivePropertyAxiom) obj);
	}
	
	public void visit( OWLClass clazz ) throws OWLException {
		objects.add(clazz);	
	}
	
	public void visit( OWLIndividual ind ) throws OWLException {
		objects.add(ind);
	}
	
	
	public void visit( OWLObjectProperty prop ) throws OWLException {
		objects.add(prop);
	}
	
	public void visit( OWLAnnotationProperty prop ) throws OWLException {
		objects.add(prop);
	}
	
	public void visit( OWLDataProperty prop ) throws OWLException {
		objects.add(prop);
	}
	
	public void visit( OWLDataValue cd ) throws OWLException {		
	}

	public void visit( OWLAnd and ) throws OWLException {
		for ( Iterator it = and.getOperands().iterator();
		it.hasNext(); ) {
			OWLDescription desc = (OWLDescription) it.next();
			desc.accept( this );		
		}		
	}

	public void visit( OWLOr or ) throws OWLException {
		for ( Iterator it = or.getOperands().iterator();
		it.hasNext(); ) {
			OWLDescription desc = (OWLDescription) it.next();
			desc.accept( this );			
		}		
	}

	public void visit( OWLNot not ) throws OWLException {
		OWLDescription desc = not.getOperand();
		desc.accept( this );		
	}

	public void visit( OWLEnumeration enumeration ) throws OWLException {
		for ( Iterator it = enumeration.getIndividuals().iterator();
		it.hasNext(); ) {
			OWLIndividual desc = (OWLIndividual) it.next();
			desc.accept( this );		
		}
	}

	public void visit( OWLObjectSomeRestriction restriction ) throws OWLException {
		restriction.getObjectProperty().accept( this );
		restriction.getDescription().accept( this );		
	}

	public void visit( OWLObjectAllRestriction restriction ) throws OWLException {
		restriction.getObjectProperty().accept( this );

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?