本文整理了Java中com.hp.hpl.jena.query.ResultSet.nextBinding
方法的一些代码示例,展示了ResultSet.nextBinding
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ResultSet.nextBinding
方法的具体详情如下:
包路径:com.hp.hpl.jena.query.ResultSet
类名称:ResultSet
方法名:nextBinding
[英]Move to the next binding (low level)
[中]移动到下一个绑定(低级别)
代码示例来源:origin: com.github.ansell.pellet/pellet-query
/**
* {@inheritDoc}
*/
public Binding nextBinding() {
row++;
return results.nextBinding();
}
代码示例来源:origin: fr.inria.eventcloud/eventcloud-api
/**
* {@inheritDoc}
*/
@Override
public Binding nextBinding() {
return super.object.nextBinding();
}
代码示例来源:origin: spaziocodice/SolRDF
@Override
public Binding nextBinding() {
return resultSet.nextBinding();
}
代码示例来源:origin: com.hp.hpl.jena/arq
@Override
protected Binding moveToNextBinding() { return resultSet.nextBinding() ; }
代码示例来源:origin: spaziocodice/SolRDF
@Override
public Binding nextBinding() {
return resultset.nextBinding();
}
代码示例来源:origin: org.apache.clerezza.ext/org.apache.jena.jena-arq
@Override
protected Binding moveToNextBinding() { return resultSet.nextBinding() ; }
代码示例来源:origin: org.apache.clerezza.ext/org.apache.jena.jena-arq
@Override
public Binding peekBinding() {
if (this.hasPeeked()) {
return this.peeked;
} else if (this.canPeek()) {
this.peeked = this.results.nextBinding();
return this.peeked;
} else {
throw new NoSuchElementException();
}
}
代码示例来源: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: 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: 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: apache/stanbol
public void debug(){
String entityVar = "s";
String fieldVar = "p";
String valueVar = "o";
StringBuilder qb = new StringBuilder();
qb.append(String.format("SELECT ?%s ?%s ?%s \n",
entityVar,fieldVar,valueVar)); //for the select
qb.append("{ \n");
qb.append(String.format(" ?%s ?%s ?%s . \n",
entityVar,fieldVar,valueVar)); //for the where
qb.append("} \n");
log.debug("EntityDataIterator Query: \n"+qb.toString());
Query q = QueryFactory.create(qb.toString(), Syntax.syntaxARQ);
ResultSet rs = QueryExecutionFactory.create(q, indexingDataset.toDataset()).execSelect();
Var s = Var.alloc(entityVar);
Var p = Var.alloc(fieldVar);
Var o = Var.alloc(valueVar);
while (rs.hasNext()){
Binding b = rs.nextBinding();
log.debug("{} {} {}",new Object[]{b.get(s),b.get(p),b.get(o)});
}
}
代码示例来源:origin: org.apache.stanbol/org.apache.stanbol.entityhub.indexing.source.jenatdb
public void debug(){
String entityVar = "s";
String fieldVar = "p";
String valueVar = "o";
StringBuilder qb = new StringBuilder();
qb.append(String.format("SELECT ?%s ?%s ?%s \n",
entityVar,fieldVar,valueVar)); //for the select
qb.append("{ \n");
qb.append(String.format(" ?%s ?%s ?%s . \n",
entityVar,fieldVar,valueVar)); //for the where
qb.append("} \n");
log.debug("EntityDataIterator Query: \n"+qb.toString());
Query q = QueryFactory.create(qb.toString(), Syntax.syntaxARQ);
ResultSet rs = QueryExecutionFactory.create(q, indexingDataset.toDataset()).execSelect();
Var s = Var.alloc(entityVar);
Var p = Var.alloc(fieldVar);
Var o = Var.alloc(valueVar);
while (rs.hasNext()){
Binding b = rs.nextBinding();
log.debug("{} {} {}",new Object[]{b.get(s),b.get(p),b.get(o)});
}
}
代码示例来源:origin: com.hp.hpl.jena/arq
/** Create an in-memory result set from any ResultSet object.
* If the ResultSet is an in-memory one already, then no
* copying is done - the necessary internal datastructures
* are shared. This operation destroys (uses up) a ResultSet
* object that is not an in memory one.
*/
public ResultSetMem(ResultSet qr)
{
model = qr.getResourceModel() ;
if (qr instanceof ResultSetMem)
{
ResultSetMem qrm = (ResultSetMem) qr;
this.rows = qrm.rows;
this.varNames = qrm.varNames;
}
else
{
varNames = qr.getResultVars();
while (qr.hasNext())
{
Binding rb = qr.nextBinding();
rows.add(rb);
}
}
reset();
}
代码示例来源:origin: org.apache.clerezza.ext/org.apache.jena.jena-arq
/** Create an in-memory result set from any ResultSet object.
* If the ResultSet is an in-memory one already, then no
* copying is done - the necessary internal datastructures
* are shared. This operation destroys (uses up) a ResultSet
* object that is not an in memory one.
*/
public ResultSetMem(ResultSet qr)
{
model = qr.getResourceModel() ;
if (qr instanceof ResultSetMem)
{
ResultSetMem qrm = (ResultSetMem) qr;
this.rows = qrm.rows;
this.varNames = qrm.varNames;
}
else
{
varNames = qr.getResultVars();
while (qr.hasNext())
{
Binding rb = qr.nextBinding();
rows.add(rb);
}
}
reset();
}
代码示例来源:origin: apache/stanbol
private void initFirst(){
if(currentEntity == null && nextEntity == null){ //only for the first call
//consume binding until the first valid entity starts
while(nextEntity == null && resultSet.hasNext()){
Binding firstValid = resultSet.nextBinding();
Node entityNode = firstValid.get(entityVar);
if((entityNode.isURI() && !entityNode.toString().isEmpty()) ||
entityNode.isBlank() && bnodePrefix != null){
//store it temporarily in nextBinding
nextBinding = firstValid;
//store it as next (first) entity
nextEntity = entityNode;
} else {
logIgnoredBnode(log,entityNode,firstValid.get(fieldVar),firstValid.get(valueVar));
}
}
} else {
throw new IllegalStateException("This Mehtod MUST be only used for Initialisation!");
}
}
@Override
代码示例来源:origin: org.apache.stanbol/org.apache.stanbol.entityhub.indexing.source.jenatdb
private void initFirst(){
if(currentEntity == null && nextEntity == null){ //only for the first call
//consume binding until the first valid entity starts
while(nextEntity == null && resultSet.hasNext()){
Binding firstValid = resultSet.nextBinding();
Node entityNode = firstValid.get(entityVar);
if((entityNode.isURI() && !entityNode.toString().isEmpty()) ||
entityNode.isBlank() && bnodePrefix != null){
//store it temporarily in nextBinding
nextBinding = firstValid;
//store it as next (first) entity
nextEntity = entityNode;
} else {
logIgnoredBnode(log,entityNode,firstValid.get(fieldVar),firstValid.get(valueVar));
}
}
} else {
throw new IllegalStateException("This Mehtod MUST be only used for Initialisation!");
}
}
@Override
代码示例来源:origin: com.github.ansell.pellet/pellet-query
/**
* {@inheritDoc}
*/
@SuppressWarnings("unchecked")
public Model execConstruct(Model model) {
ensureQueryType( QueryType.CONSTRUCT );
ResultSet results = exec();
if( results == null ) {
QueryExecutionFactory.create( query, source, initialBinding ).execConstruct( model );
}
else {
model.setNsPrefixes( source.getDefaultModel() );
model.setNsPrefixes( query.getPrefixMapping() );
Set set = new HashSet();
Template template = query.getConstructTemplate();
while( results.hasNext() ) {
Map bNodeMap = new HashMap();
Binding binding = results.nextBinding();
template.subst( set, bNodeMap, binding );
}
for( Iterator iter = set.iterator(); iter.hasNext(); ) {
Triple t = (Triple) iter.next();
Statement stmt = ModelUtils.tripleToStatement( model, t );
if( stmt != null )
model.add( stmt );
}
close();
}
return model;
}
代码示例来源:origin: Quetzal-RDF/quetzal
public SparqlRdfResultReader(String uri) {
this.ds = RDFDataMgr.loadModel(uri);
Query query = QueryFactory.create("ask { ?x a <http://www.w3.org/2001/sw/DataAccess/tests/result-set#ResultSet> . }");
QueryExecution qexec = QueryExecutionFactory.create(query, ds);
boolean isSelectOrAsk = qexec.execAsk();
assert isSelectOrAsk;
query = QueryFactory.create("ask { ?x <http://www.w3.org/2001/sw/DataAccess/tests/result-set#boolean> ?a . }");
qexec = QueryExecutionFactory.create(query, ds);
boolean isAskResult = qexec.execAsk();
assert !isAskResult;
query = QueryFactory.create("select distinct * where { ?x <http://www.w3.org/2001/sw/DataAccess/tests/result-set#resultVariable> ?v . }");
qexec = QueryExecutionFactory.create(query, ds);
com.hp.hpl.jena.query.ResultSet results = qexec.execSelect();
this.vs = HashSetFactory.make();
for (; results.hasNext(); ) {
Binding solution = results.nextBinding();
for(Iterator<Var> vs = solution.vars(); vs.hasNext(); ) {
Var v = vs.next();
if ("v".equals(v.getName())) {
String varName = solution.get(v).getLiteralLexicalForm();
this.vs.add(new Variable(varName));
}
}
}
}
代码示例来源:origin: spaziocodice/SolRDF
if (offset > 0) {
while (resultSet.hasNext() && resultSet.getRowNumber() < offset) {
resultSet.nextBinding();
内容来源于网络,如有侵权,请联系作者删除!