/** * Returns a feature reader for all features. * * <p>This method calls through to {@link #getReader(Query)}. */ public final FeatureReader<SimpleFeatureType, SimpleFeature> getReader() throws IOException { return getReader(Query.ALL); }
public SimpleFeatureIterator features() { try { return new WrappingFeatureIterator(featureSource.getReader(query)); } catch (IOException e) { throw new RuntimeException(e); } }
/** * Returns a feature reader for the specified query and transaction. * * <p>This method is not intended to be overridden and is marked final. This implementation * delegates to {@link FeatureCollection} and wraps an iterator in a {@link FeatureReader}. */ public FeatureReader<SimpleFeatureType, SimpleFeature> getFeatureReader( Query query, Transaction tx) throws IOException { if (query.getTypeName() == null) { throw new IllegalArgumentException("Query does not specify type."); } return getFeatureSource(query.getTypeName(), tx).getReader(query); }
/** * Returns a reader for features specified by a particular filter. * * <p>This method calls through to {@link #getReader(Query)}. */ public final FeatureReader<SimpleFeatureType, SimpleFeature> getReader(Filter filter) throws IOException { return getReader(new Query(getSchema().getTypeName(), filter)); }
public boolean isEmpty() { // build a minimal query Query notEmptyQuery = new Query(query); notEmptyQuery.setMaxFeatures(1); AttributeDescriptor smallAttribute = getSmallAttributeInSchema(); if (smallAttribute != null) { notEmptyQuery.setPropertyNames( Collections.singletonList(smallAttribute.getLocalName())); } try { FeatureReader<?, ?> fr = featureSource.getReader(notEmptyQuery); try { return !fr.hasNext(); } finally { fr.close(); } } catch (IOException e) { throw new RuntimeException(e); } }
fr = featureSource.getReader(q); int count = 0; while (fr.hasNext()) {
public void testGetFeatureReader() throws IOException { FeatureReader<SimpleFeatureType, SimpleFeature> reader = data.getFeatureSource("road").getReader(); assertCovered(roadFeatures, reader); assertEquals(false, reader.hasNext()); }
reader = featureSource.getReader(q); while (reader.hasNext()) { SimpleFeature f = reader.next();
/** * Returns a feature reader for all features. * <p> * This method calls through to {@link #getReader(Query)}. * </p> */ public final FeatureReader<SimpleFeatureType, SimpleFeature> getReader() throws IOException { return getReader(Query.ALL); }
FeatureReader<SimpleFeatureType, SimpleFeature> reader = getReader(filter); try { int locked = 0;
FeatureReader<SimpleFeatureType, SimpleFeature> reader = getReader(query); try { float size = progress instanceof NullProgressListener ? 0.0f : (float) getCount(query);
/** Unlocks features specified by a filter. */ public final void unLockFeatures(Filter filter) throws IOException { filter = resolvePropertyNames(filter); String typeName = getSchema().getTypeName(); FeatureReader<SimpleFeatureType, SimpleFeature> reader = getReader(filter); try { while (reader.hasNext()) { SimpleFeature feature = reader.next(); // // Use native locking? // if (canLock()) { doUnlockInternal(typeName, feature); } else { getDataStore() .getLockingManager() .unLockFeatureID(typeName, feature.getID(), transaction, lock); } } } finally { reader.close(); } }
public void testGetFeatureReaderMutability() throws IOException { FeatureReader<SimpleFeatureType, SimpleFeature> reader = data.getFeatureSource("road").getReader(); SimpleFeature feature; while (reader.hasNext()) { feature = (SimpleFeature) reader.next(); feature.setAttribute("name", null); } reader.close(); reader = data.getFeatureSource("road").getReader(); while (reader.hasNext()) { feature = (SimpleFeature) reader.next(); assertNotNull(feature.getAttribute("name")); } reader.close(); try { reader.next(); fail("next should fail with an IOException"); } catch (IOException expected) { } }
public SimpleFeatureIterator features(){ try { return new WrappingFeatureIterator( featureSource.getReader(query) ); } catch( IOException e ) { throw new RuntimeException( e ); } }
public Iterator iterator() { try { return new WrappingIterator( featureSource.getReader(query) ); } catch( IOException e ) { throw new RuntimeException( e ); } }
public void testGetFeatureReaderConcurancy() throws NoSuchElementException, IOException { FeatureReader<SimpleFeatureType, SimpleFeature> reader1 = data.getFeatureSource("road").getReader(); FeatureReader<SimpleFeatureType, SimpleFeature> reader2 = data.getFeatureSource("road").getReader(); FeatureReader<SimpleFeatureType, SimpleFeature> reader3 = data.getFeatureSource("river").getReader();
/** * Returns a feature reader for the specified query and transaction. * <p> * This method is not intended to be overridden and is marked final. This * implementation delegates to {@link FeatureCollection} and wraps an iterator * in a {@link FeatureReader}. * </p> */ public FeatureReader<SimpleFeatureType, SimpleFeature> getFeatureReader(Query query, Transaction tx) throws IOException { if ( query.getTypeName() == null ) { throw new IllegalArgumentException( "Query does not specify type."); } return getFeatureSource(query.getTypeName(),tx).getReader( query ); }
/** * Returns a reader for features specified by a particular filter. * <p> * This method calls through to {@link #getReader(Query)}. * </p> */ public final FeatureReader<SimpleFeatureType, SimpleFeature> getReader(Filter filter) throws IOException { return getReader( new Query( getSchema().getTypeName(), filter )); }
FeatureReader<SimpleFeatureType, SimpleFeature> reader = getReader(filter); try { int locked = 0;
/** * Unlocks features specified by a filter. */ public final void unLockFeatures(Filter filter) throws IOException { filter = resolvePropertyNames(filter); String typeName = getSchema().getTypeName(); FeatureReader<SimpleFeatureType, SimpleFeature> reader = getReader(filter); try { while( reader.hasNext() ) { SimpleFeature feature = reader.next(); // // Use native locking? // if(canLock()) { doLockInternal(typeName,feature); } else { getDataStore().getLockingManager() .unLockFeatureID(typeName, feature.getID(), transaction, lock); } } } finally { reader.close(); } }