• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java OntClass类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: renderHierarchy

import org.apache.jena.ontology.OntClass; //导入依赖的package包/类
protected static void renderHierarchy(PrintStream out, OntClass cls, List<Object> occurs, int depth) {
  renderClassDescription(out, cls, depth);
  out.println();

  // recurse to the next level down
  if (cls.canAs(OntClass.class) && !occurs.contains(cls)) {
    for (Iterator<?> i = cls.listSubClasses(true); i.hasNext(); ) {
      OntClass sub = (OntClass) i.next();

      // we push this expression on the occurs list before we recurse
      occurs.add(cls);
      renderHierarchy(out, sub, occurs, depth + 1);
      occurs.remove(cls);
    }
    for (Iterator<?> i = cls.listInstances(); i.hasNext(); ) {
      Individual individual = (Individual) i.next();
      renderURI(out, individual.getModel(), individual.getURI());
      out.print(" [");
      for (Iterator<?> j = individual.listLabels(null); j.hasNext(); ) {
        out.print(((Literal) j.next()).getString() + ", ");
      }
      out.print("] ");
      out.println();
    }
  }
}
 
开发者ID:apache,项目名称:incubator-sdap-mudrod,代码行数:27,代码来源:LocalOntology.java


示例2: renderClassDescription

import org.apache.jena.ontology.OntClass; //导入依赖的package包/类
public static void renderClassDescription(PrintStream out, OntClass c, int depth) {
  indent(out, depth);

  if (c.isRestriction()) {
    renderRestriction(out, (Restriction) c.as(Restriction.class));
  } else {
    if (!c.isAnon()) {
      out.print("Class ");
      renderURI(out, c.getModel(), c.getURI());

      out.print(c.getLocalName());

      out.print(" [");
      for (Iterator<?> i = c.listLabels(null); i.hasNext(); ) {
        out.print(((Literal) i.next()).getString() + ", ");
      }
      out.print("] ");
    } else {
      renderAnonymous(out, c, "class");
    }
  }
}
 
开发者ID:apache,项目名称:incubator-sdap-mudrod,代码行数:23,代码来源:LocalOntology.java


示例3: processSingle

import org.apache.jena.ontology.OntClass; //导入依赖的package包/类
private void processSingle(OntModel m) {
  for (Iterator<?> i = m.listClasses(); i.hasNext(); ) {
    OntClass c = (OntClass) i.next();
    try {
      // too confusing to list all the restrictions as root classes 
      if (c.isAnon()) {
        continue;
      }

      if (c.hasSuperClass(m.getProfile().THING(), true) || c.getCardinality(m.getProfile().SUB_CLASS_OF()) == 0) {
        // this class is directly descended from Thing
        roots.add(c);
      }
    } catch (Exception e) {
      Log.error("Error during extraction or root Classes from Ontology Model: ", e);
    }
  }
}
 
开发者ID:apache,项目名称:incubator-sdap-mudrod,代码行数:19,代码来源:OwlParser.java


示例4: createCardinalityRestriction

import org.apache.jena.ontology.OntClass; //导入依赖的package包/类
public OntClass createCardinalityRestriction(OntProperty p,
		int cardinality) {

	/*
	 * NOTE: the create(Min|Max)CardinalityRestriction(...) methods from
	 * Jena - or the turtle serialization - encodes the cardinality as an
	 * xsd:int, which should be an xsd:nonNegativeInteger according to
	 * https://www.w3.org/TR/owl2-mapping-to-rdf/
	 * 
	 * That's why we create and set the typed literal that represents the
	 * cardinality ourselves.
	 */

	OntClass restriction = this.ontmodel.createCardinalityRestriction(null,
			p, cardinality);
	restriction.removeAll(OWL.cardinality);
	Literal cardAsNonNegativeInteger = ontmodel.createTypedLiteral(
			cardinality,
			"http://www.w3.org/2001/XMLSchema#nonNegativeInteger");
	restriction.addLiteral(OWL.cardinality, cardAsNonNegativeInteger);
	return restriction;
}
 
开发者ID:ShapeChange,项目名称:ShapeChange,代码行数:23,代码来源:OntologyModel.java


示例5: createMinCardinalityRestriction

