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

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

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

ResultSet.nextSolution介绍

[英]Moves onto the next result (legacy - use .next()).
[中]移动到下一个结果(legacy-use.next())。

代码示例

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

/**
 * {@inheritDoc}
 */
@Override
public QuerySolution nextSolution() {
  return super.object.nextSolution();
}

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

/**
 * {@inheritDoc}
 */
public QuerySolution nextSolution() {        
  row++;
  
  return results.nextSolution();
}

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

@Override
public QuerySolution nextSolution() {
  return resultset.nextSolution();
}

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

/**
 * Turn the result set into a java.util.List
 * @param resultSet   The result set
 * @return            List of QuerySolutions
 */
static public List<QuerySolution> toList(ResultSet resultSet)
{
  List<QuerySolution> list = new ArrayList<QuerySolution>() ;
  for ( ; resultSet.hasNext() ; )
  {
    QuerySolution result = 
      resultSet.nextSolution() ;
    list.add(result) ;
  }
  return list ;
}

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

/**
 * Turn the result set into a java.util.List
 * @param resultSet   The result set
 * @return            List of QuerySolutions
 */
static public List<QuerySolution> toList(ResultSet resultSet)
{
  List<QuerySolution> list = new ArrayList<QuerySolution>() ;
  for ( ; resultSet.hasNext() ; )
  {
    QuerySolution result = 
      resultSet.nextSolution() ;
    list.add(result) ;
  }
  return list ;
}

代码示例来源: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: spaziocodice/SolRDF

@Override
public QuerySolution next() {			
  if (resultSet.getRowNumber() >= offset && getRowNumber() < (offset + size)){
    final QuerySolution solution = resultSet.nextSolution();
    rows.add(solution);
    return solution;
  }
  
  throw new IllegalStateException("Invalid iterable state on this ResultSet!");
}

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

/**
 * Extracts a List filled with the binding of selectElement variable for each
 * query solution as RDFNodes (Resources or Literals).
 * Exhausts the result set.  Create a rewindable one to use multiple times. 
 * Suggested by James Howison  
 * @see com.hp.hpl.jena.query.ResultSetFactory   
 */
public static List<RDFNode> resultSetToList(ResultSet rs, String selectElement)
{
  List<RDFNode> items = new ArrayList<RDFNode>() ;
  while (rs.hasNext())
  {
    QuerySolution qs = rs.nextSolution() ;
    RDFNode n = qs.get(selectElement) ;
    items.add(n) ;
  }
  return items ;
}

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

/**
 * Extracts a List filled with the binding of selectElement variable for each
 * query solution as RDFNodes (Resources or Literals).
 * Exhausts the result set.  Create a rewindable one to use multiple times. 
 *   
 * @see com.hp.hpl.jena.query.ResultSetFactory   
 */
public static List<RDFNode> resultSetToList(ResultSet rs, String selectElement)
{
  // feature suggested by James Howison
  List<RDFNode> items = new ArrayList<RDFNode>() ;
  while (rs.hasNext())
  {
    QuerySolution qs = rs.nextSolution() ;
    RDFNode n = qs.get(selectElement) ;
    items.add(n) ;
  }
  return items ;
}

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

/** This operation faithfully walks the results but does nothing with them.
 *  @return The count of the number of solutions. 
 */
public static int consume(ResultSet resultSet)
{
  int count = 0 ;
  for ( ; resultSet.hasNext() ; )
  {
    // Force nodes to be materialized.
    QuerySolution result = resultSet.nextSolution() ;
    for ( Iterator<String> iter = result.varNames() ; iter.hasNext() ; )
    {
      String vn = iter.next();
      RDFNode n = result.get(vn) ;
    }
    count++ ;
  }
  return count ;
}

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

/** This operation faithfully walks the results but does nothing with them.
 *  @return The count of the number of solutions. 
 */
public static int consume(ResultSet resultSet)
{
  int count = 0 ;
  for ( ; resultSet.hasNext() ; )
  {
    // Force nodes to be materialized.
    QuerySolution result = resultSet.nextSolution() ;
    for ( Iterator<String> iter = result.varNames() ; iter.hasNext() ; )
    {
      String vn = iter.next();
      RDFNode n = result.get(vn) ;
    }
    count++ ;
  }
  return count ;
}

代码示例来源:origin: org.smartdeveloperhub.curator/sdh-curator-connector

private List<T> processResults(ResultSet results) {
  List<T> result=Lists.newArrayList();
  for(; results.hasNext();) {
    QuerySolution solution = results.nextSolution();
    B builder = newBuilder();
    solutionParser().
      withSolution(solution).
      withBuilder(builder).
      parse();
    result.add(builder.build());
  }
  return result;
}

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

/** Execute, expecting the result to be one row, one column. 
 * Return that one RDFNode or null
 * Throw excpetion if more than one.
 */
public static RDFNode getOne(QueryExecution qExec, String varname)
{
  try {
    ResultSet rs = qExec.execSelect() ;
    
    if ( ! rs.hasNext() )
      return null ;
    QuerySolution qs = rs.nextSolution() ;
    RDFNode r = qs.get(varname) ;
    if ( rs.hasNext() )
      throw new ARQException("More than one: var ?"+varname) ;
    return r ;
  } finally { qExec.close() ; }
}

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

/** Execute, expecting the result to be one row, one column.  Return that one RDFNode or throw an exception */
public static RDFNode getExactlyOne(QueryExecution qExec, String varname)
{
  try {
    ResultSet rs = qExec.execSelect() ;
    
    if ( ! rs.hasNext() )
      throw new ARQException("Not found: var ?"+varname) ;
    QuerySolution qs = rs.nextSolution() ;
    RDFNode r = qs.get(varname) ;
    if ( rs.hasNext() )
      throw new ARQException("More than one: var ?"+varname) ;
    return r ;
  } finally { qExec.close() ; }
}

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

/** Execute, expecting the result to be one row, one column.  Return that one RDFNode or throw an exception */
public static RDFNode getExactlyOne(QueryExecution qExec, String varname)
{
  try {
    ResultSet rs = qExec.execSelect() ;
    
    if ( ! rs.hasNext() )
      throw new ARQException("Not found: var ?"+varname) ;
    QuerySolution qs = rs.nextSolution() ;
    RDFNode r = qs.get(varname) ;
    if ( rs.hasNext() )
      throw new ARQException("More than one: var ?"+varname) ;
    return r ;
  } finally { qExec.close() ; }
}

代码示例来源: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/sdb

private static List<Pair<String, String>> storesByQuery(String fn)
  {
    Model model = FileManager.get().loadModel(fn) ;
    List<Pair<String, String>> data = new ArrayList<Pair<String, String>>();
    Query query = QueryFactory.create(queryString) ;
    QueryExecution qExec = QueryExecutionFactory.create(query, model) ;
    try {
      ResultSet rs = qExec.execSelect() ;
      
      for ( ; rs.hasNext() ; )
      {
        QuerySolution qs = rs.nextSolution() ;
        String label = qs.getLiteral("label").getLexicalForm() ;
        String desc = qs.getResource("desc").getURI() ;
        data.add(new Pair<String, String>(label, desc)) ;
      }
    } finally { qExec.close() ; }
    return data ;
  }
}

相关文章