@Override protected Binding moveToNextBinding() { Domain d = graphIter.next() ; Binding b = graphResultsToBinding(binding, d, projectionVars) ; return b ; }
@Override public T next() { T x = i.next(); try { seen.add( x ); } catch (OutOfMemoryError e) { throw e; } return x; }
/** Are there any more acceptable objects. * @return true if there is another acceptable object. */ @Override synchronized public boolean hasNext() { if (current!=null) return true; while ( underlying.hasNext() ) { current = f.accept( underlying.next() ); if (current != null) return true; } current = null; dead = true; return false; }
private Iterator<Node> listTypes() { Set<Node> types = CollectionFactory.createHashedSet(); ClosableIterator<Triple> it = graph.find( null, RDF.type.asNode(), null ); while (it.hasNext()) types.add( it.next().getObject() ); return types.iterator(); }
/** * Internall implementation of all the getPropValue variants. */ private static Node doGetPropValue(ClosableIterator<Triple> it) { Node result = null; if (it.hasNext()) { result = it.next().getObject(); } it.close(); return result; }
/** Answer a human-consumable representation of <code>that</code>. The string <code>prefix</code> will appear near the beginning of the string. Nodes may be prefix-compressed using <code>that</code>'s prefix-mapping. This default implementation will display all the triples exposed by the graph (ie including reification triples if it is Standard). */ public static String toString( String prefix, Graph that ) { PrefixMapping pm = that.getPrefixMapping(); StringBuffer b = new StringBuffer( prefix + " {" ); int count = 0; String gap = ""; ClosableIterator<Triple> it = GraphUtil.findAll( that ); while (it.hasNext() && count < TOSTRING_TRIPLE_LIMIT) { b.append( gap ); gap = "; "; count += 1; b.append( it.next().toString( pm ) ); } if (it.hasNext()) b.append( "..." ); it.close(); b.append( "}" ); return b.toString(); }
private boolean allPropsAreAttr(Resource r) { ClosableIterator<Statement> ss = listProperties(r); Set<Property> seen = new HashSet<Property>(); try { while (ss.hasNext()) { Statement s = ss.next(); if (!canBeAttribute(s, seen)) return false; } } finally { ss.close(); } return true; }
private Node getObject(Node subj, Node pred) { ClosableIterator<Triple> i = graph.find( subj, pred, null ); if( i.hasNext() ) { Triple triple = i.next(); i.close(); return triple.getObject(); } return null; }
@Override public boolean graphBaseContains( Triple t ) { if ( t.isConcrete() ) return triples.contains( t ) ; ClosableIterator<Triple> it = find( t ); try { for ( ; it.hasNext() ; ) { Triple t2 = it.next() ; if ( tripleContained(t, t2) ) return true ; } } finally { it.close(); } return false ; }
@Override protected boolean hasNextBinding() { if ( finished ) return false ; if ( slot != null ) return true ; if ( cancelled ) { graphIter.close() ; finished = true ; return false ; } while(graphIter.hasNext() && slot == null ) { Triple t = graphIter.next() ; slot = mapper(t) ; } if ( slot == null ) finished = true ; return slot != null ; }
@Override protected boolean hasNextBinding() { if ( finished ) return false ; if ( slot != null ) return true ; if ( cancelled ) { graphIter.close() ; finished = true ; return false ; } while(graphIter.hasNext() && slot == null ) { Triple t = graphIter.next() ; slot = mapper(t) ; } if ( slot == null ) finished = true ; return slot != null ; }
@Override public boolean graphBaseContains( Triple t ) { if ( t.isConcrete() ) return triples.contains( t ) ; ClosableIterator<Triple> it = find( t ); try { for ( ; it.hasNext() ; ) { Triple t2 = it.next() ; if ( tripleContained(t, t2) ) return true ; } } finally { it.close(); } return false ; }
/** * Process triples with the given predicate. Predicate can be * {@link Node.ANY} to indicate all triples should be processed. * * @param predicate * Predicate of the triples that will be processed */ protected void processTriples(Node predicate) { ClosableIterator<Triple> i = graph.find( null, predicate, null ); while( i.hasNext() ) { Triple triple = i.next(); processTriple( triple ); } i.close(); }
static public int hashCode(Graph g) { ClosableIterator<Triple> ci = GraphUtil.findAll( g ); int hash = 0; GraphMatcher gm = new GraphMatcher(g); while ( ci.hasNext() ) { Triple t = ci.next(); hash += gm.new AnonStatement(t).myHashCode(null); } return hash; } /**
protected Triple getExpression(Node node) { for( BuiltinTerm expressionPredicate : BuiltinTerm.EXPRESSION_PREDICATES ) { ClosableIterator<Triple> i = graph.find( node, expressionPredicate.getNode(), null ); if( i.hasNext() ) { monitor.incrementProgress(); Triple t = i.next(); i.close(); return t; } } return null; }
@Override public Statement next() { assert this.modelImplJena.getModificationCount() == this.modelModificationCountAtCreationTime; Triple t = (Triple)this.it.next(); return new StatementJena29Impl(this.modelImplJena, t.getSubject(), t.getPredicate(), t .getObject()); }
protected void writePropertiesForSubject(Resource subj, ClosableIterator<Property> iter) { // For each property. for (; iter.hasNext();) { Property property = iter.next(); // Object list writeObjectList(subj, property); if (iter.hasNext()) out.println(" ;"); } iter.close(); }
/** * Process triples with <code>rdf:type</code> predicate and given object. * Type can be {@link Node.ANY} to indicate all type triples should be * processed. * * @param type * the object of <code>rdf:type</code> triples to be processed */ protected void processTypes(Node type) { ClosableIterator<Triple> i = graph.find( null, RDF.type.asNode(), type ); while( i.hasNext() ) { Triple stmt = i.next(); processType( stmt ); } i.close(); }
private void wPropertyEltStar(Resource r) { ClosableIterator<Statement> ss = this.listProperties(r); try { while (ss.hasNext()) { Statement s = ss.next(); wPropertyElt(wtype, s.getPredicate(), s, s.getObject()); } } finally { ss.close(); } }
private void wPropAttrSome(Resource r) { ClosableIterator<Statement> ss = listProperties(r); try { Set<Property> seen = new HashSet<Property>(); while (ss.hasNext()) { Statement s = ss.next(); if (canBeAttribute(s, seen)) { done(s); wPropAttr(s.getPredicate(), s.getObject()); } } } finally { ss.close(); } }