/** * Override close method to reclaim the iterator. */ @Override public void close() { if (matchIterator != null) matchIterator.close(); }
/** * Override close method to reclaim the iterator. */ @Override public void close() { if (matchIterator != null) matchIterator.close(); }
@Override public void close() { lazy(); it.close(); }
/** * <p>Answer true if there is at least one inverse property for this property.</p> * @return True if property has an inverse. */ @Override public boolean hasInverse() { ExtendedIterator<OntProperty> i = listInverse(); boolean hasInv = i.hasNext(); i.close(); return hasInv; }
public static long countTriples(Graph graph, Node s, Node p, Node o) { ExtendedIterator<Triple> iter = graph.find(s, p, o) ; try { return Iter.count(iter) ; } finally { iter.close() ; } }
/** @return true iff there's > 0 mappings to this triple */ public static boolean hasTriple(Graph graph, Triple t) { ExtendedIterator<Node> iter = findNodesForTriple(graph, t, false) ; try { return iter.hasNext() ; } finally { iter.close() ; } }
public static void accTriples(Collection<Triple> acc, Graph graph, Node s, Node p, Node o) { ExtendedIterator<Triple> iter = graph.find(s, p, o) ; for ( ; iter.hasNext() ; ) acc.add(iter.next()) ; iter.close() ; }
static void accTriplesOfSubject(Collection<Triple> acc, Graph graph, Node subj) { ExtendedIterator<Triple> iter = graph.find(subj, Node.ANY, Node.ANY); for (; iter.hasNext();) { acc.add(iter.next()); } iter.close(); } }
/** All subjects and objects, no duplicates. */ public static Iterator<Node> allNodes(Graph graph) { Set<Node> x = new HashSet<Node>(1000) ; ExtendedIterator<Triple> iter = graph.find(Node.ANY, Node.ANY, Node.ANY) ; for ( ; iter.hasNext() ; ) { Triple t = iter.next(); x.add(t.getSubject()) ; x.add(t.getObject()) ; } iter.close() ; return x.iterator() ; } }
/** * <p>Answer the property that is the inverse of this property. If no such property is defined, * return null. If more than one inverse is defined, return an abritrary selection.</p> * @return The property that is the inverse of this property, or null. */ @Override public OntProperty getInverse() { ExtendedIterator<OntProperty> i = listInverse(); OntProperty p = i.hasNext() ? i.next() : null; i.close(); return p; }
public static Triple triple1(Graph graph, Node s, Node p, Node o) { ExtendedIterator<Triple> iter = graph.find(s, p, o) ; try { if ( ! iter.hasNext() ) return null ; Triple t = iter.next() ; if ( iter.hasNext() ) return null ; return t ; } finally { iter.close() ; } }
private int inLinks(Node obj) { ExtendedIterator<Triple> iter = graph.find(Node.ANY, Node.ANY, obj) ; int count = 0 ; try { if ( ! iter.hasNext() ) return 0 ; iter.next() ; if ( ! iter.hasNext() ) return 1 ; return 2 ; } finally { iter.close() ; } }
private Node getNode(Node S, Node P) { ExtendedIterator<Triple> it = graph.find(S,P, Node.ANY) ; if ( ! it.hasNext() ) return null ; Triple t = it.next() ; it.close() ; return t.getObject() ; } }
public static void removeAll( Graph g, Node s, Node p, Node o ) { ExtendedIterator<Triple> it = g.find( s, p, o ); try { while (it.hasNext()) { it.next(); it.remove(); } } finally { it.close(); } }
public static void removeAll( Graph g ) { ExtendedIterator<Triple> it = GraphUtil.findAll( g ); try { while (it.hasNext()) { it.next(); it.remove(); } } finally { it.close(); } } }
public static void removeAll(Graph g, Node s, Node p, Node o) { ExtendedIterator<Triple> it = g.find(s, p, o); try { while (it.hasNext()) { Triple t = it.next(); g.delete(t); it.remove(); } } finally { it.close(); } }
private static Node getObject(Graph graph, Node n, Node predicate) { ExtendedIterator<Triple> iter = graph.find(n, predicate, Node.ANY) ; try { if ( ! iter.hasNext() ) // None. return null ; Triple t = iter.next() ; if ( iter.hasNext() ) // Too many. return null ; return t.getObject() ; } finally { iter.close() ; } }
/** * <p>Answer true if this resource has the given label</p> * @param label The label to test for * @return True if this resource has <code>label</code> as a label. */ @Override public boolean hasLabel( Literal label ) { boolean found = false; ExtendedIterator<RDFNode> i = listLabels( label.getLanguage() ); while (!found && i.hasNext()) { found = label.equals( i.next() ); } i.close(); return found; }
protected MultiValueMap<ATermAppl, ATermAppl> getSubsumptions(Graph graph) { MultiValueMap<ATermAppl, ATermAppl> subsumers = new MultiValueMap<ATermAppl, ATermAppl>(); ExtendedIterator it = graph.find(Node.ANY, PRED_SUB, Node.ANY); while (it.hasNext()) { Triple tri = (Triple) it.next(); Node sub = tri.getSubject(); Node sup = tri.getObject(); if (NameStore.isAnon(sub) || NameStore.isAnon(sup)) continue; subsumers.add(toATermAppl(sub), toATermAppl(sup)); } it.close(); return subsumers; }
protected MultiValueMap<ATermAppl, ATermAppl> getSubsumptions(Graph graph) { MultiValueMap<ATermAppl, ATermAppl> subsumers = new MultiValueMap<ATermAppl, ATermAppl>(); ExtendedIterator it = graph.find(Node.ANY, PRED_SUB, Node.ANY); while (it.hasNext()) { Triple tri = (Triple) it.next(); Node sub = tri.getSubject(); Node sup = tri.getObject(); if (NameStore.isAnon(sub) || NameStore.isAnon(sup)) continue; subsumers.add(toATermAppl(sub), toATermAppl(sup)); } it.close(); return subsumers; }