当前位置: 首页>>代码示例>>Java>>正文


Java OWLOntologyDocumentAlreadyExistsException类代码示例

本文整理汇总了Java中org.semanticweb.owlapi.model.OWLOntologyDocumentAlreadyExistsException的典型用法代码示例。如果您正苦于以下问题:Java OWLOntologyDocumentAlreadyExistsException类的具体用法?Java OWLOntologyDocumentAlreadyExistsException怎么用?Java OWLOntologyDocumentAlreadyExistsException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


OWLOntologyDocumentAlreadyExistsException类属于org.semanticweb.owlapi.model包,在下文中一共展示了OWLOntologyDocumentAlreadyExistsException类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: loadOntology

import org.semanticweb.owlapi.model.OWLOntologyDocumentAlreadyExistsException; //导入依赖的package包/类
@Override
   public HeavyLoadedOntology loadOntology( URI uri ) throws OntowrapException {
OWLAPI3Ontology onto = null;
//System.err.println( " Loading ontology "+uri );
// Cache seems to be implemented in API 3.0 anyway
// and it seems to not work well with this one
onto = cache.getOntologyFromURI( uri );
//System.err.println( "   cache1: "+onto );
if ( onto != null ) return onto;
onto = cache.getOntology( uri );
//System.err.println( "   cache2: "+onto );
if ( onto != null ) return onto;
// OWLAPI's own cache
IRI ontoIRI = IRI.create( uri );
OWLOntology ontology = manager.getOntology( ontoIRI );
//System.err.println( "   cache3: "+ontology );

try {
    // This below does not seem to work!
    //ontology = manager.loadOntologyFromOntologyDocument( IRI.create( uri ) );
    if ( ontology == null ) ontology = manager.loadOntology( ontoIRI );
    //System.err.println( "   loaded: "+ontology );
    // I must retrieve it from cache and return it!
} catch ( OWLOntologyDocumentAlreadyExistsException oodaeex ) { // should never happen
    // This is a cache failure
    throw new OntowrapException("Already loaded [doc cache failure] " + uri, oodaeex );
} catch ( OWLOntologyAlreadyExistsException ooaeex ) {
    // This happens when the ontology has been loaded from a different URIs
    ontology = manager.getOntology( ooaeex.getOntologyID() );
    if ( ontology == null )
	throw new OntowrapException("Already loaded [owl cache failure] " + uri, ooaeex );
} catch ( OWLOntologyCreationException oocex ) {
    oocex.printStackTrace();
    throw new OntowrapException("Cannot load " + uri, oocex );
}
onto = new OWLAPI3Ontology();
onto.setFormalism( formalismId );
onto.setFormURI( formalismUri );
onto.setOntology( ontology );
onto.setFile( uri );
try {
    onto.setURI( ontology.getOntologyID().getOntologyIRI().toURI() );
} catch ( Exception e ) { // Should be a NullPointerException
    // Better put in the OntowrapException of loaded
    // The ontology has no URI. In principle, it is not valid
    // It may be possible to put the uri instead (now it is void)
    e.printStackTrace();
}
cache.recordOntology( uri, onto );
//System.err.println( "   after-cache: "+cache.getOntology( uri ) );
return onto;
   }
 
开发者ID:dozed,项目名称:align-api-project,代码行数:53,代码来源:OWLAPI3OntologyFactory.java


注:本文中的org.semanticweb.owlapi.model.OWLOntologyDocumentAlreadyExistsException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。