/** * Adds a collection of features to the store. * * <p>This method operates by getting an appending feature writer and writing all the features * in <tt>collection</tt> to it. Directly after a feature is written its id is obtained and * added to the returned set. */ public List<FeatureId> addFeatures(Collection collection) throws IOException { // gather up id's List<FeatureId> ids = new ArrayList<FeatureId>(collection.size()); FeatureWriter<SimpleFeatureType, SimpleFeature> writer = getWriterAppend(); try { for (Iterator f = collection.iterator(); f.hasNext(); ) { FeatureId id = addFeature((SimpleFeature) f.next(), writer); ids.add(id); } } finally { writer.close(); } return ids; }
/** * Adds a collection of features to the store. * * @param featureCollection */ public List<FeatureId> addFeatures( FeatureCollection<SimpleFeatureType, SimpleFeature> featureCollection) throws IOException { // gather up id's List<FeatureId> ids = new ArrayList<FeatureId>(); FeatureWriter<SimpleFeatureType, SimpleFeature> writer = getWriterAppend(); FeatureIterator<SimpleFeature> f = featureCollection.features(); try { while (f.hasNext()) { SimpleFeature feature = f.next(); FeatureId id = addFeature(feature, writer); ids.add(id); } } finally { writer.close(); f.close(); } return ids; }
/** * Adds a collection of features to the store. * <p> * This method operates by getting an appending feature writer and writing * all the features in <tt>collection</tt> to it. Directly after a feature * is written its id is obtained and added to the returned set. * </p> */ public final List<FeatureId> addFeatures(Collection collection) throws IOException { // gather up id's List<FeatureId> ids = new LinkedList<FeatureId>(); FeatureWriter<SimpleFeatureType, SimpleFeature> writer = getWriterAppend(); try { for ( Iterator f = collection.iterator(); f.hasNext(); ) { FeatureId id = addFeature((SimpleFeature) f.next(), writer); ids.add( id ); } } finally { writer.close(); } return ids; }
/** * Adds a collection of features to the store. * <p> * This method calls through to {@link #addFeatures(Collection)}. * </p> */ public final List<FeatureId> addFeatures(FeatureCollection<SimpleFeatureType,SimpleFeature> collection) throws IOException { // gather up id's List<FeatureId> ids = new LinkedList<FeatureId>(); FeatureWriter<SimpleFeatureType, SimpleFeature> writer = getWriterAppend(); Iterator f = collection.iterator(); try { while (f.hasNext()) { SimpleFeature feature = (SimpleFeature) f.next(); FeatureId id = addFeature(feature, writer); ids.add( id ); } } finally { writer.close(); collection.close( f ); } return ids; }