001: /*
002: * GeoTools - OpenSource mapping toolkit
003: * http://geotools.org
004: * (C) 2004-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.store;
017:
018: import java.io.IOException;
019:
020: import org.geotools.data.FeatureSource;
021: import org.geotools.data.Transaction;
022: import org.geotools.feature.Feature;
023: import org.geotools.feature.FeatureType;
024: import org.opengis.util.InternationalString;
025:
026: import com.vividsolutions.jts.geom.Envelope;
027:
028: /**
029: * Starting place for holding information about a FeatureType.
030: * <p>
031: * Like say for instance the FeatureType, its metadata and so on.
032: * </p>
033: * <p>
034: * The default implemenation should contain enough information to wean
035: * us off of AbstractDataStore. That is it should provide its own locking
036: * and event notification.
037: * </p>
038: * <p>
039: * There is a naming convention:
040: * <ul>
041: * <li> data access follows bean conventions: getTypeName(), getSchema()
042: * <li> resource access methods follow Collections conventions reader(),
043: * writer(), etc...
044: * <li> overrrides are all protected and follow factory conventions:
045: * createWriter(), createAppend(), createFeatureSource(),
046: * createFeatureStore(), etc...
047: * </ul>
048: * <li>
049: * </p>
050: * <p>
051: * Feedback:
052: * <ul>
053: * <li>even notification yes
054: * <li>locking not - locking needs to be rejuggled
055: * <li>naming convention really helps when subclassing
056: * </ul>
057: * </p>
058: *
059: * @author jgarnett
060: * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/library/main/src/main/java/org/geotools/data/store/TypeEntry.java $
061: */
062: public interface TypeEntry {
063:
064: /**
065: * @return user name for this feature collection
066: */
067: InternationalString getDisplayName();
068:
069: /**
070: * @return Description of this feature collection
071: */
072: InternationalString getDescription();
073:
074: /**
075: * @return Schema of this feature collection
076: * @throws IOException If resoruce is unavailable
077: */
078: FeatureType getFeatureType() throws IOException;
079:
080: /**
081: * Bounding box for associated Feature Collection, will be calcualted as needed.
082: * <p>
083: * Note bounding box is returned in lat/long - the coordinate system of the default geometry
084: * is used to provide this reprojection.
085: * </p>
086: * @return Enveloper for this FeatureCollection/FeatureType
087: */
088: //Envelope getBounds();
089: /** Number of features in associated Feature Collection, will be calcualted as needed
090: * @return number of features, may block while value is calculated, -1 indicates resource is unavailable
091: */
092: //public int getCount();
093: /**
094: * Create a new FeatueSource allowing interaction with content.
095: * <p>
096: * Subclass may optionally implement:
097: * <ul>
098: * <li>FeatureStore - to allow read/write access
099: * <li>FeatureLocking - for locking support
100: * </ul>
101: * This choice may even be made a runtime (allowing the api
102: * to represent a readonly file).
103: * </p>
104: * <p>
105: * Several default implemenations are provided
106: *
107: * @return FeatureLocking allowing access to content.
108: * @throws IOException
109: */
110: //FeatureSource getFeatureSource() throws IOException;
111: FeatureSource createFeatureSource() throws IOException;
112:
113: /**
114: * Change notifcation
115: *
116: * @param newFeature
117: * @param transaction
118: */
119: void fireAdded(Feature newFeature, Transaction transaction);
120:
121: /**
122: * Change notifcation
123: *
124: * @param removedFeature
125: * @param transaction
126: */
127: void fireRemoved(Feature removedFeature, Transaction transaction);
128:
129: /**
130: * Change notifcation
131: *
132: * @param before
133: * @param after
134: * @param transaction
135: */
136: void fireChanged(Feature before, Feature after,
137: Transaction transaction);
138:
139: /**
140: * Equals based only on resource definition information (not connection information).
141: *
142: * @see java.lang.Object#equals(java.lang.Object)
143: * @param obj
144: * @return true if TypeEntry represents the same resource
145: */
146: boolean equals(Object obj);
147:
148: /**
149: * This hashcode is *VERY* important!
150: * <p>
151: * The hascode must be dependent only on the parameters that "define"
152: * the resource, not those that control opperation.
153: * <ul>
154: * <li>when representing a URL the hashcode must be: url.hashCode()
155: * <li>when representing a File the hashcode must be: file.toURL().hashcode()
156: * <li>when representing a database connection: hascode of jdbc url w/ out username, password
157: * </ul>
158: * </p>
159: * <p>
160: * Implemetnation tip - URL.hashCode is a blocking operation, so you calculate and cache when the URL changes,
161: * rather than block this method.
162: * </p>
163: * @see java.lang.Object#hashCode()
164: * @return hashCode based on resource definition
165: */
166: int hashCode();
167:
168: }
|