import org.apache.jena.ontology.OntClass; //导入依赖的package包/类
public OntClass createMinCardinalityRestriction(OntProperty p,
		int cardinality) {

	/*
	 * NOTE: the create(Min|Max)CardinalityRestriction(...) methods from
	 * Jena - or the turtle serialization - encodes the cardinality as an
	 * xsd:int, which should be an xsd:nonNegativeInteger according to
	 * https://www.w3.org/TR/owl2-mapping-to-rdf/
	 * 
	 * That's why we create and set the typed literal that represents the
	 * cardinality ourselves.
	 */

	OntClass restriction = this.ontmodel
			.createMinCardinalityRestriction(null, p, cardinality);
	restriction.removeAll(OWL.minCardinality);
	Literal cardAsNonNegativeInteger = ontmodel.createTypedLiteral(
			cardinality,
			"http://www.w3.org/2001/XMLSchema#nonNegativeInteger");
	restriction.addLiteral(OWL.minCardinality, cardAsNonNegativeInteger);
	return restriction;
}
 
开发者ID:ShapeChange,项目名称:ShapeChange,代码行数:23,代码来源:OntologyModel.java


示例6: createMaxCardinalityRestriction

import org.apache.jena.ontology.OntClass; //导入依赖的package包/类
public OntClass createMaxCardinalityRestriction(OntProperty p,
		int cardinality) {

	/*
	 * NOTE: the create(Min|Max)CardinalityRestriction(...) methods from
	 * Jena - or the turtle serialization - encodes the cardinality as an
	 * xsd:int, which should be an xsd:nonNegativeInteger according to
	 * https://www.w3.org/TR/owl2-mapping-to-rdf/
	 * 
	 * That's why we create and set the typed literal that represents the
	 * cardinality ourselves.
	 */

	OntClass restriction = this.ontmodel
			.createMaxCardinalityRestriction(null, p, cardinality);
	restriction.removeAll(OWL.maxCardinality);
	Literal cardAsNonNegativeInteger = ontmodel.createTypedLiteral(
			cardinality,
			"http://www.w3.org/2001/XMLSchema#nonNegativeInteger");
	restriction.addLiteral(OWL.maxCardinality, cardAsNonNegativeInteger);
	return restriction;
}
 
开发者ID:ShapeChange,项目名称:ShapeChange,代码行数:23,代码来源:OntologyModel.java


示例7: mapAndAddSuperClass

import org.apache.jena.ontology.OntClass; //导入依赖的package包/类
private void mapAndAddSuperClass(ClassInfo ci, OntClass c,
		ClassInfo supertype) {

	Resource mappedResource = map(supertype);

	if (mappedResource == null) {
		MessageContext mc = result.addError(this, 6, supertype.name(),
				ci.name());
		if (mc != null) {
			mc.addDetail(this, 10000, ci.fullName());
		}

	} else {
		c.addSuperClass(mappedResource);
	}
}
 
开发者ID:ShapeChange,项目名称:ShapeChange,代码行数:17,代码来源:OntologyModel.java


示例8: addAllValuesFrom

import org.apache.jena.ontology.OntClass; //导入依赖的package包/类
/**
 * @param cls
 *            class for which a all-values-from restriction is created
 * @param pi
 *            property
 * @param p
 *            ontology representation of the property
 */
protected void addAllValuesFrom(OntClass cls, PropertyInfo pi, Property p) {

	if (pi.matches(
			OWLISO19150.RULE_OWL_PROP_RANGE_LOCAL_UNIVERSAL_QUANTIFICATION)) {

		Resource range = this.rangeByPropertyInfo.get(pi);

		if (range != null) {

			OntClass restriction = ontmodel
					.createAllValuesFromRestriction(null, p, range);
			cls.addSuperClass(restriction);

		} else {
			/*
			 * The restriction is not created because the range is unknown
			 */
			MessageContext mc = result.addWarning(this, 35, pi.name());
			if (mc != null) {
				mc.addDetail(this, 10001, pi.fullName());
			}
		}
	}
}
 
开发者ID:ShapeChange,项目名称:ShapeChange,代码行数:33,代码来源:OntologyModel.java


示例9: mapClass

import org.apache.jena.ontology.OntClass; //导入依赖的package包/类
/**
 * Creates an ontology class (in the internal {@link #refmodel}), with
 * namespace identified by looking up the prefix of the QName in the
 * configuration of namespaces. Also creates an import of that namespace.
 * 
 * @param qname
 *            identifies a class
 * @return ontology class identified by the qname
 */
