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


Java OntResource.asOntology方法代码示例

本文整理汇总了Java中org.apache.jena.ontology.OntResource.asOntology方法的典型用法代码示例。如果您正苦于以下问题:Java OntResource.asOntology方法的具体用法?Java OntResource.asOntology怎么用?Java OntResource.asOntology使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.jena.ontology.OntResource的用法示例。


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

示例1: check

import org.apache.jena.ontology.OntResource; //导入方法依赖的package包/类
public void check(Ontology ontology)
{
    if (ontology == null) throw new IllegalArgumentException("Ontology cannot be null");
    
    marked.put(ontology, Boolean.TRUE);
    onStack.put(ontology, Boolean.TRUE);

    ExtendedIterator<OntResource> it = ontology.listImports();
    try
    {
        while (it.hasNext())
        {
            OntResource importRes = it.next();
            if (importRes.canAs(Ontology.class))
            {
                Ontology imported = importRes.asOntology();
                if (marked.get(imported) == null)
                    check(imported);
                else if (onStack.get(imported))
                {
                    cycleOntology = imported;
                    return;
                }
            }
        }

        onStack.put(ontology, Boolean.FALSE);
    }
    finally
    {
        it.close();
    }
}
 
开发者ID:AtomGraph,项目名称:Processor,代码行数:34,代码来源:OntologyProvider.java

示例2: match

import org.apache.jena.ontology.OntResource; //导入方法依赖的package包/类
public SortedSet<ClassPrecedence> match(Ontology ontology, Resource resource, Property property, int level)
   {
       if (ontology == null) throw new IllegalArgumentException("Ontology cannot be null");
if (resource == null) throw new IllegalArgumentException("Resource cannot be null");
if (property == null) throw new IllegalArgumentException("Property cannot be null");

       SortedSet<ClassPrecedence> matchedClasses = new TreeSet<>();
       ResIterator it = ontology.getOntModel().listResourcesWithProperty(LDT.segment);
       try
       {
           while (it.hasNext())
           {
               Resource ontClassRes = it.next();
               OntClass ontClass = ontology.getOntModel().getOntResource(ontClassRes).asClass();
               // only match templates defined in this ontology - maybe reverse loops?
               if (ontClass.getIsDefinedBy() != null && ontClass.getIsDefinedBy().equals(ontology) &&
                       resource.hasProperty(property, ontClass))
               {
                   ClassPrecedence template = new ClassPrecedence(ontClass, level * -1);
                   if (log.isTraceEnabled()) log.trace("Resource {} matched OntClass {}", resource, ontClass);
                   matchedClasses.add(template);
               } 
           }            
       }
       finally
       {
           it.close();
       }

       ExtendedIterator<OntResource> imports = ontology.listImports();
       try
       {
           while (imports.hasNext())
           {
               OntResource importRes = imports.next();
               if (importRes.canAs(Ontology.class))
               {
                   Ontology importedOntology = importRes.asOntology();
                   // traverse imports recursively
                   Set<ClassPrecedence> matchedImportClasses = match(importedOntology, resource, property, level + 1);
                   matchedClasses.addAll(matchedImportClasses);
               }
           }
       }
       finally
       {
           imports.close();
       }
       
       return matchedClasses;
   }
 
开发者ID:AtomGraph,项目名称:Processor,代码行数:52,代码来源:Skolemizer.java


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