Refine search
/** * <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 arbitrary 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 void testRemove( String findRemove, String findCheck ) { Graph g = getGraphWith( "S P O" ); ExtendedIterator<Triple> it = g.find( NodeCreateUtils.createTriple( findRemove ) ); try { it.next(); it.remove(); it.close(); assertEquals( "remove with " + findRemove + ":", 0, g.size() ); assertFalse( g.contains( NodeCreateUtils.createTriple( findCheck ) ) ); } catch (UnsupportedOperationException e) { // No iterator remove. it.close(); } }
public void testRemove( String findRemove, String findCheck ) { Graph g = getGraphWith( "S P O" ); ExtendedIterator<Triple> it = g.find( NodeCreateUtils.createTriple( findRemove ) ); try { it.next(); it.remove(); it.close(); assertEquals( "remove with " + findRemove + ":", 0, g.size() ); assertFalse( g.contains( NodeCreateUtils.createTriple( findCheck ) ) ); } catch (UnsupportedOperationException e) { // No iterator remove. it.close(); } }
/** * <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 arbitrary 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; }
private void testRemove(String findRemove, String findCheck) { Graph g = graphWith(producer.newInstance(), "S P O"); txnBegin(g); ExtendedIterator<Triple> it = g .find(NodeCreateUtils.createTriple(findRemove)); txnRollback(g); try { it.next(); it.remove(); it.close(); assertEquals("remove with " + findRemove + ":", 0, g.size()); assertFalse(g.contains(NodeCreateUtils.createTriple(findCheck))); } catch (UnsupportedOperationException e) { it.close(); } }
private RDFNode getOrCompute(RDFNode key, Map<RDFNode,RDFNode> values, NodeExpressionContext context) { return values.computeIfAbsent(key, k -> { ExtendedIterator<RDFNode> it = comparator.eval(key, context); if(it.hasNext()) { RDFNode result = it.next(); it.close(); return result; } else { return null; } }); }
private void testRemove(String findRemove, String findCheck) { Graph g = graphWith(producer.newInstance(), "S P O"); txnBegin(g); ExtendedIterator<Triple> it = g .find(NodeCreateUtils.createTriple(findRemove)); txnRollback(g); try { it.next(); it.remove(); it.close(); assertEquals("remove with " + findRemove + ":", 0, g.size()); assertFalse(g.contains(NodeCreateUtils.createTriple(findCheck))); } catch (UnsupportedOperationException e) { it.close(); } }
/** Get exactly one triple or null for none or more than one. */ 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(); } }
@Override public boolean contains(Node s, Node p, Node o) { // Do direct for efficiency. if ( ! base.contains(s,p,o) ) return false; // May have matched by value. Do a term test find to restrict to RDF terms. ExtendedIterator<Triple> iter = find(s, p, o); boolean b = iter.hasNext(); iter.close(); return b; }
public void testClosingConcatenationClosesRemainingIterators() { LoggingClosableIterator<String> L = new LoggingClosableIterator<>( iteratorOfStrings( "only" ) ); LoggingClosableIterator<String> M = new LoggingClosableIterator<>( iteratorOfStrings( "single" ) ); LoggingClosableIterator<String> R = new LoggingClosableIterator<>( iteratorOfStrings( "it" ) ); ExtendedIterator<String> cat = L.andThen( M ).andThen( R ); cat.next(); cat.close(); assertTrue( "middle iterator should have been closed", M.isClosed() ); assertTrue( "final iterator should have been closed", R.isClosed() ); }
@Override public boolean contains(final RDFNode value) throws ReadDeniedException, AuthenticationRequiredException { // iterator() checks Read final ExtendedIterator<RDFNode> iter = iterator(); try { while (iter.hasNext()) { if (value.equals(iter.next())) { return true; } } return false; } finally { iter.close(); } }
public void testClosingConcatenationClosesRemainingIterators() { LoggingClosableIterator<String> L = new LoggingClosableIterator<>( iteratorOfStrings( "only" ) ); LoggingClosableIterator<String> M = new LoggingClosableIterator<>( iteratorOfStrings( "single" ) ); LoggingClosableIterator<String> R = new LoggingClosableIterator<>( iteratorOfStrings( "it" ) ); ExtendedIterator<String> cat = L.andThen( M ).andThen( R ); cat.next(); cat.close(); assertTrue( "middle iterator should have been closed", M.isClosed() ); assertTrue( "final iterator should have been closed", R.isClosed() ); }
/** Answer the number of triples in this graph. Default implementation counts its way through the results of a findAll. Subclasses must override if they want size() to be efficient. */ protected int graphBaseSize() { ExtendedIterator<Triple> it = GraphUtil.findAll( this ); try { int tripleCount = 0; while (it.hasNext()) { it.next(); tripleCount += 1; } return tripleCount; } finally { it.close(); } }
@Override public boolean contains(Node s, Node p, Node o) { // Do direct for efficiency. if ( ! base.contains(s,p,o) ) return false; // May have matched by value. Do a term test find to restrict to RDF terms. ExtendedIterator<Triple> iter = find(s, p, o); boolean b = iter.hasNext(); iter.close(); return b; }