public static <T> NullIterator<T> instance() { return new NullIterator<>(); }
public static <T> NullIterator<T> instance() { return new NullIterator<>(); }
/** * Answer an iterator over all of the values for the given key. An iterator * is always supplied, even if the key is not present. * * @param key The key object * @return An iterator over all of the values for this key in the map */ public Iterator<To> getAll( Object key ) { List<To> entry = m_table.get( key ); return (entry != null) ? entry.iterator() : new NullIterator<>(); }
/** * Answer an iterator over all of the values for the given key. An iterator * is always supplied, even if the key is not present. * * @param key The key object * @return An iterator over all of the values for this key in the map */ public Iterator<To> getAll( Object key ) { List<To> entry = m_table.get( key ); return (entry != null) ? entry.iterator() : new NullIterator<>(); }
/** * Return the derivation of at triple. * The derivation is a List of DerivationRecords */ @Override public Iterator<Derivation> getDerivation(Triple t) { if (derivations == null) { return new NullIterator<>(); } else { return derivations.getAll(t); } }
/** * Return the derivation of at triple. * The derivation is a List of DerivationRecords */ @Override public Iterator<Derivation> getDerivation(Triple t) { if (derivations == null) { return new NullIterator<>(); } else { return derivations.getAll(t); } }
/** * Return the derivation of at triple. * The derivation is a List of DerivationRecords */ @Override public Iterator<Derivation> getDerivation(Triple t) { if (derivations == null) { return new NullIterator<>(); } else { return derivations.getAll(t); } }
/** * Return the derivation of at triple. * The derivation is a List of DerivationRecords */ @Override public Iterator<Derivation> getDerivation(Triple t) { if (derivations == null) { return new NullIterator<>(); } else { return derivations.getAll(t); } }
/** * Basic pattern lookup interface. * @param pattern a TriplePattern to be matched against the data * @return a ClosableIterator over all Triples in the data set * that match the pattern */ @Override public ExtendedIterator<Triple> find(TriplePattern pattern) { if (graph == null) return new NullIterator<>(); return graph.find(pattern.asTripleMatch()); }
/** * Basic pattern lookup interface. * @param pattern a TriplePattern to be matched against the data * @return a ClosableIterator over all Triples in the data set * that match the pattern */ @Override public ExtendedIterator<Triple> find(TriplePattern pattern) { if (graph == null) return new NullIterator<>(); return graph.find(pattern.asTripleMatch()); }
public Iterator<Triple> execTriples() throws IOException { Model model = ModelFactory.createDefaultModel(); ExtendedIterator<Triple> result = new NullIterator<Triple>(); for (Query q: tq.getQueries()) { modifyQuery(q, table); QueryExecution ex = createQueryExecution(q, model); result = result.andThen(ex.execConstructTriples()); } return result; }
/** * Extended find interface used in situations where the implementator * may or may not be able to answer the complete query. It will * attempt to answer the pattern but if its answers are not known * to be complete then it will also pass the request on to the nested * Finder to append more results. * @param pattern a TriplePattern to be matched against the data * @param continuation either a Finder or a normal Graph which * will be asked for additional match results if the implementor * may not have completely satisfied the query. */ @Override public ExtendedIterator<Triple> findWithContinuation(TriplePattern pattern, Finder continuation) { if (graph == null) return new NullIterator<>(); if (continuation == null) { return graph.find(pattern.asTripleMatch()); } else { return graph.find(pattern.asTripleMatch()).andThen(continuation.find(pattern)); } }
/** * Extended find interface used in situations where the implementator * may or may not be able to answer the complete query. It will * attempt to answer the pattern but if its answers are not known * to be complete then it will also pass the request on to the nested * Finder to append more results. * @param pattern a TriplePattern to be matched against the data * @param continuation either a Finder or a normal Graph which * will be asked for additional match results if the implementor * may not have completely satisfied the query. */ @Override public ExtendedIterator<Triple> findWithContinuation(TriplePattern pattern, Finder continuation) { if (graph == null) return new NullIterator<>(); if (continuation == null) { return graph.find(pattern.asTripleMatch()); } else { return graph.find(pattern.asTripleMatch()).andThen(continuation.find(pattern)); } }
/** * <p> * Answer an iterator that ranges over the properties in this model that are declared * to be annotation properties. Not all supported languages define annotation properties * (the category of annotation properties is chiefly an OWL innovation). * </p> * <p> * <strong>Note:</strong> the number of nodes returned by this iterator will vary according to * the completeness of the deductive extension of the underlying graph. See class * overview for more details. * </p> * * @return An iterator over annotation properties. * @see Profile#getAnnotationProperties() */ @Override public ExtendedIterator<AnnotationProperty> listAnnotationProperties() { checkProfileEntry( getProfile().ANNOTATION_PROPERTY(), "ANNOTATION_PROPERTY" ); Resource r = getProfile().ANNOTATION_PROPERTY(); if (r == null) { return new NullIterator<>(); } else { return findByType( r ) .mapWith( p -> getNodeAs( p.getSubject(), AnnotationProperty.class ) ) .filterKeep( new UniqueFilter<AnnotationProperty>()); } }
/** * <p> * Answer an iterator that ranges over the properties in this model that are declared * to be annotation properties. Not all supported languages define annotation properties * (the category of annotation properties is chiefly an OWL innovation). * </p> * <p> * <strong>Note:</strong> the number of nodes returned by this iterator will vary according to * the completeness of the deductive extension of the underlying graph. See class * overview for more details. * </p> * * @return An iterator over annotation properties. * @see Profile#getAnnotationProperties() */ @Override public ExtendedIterator<AnnotationProperty> listAnnotationProperties() { checkProfileEntry( getProfile().ANNOTATION_PROPERTY(), "ANNOTATION_PROPERTY" ); Resource r = getProfile().ANNOTATION_PROPERTY(); if (r == null) { return new NullIterator<>(); } else { return findByType( r ) .mapWith( p -> getNodeAs( p.getSubject(), AnnotationProperty.class ) ) .filterKeep( new UniqueFilter<AnnotationProperty>()); } }
@Override public void ontTest( OntModel m ) { Profile prof = m.getProfile(); ComplementClass A = m.createComplementClass( NS + "A", null ); OntClass B = m.createClass( NS + "B" ); OntClass C = m.createClass( NS + "C" ); boolean ex = false; try { A.addOperand( B ); } catch (UnsupportedOperationException e) {ex = true;} assertTrue( "Should fail to add to a complement", ex ); ex = false; try { A.addOperands( new NullIterator<Resource>() ); } catch (UnsupportedOperationException e) {ex = true;} assertTrue( "Should fail to add to a complement", ex ); ex = false; try { A.setOperands( m.createList( new RDFNode[] {C} ) ); } catch (UnsupportedOperationException e) {ex = true;} assertTrue( "Should fail to set a list to a complement", ex ); A.setOperand( B ); assertEquals( "Cardinality should be 1", 1, A.getCardinality( prof.COMPLEMENT_OF() ) ); assertEquals( "Complement should be B", B, A.getOperand() ); iteratorTest( A.listOperands(), new Object[] {B} ); A.setOperand( C ); assertEquals( "Cardinality should be 1", 1, A.getCardinality( prof.COMPLEMENT_OF() ) ); assertTrue( "A should have C in the complement", A.hasOperand( C ) ); assertTrue( "A should not have B in the complement", !A.hasOperand( B ) ); A.removeOperand( B ); assertTrue( "Should have C as an operand", A.hasOperand( C ) ); A.removeOperand( C ); assertTrue( "Should not have C as an operand", !A.hasOperand( C ) ); } },
@Override public void ontTest( OntModel m ) { Profile prof = m.getProfile(); ComplementClass A = m.createComplementClass( NS + "A", null ); OntClass B = m.createClass( NS + "B" ); OntClass C = m.createClass( NS + "C" ); boolean ex = false; try { A.addOperand( B ); } catch (UnsupportedOperationException e) {ex = true;} assertTrue( "Should fail to add to a complement", ex ); ex = false; try { A.addOperands( new NullIterator<Resource>() ); } catch (UnsupportedOperationException e) {ex = true;} assertTrue( "Should fail to add to a complement", ex ); ex = false; try { A.setOperands( m.createList( new RDFNode[] {C} ) ); } catch (UnsupportedOperationException e) {ex = true;} assertTrue( "Should fail to set a list to a complement", ex ); A.setOperand( B ); assertEquals( "Cardinality should be 1", 1, A.getCardinality( prof.COMPLEMENT_OF() ) ); assertEquals( "Complement should be B", B, A.getOperand() ); iteratorTest( A.listOperands(), new Object[] {B} ); A.setOperand( C ); assertEquals( "Cardinality should be 1", 1, A.getCardinality( prof.COMPLEMENT_OF() ) ); assertTrue( "A should have C in the complement", A.hasOperand( C ) ); assertTrue( "A should not have B in the complement", !A.hasOperand( B ) ); A.removeOperand( B ); assertTrue( "Should have C as an operand", A.hasOperand( C ) ); A.removeOperand( C ); assertTrue( "Should not have C as an operand", !A.hasOperand( C ) ); } },