001: /*
002: * GeoTools - OpenSource mapping toolkit
003: * http://geotools.org
004: * (C) 2002-2006, GeoTools Project Managment Committee (PMC)
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation;
009: * version 2.1 of the License.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: */
016: package org.geotools.data;
017:
018: import java.io.IOException;
019: import java.util.Set;
020: import org.opengis.filter.Filter;
021: import org.geotools.feature.AttributeType;
022: import org.geotools.feature.FeatureCollection;
023:
024: /**
025: * Provides storage of data for Features.
026: *
027: * <p>
028: * Individual shapefiles, database tables, etc. are modified through this
029: * interface.
030: * </p>
031: *
032: * <p>
033: * This is a prototype DataSource replacement please see FeatureSource for more
034: * information.
035: * </p>
036: *
037: * @author Jody Garnett
038: * @author Ray Gallagher
039: * @author Rob Hranac, TOPP
040: * @author Chris Holmes, TOPP
041: * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/library/api/src/main/java/org/geotools/data/FeatureStore.java $
042: * @version $Id: FeatureStore.java 22642 2006-11-07 21:00:05Z jgarnett $
043: */
044: public interface FeatureStore extends FeatureSource {
045: /**
046: * Adds all features from the passed feature collection to the datasource.
047: *
048: * @param collection The collection of features to add.
049: * @return the FeatureIds of the newly added features.
050: *
051: * @throws IOException if anything goes wrong.
052: */
053: Set addFeatures(FeatureCollection collection) throws IOException;
054:
055: /**
056: * Removes all of the features specificed by the passed filter from the
057: * collection.
058: *
059: * @param filter An OpenGIS filter; specifies which features to remove.
060: *
061: * @throws IOException If anything goes wrong.
062: */
063: void removeFeatures(Filter filter) throws IOException;
064:
065: /**
066: * Modifies the passed attribute types with the passed objects in all
067: * features that correspond to the passed OGS filter.
068: *
069: * @param type The attributes to modify.
070: * @param value The values to put in the attribute types.
071: * @param filter An OGC filter to note which attributes to modify.
072: *
073: * @throws IOException if the attribute and object arrays are not eqaul
074: * length, if the object types do not match the attribute types,
075: * or if there are backend errors.
076: */
077: void modifyFeatures(AttributeType[] type, Object[] value,
078: Filter filter) throws IOException;
079:
080: /**
081: * Modifies the passed attribute types with the passed objects in all
082: * features that correspond to the passed OGS filter. A convenience
083: * method for single attribute modifications.
084: *
085: * @param type The attributes to modify.
086: * @param value The values to put in the attribute types.
087: * @param filter An OGC filter to note which attributes to modify.
088: *
089: * @throws IOException If modificaton is not supported, if the object type
090: * do not match the attribute type.
091: */
092: void modifyFeatures(AttributeType type, Object value, Filter filter)
093: throws IOException;
094:
095: /**
096: * Deletes the all the current Features of this datasource and adds the new
097: * collection. Primarily used as a convenience method for file
098: * datasources.
099: *
100: * @param reader - the collection to be written
101: *
102: * @throws IOException if there are any datasource errors.
103: */
104: void setFeatures(FeatureReader reader) throws IOException;
105:
106: /**
107: * Provides a transaction for commit/rollback control of this FeatureStore.
108: *
109: * <p>
110: * This method operates as a replacement for setAutoCommitMode. When a
111: * transaction is provided you are no longer automatically committing.
112: * </p>
113: *
114: * <p>
115: * In order to return to AutoCommit mode supply the Transaction.AUTO_COMMIT
116: * to this method. Since this represents a return to AutoCommit mode the
117: * previous Transaction will be commited.
118: * </p>
119: *
120: * @param transaction DOCUMENT ME!
121: */
122: void setTransaction(Transaction transaction);
123:
124: /**
125: * Used to access the Transaction this DataSource is currently opperating
126: * against.
127: *
128: * <p>
129: * Example Use: adding features to a road DataSource
130: * </p>
131: * <pre><code>
132: * Transaction t = roads.getTransaction();
133: * try{
134: * roads.addFeatures( features );
135: * roads.getTransaction().commit();
136: * }
137: * catch( IOException erp ){
138: * //something went wrong;
139: * roads.getTransaction().rollback();
140: * }
141: * </code></pre>
142: *
143: * @return Transaction in use, or <code>Transaction.AUTO_COMMIT</code>
144: */
145: Transaction getTransaction();
146: }
|