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

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

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

Resource.inModel介绍

[英]Override RDFNode.inModel() to produce a staticly-typed Resource in the given Model.
[中]重写RDFNode。inModel()在给定模型中生成静态类型的资源。

代码示例

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

/**
 * <p>Answer a resource presenting the {@link OntResource} facet, which
 * corresponds to the given resource but attached to this model.</p>
 * @param res An existing resource
 * @return An {@link OntResource} attached to this model that has the same URI
 * or anonID as the given resource
 */
@Override
public OntResource getOntResource( Resource res ) {
  return res.inModel( this ).as( OntResource.class );
}

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

@Override
public Alt getAlt( Resource r )  
{ return r.inModel( this ).as( Alt.class ); }

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

@Override
public Seq getSeq( Resource r )  
{ return r.inModel( this ).as( Seq.class ); }

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

@Override
public Bag getBag( Resource r )  
{ return r.inModel( this ).as( Bag.class ); }

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

public StatementImpl(Resource subject, Property predicate, RDFNode object)
  {
  super( empty );
  this.subject = subject.inModel( model );
  this.predicate = predicate.inModel( model );
  this.object = object.inModel( model );
  }

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

/** Creates new StatementImpl */
public StatementImpl(Resource subject, Property predicate, RDFNode object,
    ModelCom model)
  {
  super( model );
  this.subject = subject.inModel( model );
  this.predicate = predicate.inModel( model );
  this.object = object.inModel( model );
  }

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

/**
  Answer a Resource .equals() to <code>root</code>, but in the expanded
  model.
*/
public static Resource withFullModel( Resource root )
  { return root.inModel( fullModel( root.getModel() ) ); }

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

public APIResultSet(Graph graph, List<Resource> results, boolean isCompleted, boolean enableETags, String detailsQuery, View v) {
  model = new MergedModels( ModelFactory.createModelForGraph( graph ) );
  setUsedPrefixes( model, getResultPrefixes( results ) );
  this.results = results;
  this.isCompleted = isCompleted;
  this.detailsQuery = detailsQuery;
  this.hash = 0;
  this.timestamp = new Date();
  this.enableETags = enableETags;
  this.view = v;
  if (!results.isEmpty()) this.root = results.get(0).inModel(model.merged);
}

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

public void addBindings( Model toScan, Model meta, Resource anExec, CompleteContext cc ) {
  Resource exec = anExec.inModel(meta), page = thisPage.inModel(meta);
  exec.addProperty( RDF.type, API.Execution );
  addVariableBindings( meta, exec );
  cc.include( meta );
  addTermBindings( toScan, meta, exec, cc );
  page.addProperty( API.wasResultOf, exec );
}

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

public void addExecution( Model meta, Resource anExec ) {
  Resource exec = anExec.inModel(meta), page = thisPage.inModel(meta);
  exec.addProperty( RDF.type, API.Execution );
  Resource P = createBNode( meta );
  ELDA.addEldaMetadata( P );
  exec.addProperty( API.processor, P );
  page.addProperty( API.wasResultOf, exec );
}

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

/**
 * Return a {@link Page} object decorating the underlying page resource in
 * the API results model
 * @return A page object
 */
public Page page() {
  return new Page( this, results.getRoot().inModel( this.getModel() ) );
}

代码示例来源:origin: com.googlecode.foresite-toolkit/foresite

public void setResource(Resource resource)
{
  StmtIterator itr = resource.listProperties();
  model.removeAll();
  model.add(itr);
  res = (Resource) resource.inModel(model);
}

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

private Resource completedClone( Resource root, Resource newRoot, Model fragment )
  {
  Model typed = fragment.add( newRoot, RDF.type, JA.Content );
  return newRoot.inModel(  ModelFactory.createUnion( root.getModel(), typed ) );
  }

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

