com.hp.hpl.jena.rdf.model.Resource.canAs()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(4.0k)|赞(0)|评价(0)|浏览(117)

本文整理了Java中com.hp.hpl.jena.rdf.model.Resource.canAs方法的一些代码示例,展示了Resource.canAs的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Resource.canAs方法的具体详情如下:
包路径:com.hp.hpl.jena.rdf.model.Resource
类名称:Resource
方法名:canAs

Resource.canAs介绍

暂无

代码示例

代码示例来源:origin: org.nuxeo.ecm.platform/nuxeo-platform-relations-jena-plugin

/**
 * Gets NXRelations statement list corresponding to the Jena statement list.
 *
 * @param graph the jena graph
 * @param jenaStatements jena statements list
 * @return NXRelations statements list
 */
private List<Statement> getNXRelationsStatements(Model graph,
    List<com.hp.hpl.jena.rdf.model.Statement> jenaStatements) {
  List<Statement> nuxStmts = new ArrayList<Statement>();
  for (com.hp.hpl.jena.rdf.model.Statement jenaStmt : jenaStatements) {
    // NXP-2665: remove reified statements are they're as properties in
    // nuxeo logic
    if (!jenaStmt.getSubject().canAs(ReifiedStatement.class)) {
      nuxStmts.add(getNXRelationsStatement(graph, jenaStmt));
    }
  }
  return nuxStmts;
}

代码示例来源:origin: epimorphics/elda

private static AnyList convertList(Resource tso) {
  if (tso.canAs(RDFList.class)) {
    List<RDFNode> operand = tso.as(RDFList.class).asJavaList();
    Any[] elements = new Any[operand.size()];
    for (int i = 0; i < operand.size(); i += 1) elements[i] = RDFQ.any( operand.get(i) );
    return RDFQ.list( elements );
  } else {
    EldaException.BadSpecification( "Object " + tso + " of " + ELDA_API.textSearchOperand + " must be an RDF list." );
    return /* never */ null;
  }
}

代码示例来源:origin: epimorphics/elda

/**
  Answer this view after modifying it to contain all the property
  chains defined by <code>spec</code>.
*/
public View addViewFromRDFList(Resource spec, ShortnameService sns) {
  cannotUpdateALL();
  if (spec.canAs(RDFList.class)) {
    List<ViewProperty> properties = new ArrayList<>();
    Iterator<RDFNode> list = spec.as(RDFList.class).iterator();
    while(list.hasNext()) {
      properties.add(new ViewProperty.Base(list.next().as(Property.class)));
    }
    chains.add( new PropertyChain( properties ) );
  } else {
    String uri = spec.asResource().getURI();
    Property prop = ResourceFactory.createProperty(uri);
    ViewProperty vp = new ViewProperty.Base(prop);
    chains.add(new PropertyChain(vp));
  }
  if (chains.size() > 0) type = Type.T_CHAINS;
  return this;
}

代码示例来源:origin: org.apache.clerezza.ext/org.apache.jena.jena-core

if (obj.canAs( RDFList.class )) {

代码示例来源:origin: anno4j/anno4j

/**
 * Convert the given Jena Resource into a Sesame Resource
 * @param theRes the jena resource to convert
 * @return the jena resource as a sesame resource
 */
public static org.openrdf.model.Resource asSesameResource(Resource theRes) {
  if (theRes == null) {
    return null;
  }
  else if (theRes.canAs(Property.class)) {
    return asSesameURI(theRes.as(Property.class));
  }
  else {
    return FACTORY.createURI("urn:anno4j:" + theRes.getId().getLabelString());
  }
}

代码示例来源:origin: org.apache.clerezza.ext/org.apache.jena.jena-core

/**
 * <p>Answer the class or datarnage to which all values of the restricted property belong.</p>
 * @return The ontology class of the restricted property values
 * @exception OntProfileException If the {@link Profile#HAS_CLASS_Q()} property is not supported in the current language profile.
 */
@Override
public OntResource getHasClassQ() {
  checkProfile( getProfile().HAS_CLASS_Q(), "HAS_CLASS_Q" );
  Resource r = getProperty( getProfile().HAS_CLASS_Q() ).getResource();
  if (r.canAs( OntClass.class )) {
    return r.as( OntClass.class );
  }
  else if (r.canAs( DataRange.class )) {
    return r.as( DataRange.class );
  }
  else {
    return r.as( OntResource.class );
  }
}

代码示例来源:origin: org.apache.clerezza.ext/org.apache.jena.jena-core

if (r.canAs( OntClass.class )) {
else if (r.canAs( DataRange.class )) {

代码示例来源:origin: org.apache.clerezza.ext/org.apache.jena.jena-core

if (r.canAs( OntClass.class )) {
else if (r.canAs( DataRange.class )) {

代码示例来源:origin: org.apache.juneau/juneau-marshall-rdf

o = new ObjectList(this);
    parseIntoCollection(r.as(Bag.class), (Collection)o, sType, pMeta);
  } else if (r.canAs(RDFList.class)) {
    o = new ObjectList(this);
    parseIntoCollection(r.as(RDFList.class), (Collection)o, sType, pMeta);
} else if (isBag(r)) {
  parseIntoCollection(r.as(Bag.class), (Collection)o, sType, pMeta);
} else if (r.canAs(RDFList.class)) {
  parseIntoCollection(r.as(RDFList.class), (Collection)o, sType, pMeta);
} else {

相关文章