private Resource mapClass(String qname) {

	String[] qnamePars = qname.split(":",2);
	String prefix = qnamePars[0];
	String resourceName = qnamePars[1];

	// identify rdf namespace based upon prefix and standard namespaces
	String rdfNs = config.fullNamespace(prefix);
	String location = config.locationOfNamespace(rdfNs);

	String uri = rdfNs + resourceName;

	OntClass c = refmodel.getOntClass(uri);
	if (c == null)
		c = refmodel.createClass(uri);

	// also add import for the namespace
	addImport(rdfNs, location);

	// return correct element definition
	return c;
}
 
开发者ID:ShapeChange,项目名称:ShapeChange,代码行数:32,代码来源:OntologyModel.java


示例10: map

import org.apache.jena.ontology.OntClass; //导入依赖的package包/类
@Override
public void map(List<DIF> pojoList, Properties props) {
  // create the base model
  OntModel ontModel = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
  ontModel.setNsPrefix("dif_v9.8.2", MUDROD_GCMD_DIF_9_8_2);
  ontModel.setNsPrefix("geo", "http://www.opengis.net/ont/geosparql#");
  ontModel.read(SWEET_REPR_DATA_PRODUCT, null, "TURTLE");

  // get the https://sweetontology.net/reprDataProduct/Dataset class reference
  Resource dataset = ontModel.getResource(SWEET_REPR_DATA_PRODUCT_NS + "Dataset");
  // create the https://sweetontology.net/reprDataProduct/PODAACDataset class
  // reference
  OntClass podaacDataset = ontModel.createClass(PODAAC_DATASET + "PODAACDataset");
  // make PODAACDataset a subclass of Dataset
  podaacDataset.addSuperClass(dataset);
  // create an individual for each DIF POJO
  for (DIF dif : pojoList) {
    Individual gcmdDif = podaacDataset.createIndividual(PODAAC_DATASET + dif.getEntryID());
    buildIndividual(ontModel, dif, gcmdDif);
  }
  writeOntologyModel(ontModel, props);
}
 
开发者ID:ESIPFed,项目名称:eskg,代码行数:23,代码来源:PODAACOntologyMapper.java


示例11: hasSuperTemplate

import org.apache.jena.ontology.OntClass; //导入依赖的package包/类
@Override
   public final boolean hasSuperTemplate(Template superTemplate)
   {
if (superTemplate == null) throw new IllegalArgumentException("Template cannot be null");
       
       ExtendedIterator<OntClass> it = listSuperClasses(false);
       try
       {
           while (it.hasNext())
           {
               OntClass nextClass = it.next();
               if (nextClass.canAs(Template.class))
               {
                   Template nextTemplate = nextClass.as(Template.class);
                   if (nextTemplate.equals(superTemplate) || nextTemplate.hasSuperTemplate(superTemplate))
                       return true;
               }
           }
       }
       finally
       {
           it.close();
       }
       
       return false;
   }
 
开发者ID:AtomGraph,项目名称:Processor,代码行数:27,代码来源:TemplateImpl.java


示例12: process

import org.apache.jena.ontology.OntClass; //导入依赖的package包/类
public Resource process(Resource resource)
{
    // add UUID as dh:slug value to instances of dh:Container and dh:Item, if they don't have one
    // unlike using STRUUID() in dh:DocumentConstructor, we can cache pages without worrying about reusing slugs
    if (!resource.hasProperty(DH.slug))
    {
        Statement typeStmt = resource.getProperty(RDF.type);
        if (typeStmt != null && typeStmt.getObject().isURIResource())
        {
            OntClass ontClass = getOntology().getOntModel().getOntClass(typeStmt.getResource().getURI());
            if (ontClass != null)
            {
                // cannot use ontClass.hasSuperClass() here as it does not traverse the chain
                Set<Resource> superClasses = JenaUtil.getAllSuperClasses(ontClass);
                if (superClasses.contains(DH.Container) || superClasses.contains(DH.Item))
                    resource.addLiteral(DH.slug, UUID.randomUUID().toString());
            }
        }
    }

    return resource;
}
 
开发者ID:AtomGraph,项目名称:Processor,代码行数:23,代码来源:SkolemizingModelProvider.java


示例13: TurtleInputPanel

import org.apache.jena.ontology.OntClass; //导入依赖的package包/类
public TurtleInputPanel(OntClass clazz) {
	super(new BorderLayout());
	this.clazz = clazz;

	add(new JScrollPane(turtleTextArea), CENTER);

	turtleTextArea.setText("<#changeme> a <" + clazz.getURI() + ">\n\n\n.");

	JPanel buttonPanel = new JPanel();
	buttonPanel.setLayout(new BorderLayout());
	JButton validateButton = new DeselectingButton(new AbstractAction(
			"Validate") {
		@Override
		public void actionPerformed(ActionEvent arg0) {
			getContentAsModel();
		}
	});
	buttonPanel.add(errors, CENTER);
	errors.setOpaque(false);
	buttonPanel.add(validateButton, EAST);
	add(buttonPanel, SOUTH);
}
 