/** 
  External rendering API. e is the XML element representing the result,
  x is the root node, and mm comprises the object and meta data.
*/
public Element addResourceToElement( Element e, Resource x, MergedModels mm ) {
  Resource xInMetaModel = x.inModel( mm.getMetaModel() );
  renderMetadata( e, x, xInMetaModel );
  renderObjectData( e, x, mm.getObjectModel(), xInMetaModel );
  return e;
}

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

protected Resource resourceInModel( String string )
  {
  Model m = ModelTestBase.modelWithStatements( string );
  String firstResourceString = string.substring( 0, string.indexOf( ' ' ) );
  Resource r = ModelTestBase.resource( m, firstResourceString );
  return r.inModel( m );        
  }

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

/**
 * @return The page root resource, but attached only to the metadata model
 */
public RDFNodeWrapper metadataRoot() {
  return new RDFNodeWrapper( new ModelWrapper( metadataModel() ), results.getRoot().inModel( metadataModel() ) );
}

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

/** @return My wrapped node, but restricted to only the results object graph (ie not metadata) */
public RDFNodeWrapper objectResourceWrapped() {
  Resource objResource = this.asResource().inModel( page().pageObjectModel() );
  ModelWrapper mw = new ModelWrapper( page().pageObjectModel() );
  RDFNodeWrapper objResourceWrapper = new RDFNodeWrapper( mw, objResource );
  return objResourceWrapper;
}

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

/**
 * <p>Answer true if the given class is a sub-class of this class.
 * See {@link #listSubClasses( boolean )} for a full explanation of the <em>direct</em>
 * parameter.
 * </p>
 * @param cls A class to test.
 * @param direct If true, only search the classes that are directly adjacent to this
 * class in the class hierarchy.
 * @return True if the given class is a sub-class of this class.
 * @exception OntProfileException If the {@link Profile#SUB_CLASS_OF()} property is not supported in the current language profile.
 */
@Override
public boolean hasSubClass( Resource cls, boolean direct ) {
  if (getModel() instanceof OntModel &&
    (cls.getModel() == null || !(cls.getModel() instanceof OntModel)))
  {
    // could be outside an ontmodel if a constant
    cls = cls.inModel( getModel() );
  }
  return cls.as( OntClass.class ).hasSuperClass( this, direct );
}

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

/**
  Create metadata which describes the available alternative formats
  this page could be presented in.
*/
public void addFormats( Model meta, Set<FormatNameAndType> formats ) {
  List<String> formatNames = getFormatNames( formats );
  Resource page = thisPage.inModel(meta);
  for (FormatNameAndType format: formats) {
    Resource v = resourceForFormat( thisPageAsURI, meta, formatNames, format.name );
    Resource formatNode = createBNode( meta ).addProperty( RDFS.label, format.mediaType );
    page.addProperty( DCTerms.hasFormat, v );
    v.addProperty( DCTerms.isFormatOf, thisPage );
    v.addProperty( DCTerms.format, formatNode );
    v.addProperty( RDFS.label, format.name );
  }
}

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

public void addQueryMetadata( Model meta, Resource anExec, String selectQuery, String viewQuery, Source source, boolean listEndpoint ) {
  Resource EP = meta.createResource( SPARQL.Service );
//
  source.addMetadata( EP ); 
  Resource url = EP.getRequiredProperty( API.sparqlEndpoint ).getResource(); 
  EP.addProperty( SPARQL.url, url );
//
  Resource exec = anExec.inModel(meta);
  if (listEndpoint) {
    Resource sr = meta.createResource( SPARQL.QueryResult );        
    sr.addProperty( SPARQL.query, inValue( meta, selectQuery ) );
    sr.addProperty( SPARQL.endpoint, EP );
    exec.addProperty( API.selectionResult, sr );
  }
//
  Resource vr = meta.createResource( SPARQL.QueryResult );
  vr.addProperty( SPARQL.query, inValue( meta, viewQuery ) ); 
  vr.addProperty( SPARQL.endpoint, EP );
  exec.addProperty( API.viewingResult, vr );
}

相关文章