/** * Returns a writer over features specified by a filter. * * @param filter The filter */ public final FeatureWriter<SimpleFeatureType, SimpleFeature> getWriter(Filter filter) throws IOException { return getWriter(filter, WRITER_ADD | WRITER_UPDATE); }
/** * Returns a writer over features specified by a query. * * @param query The query */ public final FeatureWriter<SimpleFeatureType, SimpleFeature> getWriter(Query query) throws IOException { return getWriter(query, WRITER_ADD | WRITER_UPDATE); }
/** * Returns a feature writer 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 FeatureWriter}. */ public FeatureWriter<SimpleFeatureType, SimpleFeature> getFeatureWriter( String typeName, Filter filter, Transaction tx) throws IOException { ContentFeatureStore featureStore = ensureFeatureStore(typeName, tx); return featureStore.getWriter(filter, WRITER_UPDATE | WRITER_ADD); }
/** * Utility method that ensures we are going to write only in append mode * * @return * @throws IOException */ private FeatureWriter<SimpleFeatureType, SimpleFeature> getWriterAppend() throws IOException { FeatureWriter<SimpleFeatureType, SimpleFeature> writer = getWriter(Filter.INCLUDE, WRITER_ADD); while (writer.hasNext()) { writer.next(); } return writer; }
/** * Returns a writer over features specified by a filter. * * @param filter The filter * @param flags flags specifying writing mode */ public final FeatureWriter<SimpleFeatureType, SimpleFeature> getWriter(Filter filter, int flags) throws IOException { return getWriter(new Query(getSchema().getTypeName(), filter), flags); }
/** * Returns an appending feature writer for the specified type name 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 FeatureWriter}. */ public final FeatureWriter<SimpleFeatureType, SimpleFeature> getFeatureWriterAppend( String typeName, Transaction tx) throws IOException { ContentFeatureStore featureStore = ensureFeatureStore(typeName, tx); FeatureWriter<SimpleFeatureType, SimpleFeature> writer = featureStore.getWriter(Filter.INCLUDE, WRITER_ADD); // ensure we are at the "end" as we are being asked to return this in "append" mode while (writer.hasNext()) { writer.next(); } return writer; }
/** * Removes the features from the store which match the specified filter. * * <p>This method operates by obtaining an updating feature writer based on the specified * <tt>filter</tt> and removing every feature from it. * * <p>The <tt>filter</tt> must not be <code>null</code>, in this case this method will throw an * {@link IllegalArgumentException}. */ public void removeFeatures(Filter filter) throws IOException { if (filter == null) { String msg = "Must specify a filter, must not be null."; throw new IllegalArgumentException(msg); } filter = resolvePropertyNames(filter); // grab a feature writer FeatureWriter<SimpleFeatureType, SimpleFeature> writer = getWriter(filter, WRITER_UPDATE); try { // remove everything while (writer.hasNext()) { writer.next(); writer.remove(); } } finally { writer.close(); } } }
/** * Modifies/updates the features of the store which match the specified filter. * * <p>This method operates by obtaining an updating feature writer based on the specified * <tt>filter</tt> and writing the updated values to it. * * <p>The <tt>filter</tt> must not be <code>null</code>, in this case this method will throw an * {@link IllegalArgumentException}. */ public void modifyFeatures(Name[] type, Object[] value, Filter filter) throws IOException { if (filter == null) { String msg = "Must specify a filter, must not be null."; throw new IllegalArgumentException(msg); } filter = resolvePropertyNames(filter); // grab a feature writer FeatureWriter<SimpleFeatureType, SimpleFeature> writer = getWriter(filter, WRITER_UPDATE); try { while (writer.hasNext()) { SimpleFeature toWrite = writer.next(); for (int i = 0; i < type.length; i++) { toWrite.setAttribute(type[i], value[i]); } writer.write(); } } finally { writer.close(); } }
/** * Returns a writer over features specified by a query. * * @param query The query */ public final FeatureWriter<SimpleFeatureType, SimpleFeature> getWriter( Query query ) throws IOException { return getWriter( query, WRITER_ADD | WRITER_UPDATE ); }
/** * Returns a writer over features specified by a filter. * * @param filter The filter */ public final FeatureWriter<SimpleFeatureType, SimpleFeature> getWriter( Filter filter ) throws IOException { return getWriter( filter, WRITER_ADD | WRITER_UPDATE ); }
writer = store.getWriter(Filter.INCLUDE, ContentDataStore.WRITER_COMMIT); } else { throw new UnsupportedOperationException("not writable");
getWriter(Filter.INCLUDE, WRITER_ADD); try { while (reader.hasNext()) {
/** * Returns a feature writer 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 FeatureWriter}. * </p> */ public FeatureWriter<SimpleFeatureType, SimpleFeature> getFeatureWriter(String typeName, Filter filter, Transaction tx) throws IOException { ContentFeatureStore featureStore = ensureFeatureStore(typeName,tx); return featureStore.getWriter( filter , WRITER_UPDATE | WRITER_ADD ); }
/** * Utility method that ensures we are going to write only in append mode * @return * @throws IOException */ private FeatureWriter<SimpleFeatureType, SimpleFeature> getWriterAppend() throws IOException { FeatureWriter<SimpleFeatureType, SimpleFeature> writer = getWriter( Filter.INCLUDE, WRITER_ADD ); while(writer.hasNext()) { writer.next(); } return writer; }
/** * Returns a writer over features specified by a filter. * * @param filter The filter * @param flags flags specifying writing mode */ public final FeatureWriter<SimpleFeatureType, SimpleFeature> getWriter( Filter filter, int flags ) throws IOException { return getWriter( new Query( getSchema().getTypeName(), filter ), flags ); }
/** * Returns an appending feature writer for the specified type name 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 FeatureWriter}. * </p> */ public final FeatureWriter<SimpleFeatureType, SimpleFeature> getFeatureWriterAppend(String typeName, Transaction tx) throws IOException { ContentFeatureStore featureStore = ensureFeatureStore(typeName,tx); FeatureWriter<SimpleFeatureType, SimpleFeature> writer = featureStore.getWriter( Filter.INCLUDE , WRITER_ADD ); // ensure we are at the "end" as we are being asked to return this in "append" mode while( writer.hasNext() ){ writer.next(); } return writer; }
FeatureWriter<SimpleFeatureType, SimpleFeature> writer = getWriter( filter, WRITER_UPDATE ); try {
FeatureWriter<SimpleFeatureType, SimpleFeature> writer = getWriter( filter, WRITER_UPDATE ); try { while( writer.hasNext() ) {
.getWriter(Filter.INCLUDE); SimpleFeature feature;
FeatureWriter<SimpleFeatureType, SimpleFeature> writer = getWriter( Filter.INCLUDE, WRITER_ADD ); try { while( reader.hasNext() ) {