开发者ID:apache,项目名称:incubator-taverna-plugin-component,代码行数:23,代码来源:TurtleInputPanel.java


示例14: parse

import org.apache.jena.ontology.OntClass; //导入依赖的package包/类
/**
 * Parse OWL ontology files using Apache Jena
 */
@Override
public void parse(Ontology ont, OntModel m) {
  this.ont = ont;
  for (Iterator<OntClass> i = rootClasses(m); i.hasNext(); ) {
    OntClass c = i.next();

    //dont deal with anonymous classes
    if (c.isAnon()) {
      continue;
    }

    parseClass(c, new ArrayList<>(), 0);
  }
}
 
开发者ID:apache,项目名称:incubator-sdap-mudrod,代码行数:18,代码来源:OwlParser.java


示例15: rootClasses

import org.apache.jena.ontology.OntClass; //导入依赖的package包/类
/**
 * Parses out all root classes of the given 
 * {@link org.apache.jena.ontology.OntModel}
 * @param m the {@link org.apache.jena.ontology.OntModel} we wish to obtain 
 * all root classes for.
 * @return an {@link java.util.Iterator} of {@link org.apache.jena.ontology.OntClass}
 * elements representing all root classes.
 */
@Override
public Iterator<OntClass> rootClasses(OntModel m) {
  Iterator<?> i = m.listClasses();
  if (i.hasNext() && i.next() instanceof OntClass) {
    //assume ontology has root classes
    processSingle(m);
  } else {
    //check for presence of aggregate/collection ontologies such as sweetAll.owl
    processCollection(m);
  }

  return roots.iterator();
}
 
开发者ID:apache,项目名称:incubator-sdap-mudrod,代码行数:22,代码来源:OwlParser.java


示例16: createQCardinalityRestriction

import org.apache.jena.ontology.OntClass; //导入依赖的package包/类
public OntClass createQCardinalityRestriction(OntProperty p,
		int cardinality, Resource range) {
	/*
	 * NOTE: We cannot use the create(Min|Max)CardinalityQRestriction(...)
	 * methods from the Jena API, because they throw the following
	 * exception: org.apache.jena.ontology.ProfileException: Attempted to
	 * use language construct CARDINALITY_Q that is not supported in the
	 * current language profile: OWL Full
	 * 
	 * So, we use a workaround to create the qualified cardinality
	 * restriction. For further details, see
	 * http://stackoverflow.com/questions/20562107/how-to-add-qualified-
	 * cardinality-in-jena
	 */

	OntClass restriction = this.ontmodel.createCardinalityRestriction(null,
			p, cardinality);
	restriction.removeAll(OWL.cardinality);
	Literal cardAsNonNegativeInteger = ontmodel.createTypedLiteral(
			cardinality,
			"http://www.w3.org/2001/XMLSchema#nonNegativeInteger");
	restriction.addLiteral(OWL2.qualifiedCardinality,
			cardAsNonNegativeInteger);
	restriction.addProperty(OWL2.onClass, range);

	return restriction;
}
 
开发者ID:ShapeChange,项目名称:ShapeChange,代码行数:28,代码来源:OntologyModel.java


示例17: createQMinCardinalityRestriction

import org.apache.jena.ontology.OntClass; //导入依赖的package包/类
public OntClass createQMinCardinalityRestriction(OntProperty p,
		int cardinality, Resource range) {
	/*
	 * NOTE: We cannot use the create(Min|Max)CardinalityQRestriction(...)
	 * methods from the Jena API, because they throw the following
	 * exception: org.apache.jena.ontology.ProfileException: Attempted to
	 * use language construct CARDINALITY_Q that is not supported in the
	 * current language profile: OWL Full
	 * 
	 * So, we use a workaround to create the qualified cardinality
	 * restriction. For further details, see
	 * http://stackoverflow.com/questions/20562107/how-to-add-qualified-
	 * cardinality-in-jena
	 */

	OntClass restriction = this.ontmodel
			.createMinCardinalityRestriction(null, p, cardinality);
	restriction.removeAll(OWL.minCardinality);
	Literal cardAsNonNegativeInteger = ontmodel.createTypedLiteral(
			cardinality,
			"http://www.w3.org/2001/XMLSchema#nonNegativeInteger");
	restriction.addLiteral(OWL2.minQualifiedCardinality,
			cardAsNonNegativeInteger);
	restriction.addProperty(OWL2.onClass, range);

	return restriction;
}
 
