⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 axiomcontentextractor.java

📁 Semantic Web Ontology Editor
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
		if ( !classExpDepths.keySet().contains( restriction ))
		{
			classExpDepths.add( restriction );
			depthCountingClassExp.add( restriction );
			desc.accept( this );
			depthCountingClassExp.remove( restriction );
		}
		else
			desc.accept( this );
		
		decrementCurrDepth();
	}

	public void visit( OWLObjectValueRestriction restriction ) throws OWLException 
	{
		incrementCurrDepth();
		incrementAllDepthCounters();
		classExpDepths.put( restriction, new Integer(1) );

		OWLObjectProperty prop = restriction.getObjectProperty();
		OWLIndividual ind = restriction.getIndividual();
		
		hasValueMap.add( prop, ind );
		decrementCurrDepth();
	}
	
	public void visit( OWLDataSomeRestriction restriction ) throws OWLException 
	{
		incrementCurrDepth();
		incrementAllDepthCounters();
		classExpDepths.put( restriction, new Integer(1) );
		
		OWLDataProperty prop = restriction.getDataProperty();
		OWLDataRange datatype =restriction.getDataType();
		
		existentialMap.add( prop, datatype );
		decrementCurrDepth();
	}

	public void visit( OWLDataAllRestriction restriction ) throws OWLException 
	{
		incrementCurrDepth();
		incrementAllDepthCounters();
		classExpDepths.put( restriction, new Integer(1) );
		
		OWLDataProperty prop  = restriction.getDataProperty();
		OWLDataRange datatype = restriction.getDataType();
		
		universalMap.add( prop, datatype );
		decrementCurrDepth();
	}

	public void visit( OWLObjectCardinalityRestriction restriction ) throws OWLException 
	{
		incrementCurrDepth();
		incrementAllDepthCounters();
		classExpDepths.put( restriction, new Integer(1) );
		
		if ( restriction.isExactly() ) 
		{
			cardMap.add( restriction.getObjectProperty(), new Integer( restriction.getAtLeast() ) );
		} 
		else if ( restriction.isAtMost() ) 
		{
			maxCardMap.add( restriction.getObjectProperty(), new Integer( restriction.getAtMost() ) );
		} 
		else if ( restriction.isAtLeast() ) 
		{
			minCardMap.add( restriction.getObjectProperty(), new Integer( restriction.getAtLeast() ) );
		}
		decrementCurrDepth();
	}


	/*
	 * Data Property Restrictions
	 */
	public void visit( OWLDataCardinalityRestriction restriction ) throws OWLException 
	{
		incrementCurrDepth();
		classExpDepths.add( restriction );
		classExpDepths.put( restriction, new Integer(1) );
		
		if ( restriction.isExactly() ) 
		{
			cardMap.add( restriction.getDataProperty(), new Integer( restriction.getAtLeast() ) );
		} 
		else if ( restriction.isAtMost() ) 
		{
			maxCardMap.add( restriction.getDataProperty(), new Integer( restriction.getAtMost() ) );
		} 
		else if ( restriction.isAtLeast() ) 
		{
			minCardMap.add( restriction.getDataProperty(), new Integer( restriction.getAtLeast() ) );
		}
		decrementCurrDepth();
	}

	public void visit( OWLDataValueRestriction restriction ) throws OWLException 
	{
		incrementCurrDepth();
		OWLDataProperty prop = restriction.getDataProperty();
		OWLDataValue val = restriction.getValue();
		classExpDepths.put( restriction, new Integer(1) );
		
		dhasValueMap.add( prop, val );
		decrementCurrDepth();
	}

	
	/* ------------
	 * Class Axioms
	 * ------------
	 */	
	public void visit( OWLEquivalentClassesAxiom axiom ) throws OWLException 
	{
		int maxDepth = 0;
		Set equClas = axiom.getEquivalentClasses();
		for ( Iterator it = equClas.iterator(); it.hasNext(); ) 
		{
			OWLDescription desc = (OWLDescription) it.next();
			desc.accept( this );
			classExpCounts.add( desc );
		}
	}

	
	public void visit( OWLDisjointClassesAxiom axiom ) throws OWLException 
	{
		for ( Iterator it = axiom.getDisjointClasses().iterator(); it.hasNext(); ) 
		{
			OWLDescription desc = (OWLDescription) it.next();
			desc.accept( this );
			classExpCounts.add( desc );
		}
	}

	public void visit( OWLSubClassAxiom axiom ) throws OWLException 
	{
		OWLDescription subclass = axiom.getSubClass();
		OWLDescription supclass = axiom.getSuperClass();
		classExpCounts.add( subclass );
		classExpCounts.add( supclass );
		
		axiom.getSubClass().accept( this );		
		axiom.getSuperClass().accept( this );
	}

	

	

	public void visit( OWLEquivalentPropertiesAxiom axiom ) throws OWLException 
	{
		for ( Iterator it = axiom.getProperties().iterator(); it.hasNext(); ) 
		{
			OWLProperty prop = (OWLProperty) it.next();
			prop.accept( this );
		}
	}
	
	public void visit( OWLSubPropertyAxiom axiom ) throws OWLException 
	{
		axiom.getSubProperty().accept( this );
		axiom.getSuperProperty().accept( this );
	}

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

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

	public void visit( OWLDataType ocdt ) throws OWLException 
	{
		//pw.print( shortForms.shortForm( ocdt.getURI() ) );		
	}

	public void visit( OWLDataEnumeration enumeration ) throws OWLException 
	{
		for ( Iterator it = enumeration.getValues().iterator(); it.hasNext(); ) 
		{
			OWLDataValue desc = (OWLDataValue) it.next();
			desc.accept( this );
		}
	}
	
	
	public void visit( OWLFunctionalPropertyAxiom axiom ) throws OWLException 
	{
		axiom.getProperty().accept( this );
	}
	
	public void visit( OWLPropertyDomainAxiom axiom ) throws OWLException 
	{
		axiom.getProperty().accept( this );
		axiom.getDomain().accept( this );
	}
	
	public void visit( OWLObjectPropertyRangeAxiom axiom ) throws OWLException 
	{
		axiom.getProperty().accept( this );
		axiom.getRange().accept( this );
	}
	
	public void visit( OWLDataPropertyRangeAxiom axiom ) throws OWLException 
	{
		axiom.getProperty().accept( this );
		axiom.getRange().accept( this );
	}
	

    public void visit(OWLInverseFunctionalPropertyAxiom axiom) throws OWLException 
    {
    	if (axiom.getProperty().isInverseFunctional(axiom.getProperty().getOntologies())) 
    	{
			axiom.getProperty().accept( this );
    	}
    	if (axiom instanceof OWLInversePropertyAxiomImpl) 
    	{
    		OWLInversePropertyAxiomImpl invAxiom = (OWLInversePropertyAxiomImpl) axiom;
    		invAxiom.getProperty().accept( this );
    		invAxiom.getInverseProperty().accept( this );	
    	}
    }


    public void visit(OWLTransitivePropertyAxiom axiom) throws OWLException 
    {
		axiom.getProperty().accept( this );    
	}


    public void visit(OWLSymmetricPropertyAxiom axiom) throws OWLException 
    {
		axiom.getProperty().accept( this );    
	}


    public void visit(OWLInversePropertyAxiom axiom) throws OWLException 
    {
		axiom.getProperty().accept( this );
		axiom.getInverseProperty().accept( this );
    }

    // object assertion
    public void visit(OWLObjectPropertyInstance axiom) throws OWLException 
    {
		axiom.getSubject().accept( this );
		axiom.getProperty().accept( this );
		axiom.getObject().accept( this );
    }

    // data assertion
    public void visit(OWLDataPropertyInstance axiom) throws OWLException 
    {    	
		axiom.getSubject().accept( this );
		axiom.getProperty().accept( this );
		axiom.getObject().accept( this );
    }

    // type assertion
    public void visit(OWLIndividualTypeAssertion axiom) throws OWLException 
    {
		axiom.getIndividual().accept( this );
		axiom.getType().accept( this );
    }
    
    
    /*
     * manages currDepth and maxDepth
     */
    private void incrementCurrDepth()
    {
    	currDepth++;
    	if ( currDepth > maxDepth )
    		maxDepth = currDepth;
    }
    
    private void decrementCurrDepth()
    { currDepth--; }
    
    
    private void incrementAllDepthCounters() 
    {
    	try
    	{
	    	for (Iterator it = depthCountingClassExp.iterator(); it.hasNext(); )
	    	{
	    		OWLDescription obj = (OWLDescription)it.next();
	    		classExpDepths.add( obj );
	    	}
    	}
    	catch ( Exception e )
    	{ e.printStackTrace(); }
    }
    
}

⌨️ 快捷键说明

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