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

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

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

Resource.getRequiredProperty介绍

[英]Get a property value of this resource.

The model associated with the resource instance is searched for statements whose subject is this resource and whose predicate is p. If such a statement is found, it is returned. If several such statements are found, any one may be returned. If no such statements are found, an exception is thrown.
[中]获取此资源的属性值。
在与资源实例关联的模型中搜索主语为该资源、谓词为p的语句。如果找到这样的语句,则返回该语句。如果发现多个这样的声明,任何一个都可以返回。如果没有找到这样的语句,将抛出异常。

代码示例

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

@Override
public Statement getStatementProperty( Property p )
  {
  return asResource().getRequiredProperty( p );
  }

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

@Override
public Statement getProperty(Property p)  {
  return getResource().getRequiredProperty( p );
}

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

/**
 * Answer true if this option is set to true, either on the command line
 * or in the config model
 *
 * @return boolean
 */
protected boolean isTrue( List<String> cmdLineArgs, Resource confRoot ) {
  if (cmdLineArgs.contains( m_cmdLineForm )) {
    return true;
  }
  if (confRoot.hasProperty( m_prop )) {
    return confRoot.getRequiredProperty( m_prop ).getBoolean();
  }
  return false;
}

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

/**
 * Answer the resource value of the parameter if set, or null otherwise.
 *
 * @return String
 */
protected Resource getResource( List<String> cmdLineArgs, Resource confRoot ) {
  int index = cmdLineArgs.indexOf( m_cmdLineForm );
  if (index >= 0) {
    try {
      return confRoot.getModel().getResource( cmdLineArgs.get( index + 1 ) );
    }
    catch (IndexOutOfBoundsException e) {
      System.err.println( "Value for parameter " + m_cmdLineForm  + " not set! Aborting.");
    }
  }
  if (m_prop != null  &&  confRoot.hasProperty( m_prop )) {
    return confRoot.getRequiredProperty( m_prop ).getResource();
  }
  // not set
  return null;
}

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

/**
 * Return the value of the parameter if set, or null otherwise. Note command line
 * has precedence.
 *
 * @return The argument value as an RDFNode
 */
protected RDFNode getValue( List<String> cmdLineArgs, Resource confRoot ) {
  int index = cmdLineArgs.indexOf( m_cmdLineForm );
  if (index >= 0) {
    try {
      return ResourceFactory.createPlainLiteral( cmdLineArgs.get( index + 1 ) );
    }
    catch (IndexOutOfBoundsException e) {
      throw new SchemagenException( "Value for parameter " + m_cmdLineForm  + " not set! Aborting.", e );
    }
  }
  if (m_prop != null && confRoot != null  &&  confRoot.hasProperty( m_prop )) {
    return confRoot.getRequiredProperty( m_prop ).getObject();
  }
  // not set
  return null;
}

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

/**
 * <p>
 * Helper method for setting the list tail, that assumes we have
 * a resource that is a list.
 * </p>
 * 
 * @param root The resource representing the list cell we're setting the
 * tail of
 * @param tail The new tail for this list, as a resource.
 * @return The old tail, as a resource.
 */
protected static Resource setTailAux( Resource root, Resource tail, Property pTail ) {
  Statement current = root.getRequiredProperty( pTail );
  Resource oldTail = current.getResource();
    
  // out with the old, in with the new
  current.remove();
  root.addProperty( pTail, tail );
    
  return oldTail;
}

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

String name = mapping.getRequiredProperty(LocationMappingVocab.name)
          .getString() ;
String altName = mapping.getRequiredProperty(LocationMappingVocab.altName)
          .getString() ;
addAltEntry(name, altName) ;
String prefix = mapping.getRequiredProperty(LocationMappingVocab.prefix)
          .getString() ;
String altPrefix = mapping.getRequiredProperty(LocationMappingVocab.altPrefix)
          .getString() ;
addAltPrefix(prefix, altPrefix) ;

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

String name = mapping.getRequiredProperty(LocationMappingVocab.name)
          .getString() ;
String altName = mapping.getRequiredProperty(LocationMappingVocab.altName)
          .getString() ;
locMap.addAltEntry(name, altName) ;
String prefix = mapping.getRequiredProperty(LocationMappingVocab.prefix)
          .getString() ;
String altPrefix = mapping.getRequiredProperty(LocationMappingVocab.altPrefix)
          .getString() ;
locMap.addAltPrefix(prefix, altPrefix) ;

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

RDFNode n0 = r0.getRequiredProperty( head ).getObject();
RDFNode n1 = r1.getRequiredProperty( head ).getObject();
  r0 = r0.getRequiredProperty( tail ).getResource();
  r1 = r1.getRequiredProperty( tail ).getResource();

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

/**
 * @return A statement that is suitable for a typed node construction or
 *         null.
 */
private Statement getType(Resource r) {
  Statement rslt;
  try {
    if (r instanceof Statement) {
      rslt = ((Statement) r).getStatementProperty(RDF.type);
      if (rslt == null || (!rslt.getObject().equals(RDF.Statement)))
        error("Statement type problem");
    } else {
      rslt = r.getRequiredProperty(RDF.type);
    }
  } catch (PropertyNotFoundException rdfe) {
    if (r instanceof Statement)
      error("Statement type problem");
    rslt = null;
  }
  if (rslt == null || isOKType(rslt.getObject()) == -1)
    return null;
  return rslt;
}

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

Statement subj = r.getRequiredProperty(RDF.subject);
Statement pred = r.getRequiredProperty(RDF.predicate);
Statement obj = r.getRequiredProperty(RDF.object);
RDFNode nobj = obj.getObject();
Resource rsubj = (Resource) subj.getObject();

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

private void buildRows(Resource root)
{
  // Now the results themselves
  int count = 0 ;
  StmtIterator solnIter = root.listProperties(ResultSetGraphVocab.solution) ;
  for ( ; solnIter.hasNext() ; )
  {
    Resource soln = solnIter.nextStatement().getResource() ;
    count++ ;
    Binding rb = buildBinding(soln) ;
    rows.add(rb) ;
  }
  solnIter.close() ;
  
  if ( root.hasProperty(ResultSetGraphVocab.size))
  {
    try {
      int size = root.getRequiredProperty(ResultSetGraphVocab.size).getInt() ;
      if ( size != count )
        Log.warn(this, "Warning: Declared size = "+size+" : Count = "+count) ;
    } catch (JenaException rdfEx) {}
  }
}

代码示例来源:origin: com.hp.hpl.jena/arq

private void buildRows(Resource root)
{
  // Now the results themselves
  int count = 0 ;
  StmtIterator solnIter = root.listProperties(ResultSetGraphVocab.solution) ;
  for ( ; solnIter.hasNext() ; )
  {
    Resource soln = solnIter.nextStatement().getResource() ;
    count++ ;
    Binding rb = buildBinding(soln) ;
    rows.add(rb) ;
  }
  solnIter.close() ;
  
  if ( root.hasProperty(ResultSetGraphVocab.size))
  {
    try {
      int size = root.getRequiredProperty(ResultSetGraphVocab.size).getInt() ;
      if ( size != count )
        Log.warn(this, "Warning: Declared size = "+size+" : Count = "+count) ;
    } catch (JenaException rdfEx) {}
  }
}

代码示例来源:origin: com.hp.hpl.jena/arq

String var = binding.getRequiredProperty(ResultSetGraphVocab.variable).getString() ;
try {
  RDFNode val = binding.getRequiredProperty(ResultSetGraphVocab.value).getObject() ;
  rb.add(Var.alloc(var), val.asNode()) ;
} catch (PropertyNotFoundException ex)

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

String var = binding.getRequiredProperty(ResultSetGraphVocab.variable).getString() ;
try {
  RDFNode val = binding.getRequiredProperty(ResultSetGraphVocab.value).getObject() ;
  rb.add(Var.alloc(var), val.asNode()) ;
} catch (PropertyNotFoundException ex)

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

l = l.getRequiredProperty( tail ).getResource();
index++;
found = l.hasProperty( head, value );

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

l = l.getRequiredProperty( tail ).getResource();
found = (last && l.hasProperty( tail, nil )) || (!last && (--i == 0));

代码示例来源: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 );
}

相关文章