开发者ID:ShapeChange,项目名称:ShapeChange,代码行数:28,代码来源:OntologyModel.java


示例18: createQMaxCardinalityRestriction

import org.apache.jena.ontology.OntClass; //导入依赖的package包/类
public OntClass createQMaxCardinalityRestriction(OntProperty p,
		int cardinality, Resource range) {
	/*
	 * NOTE: We cannot use the create(Min|Max)CardinalityQRestriction(...)
	 * methods from the Jena API, because they throw the following
	 * exception: org.apache.jena.ontology.ProfileException: Attempted to
	 * use language construct CARDINALITY_Q that is not supported in the
	 * current language profile: OWL Full
	 * 
	 * So, we use a workaround to create the qualified cardinality
	 * restriction. For further details, see
	 * http://stackoverflow.com/questions/20562107/how-to-add-qualified-
	 * cardinality-in-jena
	 */

	OntClass restriction = this.ontmodel
			.createMaxCardinalityRestriction(null, p, cardinality);
	restriction.removeAll(OWL.maxCardinality);
	Literal cardAsNonNegativeInteger = ontmodel.createTypedLiteral(
			cardinality,
			"http://www.w3.org/2001/XMLSchema#nonNegativeInteger");
	restriction.addLiteral(OWL2.maxQualifiedCardinality,
			cardAsNonNegativeInteger);
	restriction.addProperty(OWL2.onClass, range);

	return restriction;
}
 
开发者ID:ShapeChange,项目名称:ShapeChange,代码行数:28,代码来源:OntologyModel.java


示例19: addClassDefinition

import org.apache.jena.ontology.OntClass; //导入依赖的package包/类
public OntClass addClassDefinition(ClassInfo ci) {

		if (finalized) {
			this.result.addWarning(this, 3, ci.name());
			return null;
		}

		// create the Class <OWL>
		OntClass c = ontmodel
				.createClass(computeReference(getPrefix(), normalizedName(ci)));

		this.ontClassByClassInfo.put(ci, c);
		this.resourceByClassInfo.put(ci, c);

		applyDescriptorTargets(c, ci, DescriptorTarget.AppliesTo.CLASS);

		if (ci.isAbstract()
				&& ci.matches(OWLISO19150.RULE_OWL_CLS_19150_2_ISABSTRACT)) {
			this.ontmodel.setNsPrefix(OWLISO19150.PREFIX_ISO_19150_2,
					OWLISO19150.RDF_NS_ISO_19150_2);
			c.addLiteral(ISO19150_2.isAbstract,
					ontmodel.createTypedLiteral(true));
		}

		addCustomSubClassOf(c, ci);
		addConstraintDeclarations(c, ci);

		// NOTE: properties are created once all classes have been created

		return c;
	}
 
开发者ID:ShapeChange,项目名称:ShapeChange,代码行数:32,代码来源:OntologyModel.java


示例20: addSuperParameters

import org.apache.jena.ontology.OntClass; //导入依赖的package包/类
protected Map<Property, Parameter> addSuperParameters(Template template, Map<Property, Parameter> args)
{
    if (template == null) throw new IllegalArgumentException("Template Set cannot be null");        
    if (args == null) throw new IllegalArgumentException("Parameter Map cannot be null");        
    
    ExtendedIterator<OntClass> superIt = template.listSuperClasses();
    try
    {
        while (superIt.hasNext())
        {
            OntClass superClass = superIt.next();
            if (superClass.canAs(Template.class))
            {
                Template superTemplate = superClass.as(Template.class);
                Map<Property, Parameter> superArgs = superTemplate.getLocalParameters();
                Iterator<Entry<Property, Parameter>> entryIt = superArgs.entrySet().iterator();
                while (entryIt.hasNext())
                {
                    Entry<Property, Parameter> entry = entryIt.next();
                    args.putIfAbsent(entry.getKey(), entry.getValue()); // reject Parameters for existing predicates
                }
                
                addSuperParameters(superTemplate, args);  // recursion to super class
            }
        }
    }
    finally
    {
        superIt.close();
    }

    return args;
}
 
开发者ID:AtomGraph,项目名称:Processor,代码行数:34,代码来源:TemplateImpl.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java BaseHeaderProto类代码示例发布时间:2022-05-22
下一篇:
Java Logger类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap