com.hp.hpl.jena.query.ResultSet.getResultVars()方法的使用及代码示例

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

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

ResultSet.getResultVars介绍

[英]Get the variable names for the projection. Not all query solutions from a result have every variable defined.
[中]获取投影的变量名。并非结果中的所有查询解决方案都定义了每个变量。

代码示例

代码示例来源:origin: fr.inria.eventcloud/eventcloud-api

/**
 * {@inheritDoc}
 */
@Override
public List<String> getResultVars() {
  return super.object.getResultVars();
}

代码示例来源:origin: spaziocodice/SolRDF

@Override
public List<String> getResultVars() {
  return resultSet.getResultVars();
}

代码示例来源:origin: com.github.ansell.pellet/pellet-query

/**
 * {@inheritDoc}
 */
public List<String> getResultVars() {
  return results.getResultVars();
}

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

@Override
public List<String> getResultVars() {
  return this.results.getResultVars();
}

代码示例来源:origin: spaziocodice/SolRDF

@Override
public List<String> getResultVars() {
  return resultset.getResultVars();
}

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

static private boolean compareHeader(ResultSet rs1, ResultSet rs2)
{
  if ( rs1 == null && rs2 == null ) return true ;
  if ( rs1 == null ) return false ;
  if ( rs2 == null ) return false ;
  Set<String> names1 = new HashSet<String>(rs1.getResultVars()) ;
  Set<String> names2 = new HashSet<String>(rs2.getResultVars()) ;
  return names1.equals(names2) ;
}

代码示例来源:origin: org.apache.clerezza/rdf.jena.sparql

public ResultSetWrapper(final ResultSet jenaResultSet) {
  final List<QuerySolution> solutions = new ArrayList<QuerySolution>();
  while (jenaResultSet.hasNext()) {
    solutions.add(jenaResultSet.nextSolution());
  }
  solutionsIter = solutions.iterator();
  resultVars = jenaResultSet.getResultVars();
}

代码示例来源:origin: com.github.ansell.pellet/pellet-query

@SuppressWarnings("unchecked")
public SortedResultSet(ResultSet results, List<SortCondition> sortConditions) {
  resultVars = results.getResultVars();
  
  sortedRows = new ArrayList<Binding>();        
  while( results.hasNext() ) {
    sortedRows.add( results.nextBinding() );
  }
  
  BindingComparator cmp = new BindingComparator( sortConditions );
  Collections.sort( sortedRows, cmp );
  
  iterator = sortedRows.iterator();
  row = 0;
}

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

/** Create an in-memory result set from an array of 
 * ResulSets. It is assumed that all the ResultSets 
 * from the array have the same variables.
 * 
 * @param sets the ResultSet objects to concatenate.
 */

public ResultSetMem(ResultSet... sets) 
{
  varNames = sets[0].getResultVars();
  
  for (ResultSet rs : sets) 
  {
    if ( !varNames.equals(rs.getResultVars()) )
      throw new ResultSetException("ResultSet must have the same variables.") ;
    if (rs instanceof ResultSetMem)
      rows.addAll(((ResultSetMem) rs).rows);
    else 
      while (rs.hasNext()) rows.add(rs.nextBinding());
  }
  reset();
}

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

private SortedResultSet(ResultSet rs, Comparator<Binding> comparator)
{
  model = rs.getResourceModel() ;
  // Put straight into a sorted structure 
  SortedSet<Binding> sorted = new TreeSet<Binding>(comparator) ;
  
  for ( ; rs.hasNext() ; )
  {
    Binding b = rs.nextBinding() ;
    sorted.add(b) ;
  }
    
  qIter = new QueryIterPlainWrapper(sorted.iterator()) ;
  resultVars = rs.getResultVars() ;
  //resultSet = new ResultSetStream(rs.getResultVars(), null, qIter) ;
}

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

private SortedResultSet(ResultSet rs, Comparator<Binding> comparator)
{
  model = rs.getResourceModel() ;
  // Put straight into a sorted structure 
  SortedSet<Binding> sorted = new TreeSet<Binding>(comparator) ;
  
  for ( ; rs.hasNext() ; )
  {
    Binding b = rs.nextBinding() ;
    sorted.add(b) ;
  }
    
  qIter = new QueryIterPlainWrapper(sorted.iterator()) ;
  resultVars = rs.getResultVars() ;
  //resultSet = new ResultSetStream(rs.getResultVars(), null, qIter) ;
}

代码示例来源:origin: paulhoule/infovore

public static Map<RDFNode,RDFNode> fetchMap(Dataset m,Query query,QuerySolution bindings) throws Exception {
  QueryExecution qe=QueryExecutionFactory.create(query,m);        
  try {
    ResultSet results=qe.execSelect();
    Map<RDFNode,RDFNode> map=Maps.newHashMap();
    List<String> vars=results.getResultVars();
    while(results.hasNext()) {
      QuerySolution row=results.nextSolution();
      map.put(row.get(vars.get(0)),row.get(vars.get(1)));
    }
    return map;
  } finally { qe.close(); }
}

代码示例来源:origin: org.wso2.carbon.data/org.wso2.carbon.dataservices.core

private DataEntry getDataEntryFromRS(ResultSet rs) {
  DataEntry dataEntry = new DataEntry();
  QuerySolution soln = rs.nextSolution();
  String colName, value;
  boolean useColumnNumbers = this.isUsingColumnNumbers();
  /* for each column get the colName and colValue and add to the data entry */
  for (int i = 0; i < rs.getResultVars().size(); i++) {
    colName = rs.getResultVars().get(i);
    RDFNode node = soln.get(colName) ;              
    if (node.isLiteral()) {
      value = convertRSToString(soln, colName);
    } else {
      value = soln.getResource(colName).getURI();
    }            
    dataEntry.addValue(useColumnNumbers ? Integer.toString(i + 1) : 
      colName, new ParamValue(value));
  }
  return dataEntry;
}

代码示例来源:origin: org.wso2.carbon.data/org.wso2.carbon.dataservices.core

public DataEntry getDataEntryFromRS(ResultSet rs) {
  DataEntry dataEntry = new DataEntry();
  QuerySolution soln = rs.nextSolution();
  String colName, value;
  boolean useColumnNumbers = this.isUsingColumnNumbers();
  /* for each column get the colName and colValue and add to the data entry */
  for (int i = 0; i < rs.getResultVars().size(); i++) {
    colName = rs.getResultVars().get(i);
    RDFNode node = soln.get(colName) ;              
    if (node.isLiteral()) {
      value = convertRSToString(soln, colName);
    } else {
      value = soln.getResource(colName).getURI();
    }            
    dataEntry.addValue(useColumnNumbers ? Integer.toString(i + 1) : 
      colName, new ParamValue(value));
  }
  return dataEntry;
}

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

private void doVars(ResultSet rs)
{
  // On one line.
  out.print(quoteName(dfVars)+": [ ") ;
  if ( multiLineVarNames ) out.println() ;
  out.incIndent() ;
  for (Iterator<String> iter = rs.getResultVars().iterator() ; iter.hasNext() ; )
  {
    String varname = iter.next() ;
    out.print("\""+varname+"\"") ;
    if ( multiLineVarNames ) out.println() ;
    if ( iter.hasNext() )
      out.print(" , ") ;
  }
  out.println(" ]") ;
  out.decIndent() ;
}

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

private void doVars(ResultSet rs)
{
  // On one line.
  out.print(quoteName(kVars)+": [ ") ;
  if ( multiLineVarNames ) out.println() ;
  out.incIndent() ;
  for (Iterator<String> iter = rs.getResultVars().iterator() ; iter.hasNext() ; )
  {
    String varname = iter.next() ;
    out.print("\""+varname+"\"") ;
    if ( multiLineVarNames ) out.println() ;
    if ( iter.hasNext() )
      out.print(" , ") ;
  }
  out.println(" ]") ;
  out.decIndent() ;
}

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

/** Output a result set in BIO format */
public static void outputAsBIO(OutputStream out, ResultSet results)
{
  List<Var> vars = Var.varList(results.getResultVars()) ;
  
  BindingOutputStream bout = new BindingOutputStream(out, vars) ;
  for ( ; results.hasNext() ; )
  {
    Binding b = BindingUtils.asBinding(results.next()) ;
    bout.write(b) ;
  }
  bout.flush() ;
}

代码示例来源:origin: net.exogeni.orca/ndl

@SuppressWarnings("static-access")
public void testGetLayer() {
  System.out.println("--------GetLayer-------\n");
  String uri = "http://geni-orca.renci.org/owl/ben-dtn.rdf#Duke/Infinera/DTN/fB/1/ocgB/1";
  System.out.println(ontProcessor.getOntModel().getResource(uri).getLocalName());
  ResultSet results = ontProcessor.getLayer(ontProcessor.getOntModel(), uri);
  String layerName = null;
  String varName = (String) results.getResultVars().get(0);
  while (results.hasNext()) {
    layerName = results.nextSolution().getResource(varName).getLocalName();
    System.out.println(layerName);
  }
  assertTrue(layerName != null);
}

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

public void apply()
{
  proc.start(rs) ;
  for ( ; rs.hasNext() ; )
  {
    QuerySolution qs = rs.next() ;
    proc.start(qs) ;
    for ( String varName : rs.getResultVars()  )
    {
      RDFNode node = qs.get(varName) ;
      // node may be null
      proc.binding(varName, node) ;
    }
    proc.finish(qs) ;
  }
  proc.finish(rs) ;
}

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

public void apply()
{
  proc.start(rs) ;
  for ( ; rs.hasNext() ; )
  {
    QuerySolution qs = rs.next() ;
    proc.start(qs) ;
    for ( String varName : rs.getResultVars()  )
    {
      RDFNode node = qs.get(varName) ;
      // node may be null
      proc.binding(varName, node) ;
    }
    proc.finish(qs) ;
  }
  proc.finish(rs) ;
}

相关文章