public final void close(Iterator<SimpleFeature> close) { try { closeIterator(close); } catch (IOException e) { LOGGER.log(Level.WARNING, "Error closing iterator", e); } open.remove(close); }
public void accepts(org.opengis.feature.FeatureVisitor visitor, org.opengis.util.ProgressListener progress) { Iterator iterator = null; if (progress == null) progress = new NullProgressListener(); try{ float size = size(); float position = 0; progress.started(); for( iterator = iterator(); !progress.isCanceled() && iterator.hasNext(); progress.progress( 100.0f * position++ / size )){ try { SimpleFeature feature = (SimpleFeature) iterator.next(); visitor.visit(feature); } catch( Exception erp ){ progress.exceptionOccurred( erp ); } } } finally { progress.complete(); close( iterator ); } }
/** * Returns a FeatureWriterIterator, or FeatureReaderIterator over content. * * <p>If you have a way to tell that you are readonly please subclass with a less hardcore check * - this implementations catches a UnsupportedOpperationsException from wrtier()! * * @return Iterator, should be closed closeIterator */ protected Iterator<SimpleFeature> openIterator() throws IOException { try { FeatureWriter writer = writer(); if (writer != null) { return new FeatureWriterIterator(writer()); } } catch (IOException badWriter) { return new NoContentIterator(badWriter); } catch (UnsupportedOperationException readOnly) { } try { return new FeatureReaderIterator(reader()); } catch (IOException e) { return new NoContentIterator(e); } }
protected void fireChange(SimpleFeature feature, int type) { fireChange(new SimpleFeature[] {feature}, type); }
/** * Default implementation based on creating an reader, testing hasNext, and closing. * * <p>For once the Collections API does not give us an escape route, we *have* to check the * data. */ public boolean isEmpty() { FeatureReader<SimpleFeatureType, SimpleFeature> reader = null; try { reader = reader(); try { return !reader.hasNext(); } catch (IOException e) { return true; // error seems like no features are available } } catch (IOException e) { return true; } finally { if (reader != null) { try { reader.close(); } catch (IOException e) { // return value already set } } } }
@Override public void close(final FeatureIterator<SimpleFeature> iterator) { featureCursor = null; super.close(iterator); }
/** Iterator may (or may) not support modification. */ public final Iterator<SimpleFeature> iterator() { Iterator<SimpleFeature> iterator; try { iterator = openIterator(); } catch (IOException e) { throw new RuntimeException(e); } open.add(iterator); return iterator; }
/** Default implementation based on getCount() - this may be expensive */ public int size() { try { return getCount(); } catch (IOException e) { if (LOGGER.isLoggable(Level.FINE)) LOGGER.log( Level.FINE, "IOException while calculating size() of FeatureCollection", e); return 0; } }
/** * SimpleFeatureIterator is entirely based on iterator(). * * <p>So when we implement FeatureCollection.iterator() this will work out of the box. */ public SimpleFeatureIterator features() { SimpleFeatureIterator iterator = new DelegateSimpleFeatureIterator(this, iterator()); open.add(iterator); return iterator; }
/** * FeatureSchema for provided query. * * <p>If query.retrieveAllProperties() is <code>true</code> the FeatureSource getSchema() will * be returned. * * <p>If query.getPropertyNames() is used to limit the result of the Query a sub type will be * returned based on FeatureSource.getSchema(). * * @return DOCUMENT ME! * @throws IOException DOCUMENT ME! * @throws DataSourceException DOCUMENT ME! */ public SimpleFeatureType getSchema() { return super.getSchema(); }
public int getNumberOfAttributes() { return size(); }
/** * Accepts a visitor, which then visits each feature in the collection. * @throws IOException */ public void accepts(FeatureVisitor visitor, ProgressListener progress ) throws IOException { Iterator iterator = null; if (progress == null) progress = new NullProgressListener(); try{ float size = size(); float position = 0; progress.started(); for( iterator = iterator(); !progress.isCanceled() && iterator.hasNext(); progress.progress( position++/size )){ try { Feature feature = (Feature) iterator.next(); visitor.visit(feature); } catch( Exception erp ){ progress.exceptionOccurred( erp ); } } } finally { progress.complete(); close( iterator ); } }
/** * Returns a FeatureWriterIterator, or FeatureReaderIterator over content. * <p> * If you have a way to tell that you are readonly please subclass with * a less hardcore check - this implementations catches a * UnsupportedOpperationsException from wrtier()! * * @return Iterator, should be closed closeIterator */ protected Iterator<SimpleFeature> openIterator() throws IOException { try { FeatureWriter writer = writer(); if(writer != null) { return new FeatureWriterIterator( writer() ); } } catch (IOException badWriter) { return new NoContentIterator( badWriter ); } catch( UnsupportedOperationException readOnly ){ } try { return new FeatureReaderIterator( reader() ); } catch (IOException e) { return new NoContentIterator( e ); } }
protected void fireChange(Collection coll, int type) { SimpleFeature[] features = new SimpleFeature[coll.size()]; features = (SimpleFeature[]) coll.toArray(features); fireChange(features, type); }
reader = reader(); try { while (reader.hasNext()) {