|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.geotools.data.AbstractDataStore
Represents a stating point for implementing your own DataStore.
The goal is to have this class provide everything else if you can only provide:
All remaining functionality is implemented against these methods, including Transaction and Locking Support. These implementations will not be optimal but they will work.
Pleae note that there may be a better place for you to start out from, (like JDBCDataStore).
Field Summary | |
protected boolean |
isWriteable
Flags AbstractDataStore to allow Modification. |
FeatureListenerManager |
listenerManager
Manages listener lists for FeatureSource implementation |
protected static java.util.logging.Logger |
LOGGER
The logger for the filter module. |
Constructor Summary | |
AbstractDataStore()
Default (Writeable) DataStore |
|
AbstractDataStore(boolean isWriteable)
AbstractDataStore creation. |
Method Summary | |
protected FeatureWriter |
createFeatureWriter(java.lang.String typeName,
Transaction transaction)
Subclass should implement this to provide writing support. |
protected InProcessLockingManager |
createLockingManager()
Currently returns an InProcessLockingManager. |
protected java.util.Map |
createMetadata(java.lang.String typeName)
Subclass override to provide access to metadata. |
void |
createSchema(FeatureType featureType)
Subclass should implement to provide writing support. |
protected com.vividsolutions.jts.geom.Envelope |
getBounds(Query query)
Computes the bounds of the features for the specified feature type that satisfy the query provided that there is a fast way to get that result. |
protected int |
getCount(Query query)
Gets the number of the features that would be returned by this query for the specified feature type. |
FeatureReader |
getFeatureReader(Query query,
Transaction transaction)
Access a FeatureReader providing access to Feature information. |
protected abstract FeatureReader |
getFeatureReader(java.lang.String typeName)
Subclass must implement. |
protected FeatureReader |
getFeatureReader(java.lang.String typeName,
Query query)
GR: this method is called from inside getFeatureReader(Query ,Transaction ) to allow subclasses return an optimized FeatureReader wich supports the filter and attributes truncation specified in query
A subclass that supports the creation of such an optimized FeatureReader
shold override this method. |
FeatureSource |
getFeatureSource(java.lang.String typeName)
Default implementation based on getFeatureReader and getFeatureWriter. |
protected FeatureWriter |
getFeatureWriter(java.lang.String typeName)
Deprecated. |
FeatureWriter |
getFeatureWriter(java.lang.String typeName,
Filter filter,
Transaction transaction)
Access FeatureWriter for modification of existing DataStore contents. |
FeatureWriter |
getFeatureWriter(java.lang.String typeName,
Transaction transaction)
Access FeatureWriter for modification of the DataStore typeName. |
FeatureWriter |
getFeatureWriterAppend(java.lang.String typeName,
Transaction transaction)
Aquire a FeatureWriter for adding new content to a FeatureType. |
LockingManager |
getLockingManager()
Locking manager used for this DataStore. |
abstract FeatureType |
getSchema(java.lang.String typeName)
Retrive schema information for typeName |
abstract java.lang.String[] |
getTypeNames()
Convience method for retriving all the names from the Catalog Entires |
protected Filter |
getUnsupportedFilter(java.lang.String typeName,
Filter filter)
GR: if a subclass supports filtering, it should override this method to return the unsupported part of the passed filter, so a FilteringFeatureReader will be constructed upon it. |
FeatureSource |
getView(Query query)
Access a FeatureSource for Query providing a high-level API. |
void |
updateSchema(java.lang.String typeName,
FeatureType featureType)
Used to force namespace and CS info into a persistent change. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected static final java.util.logging.Logger LOGGER
public FeatureListenerManager listenerManager
protected final boolean isWriteable
GetFeatureSource will return a FeatureStore is this is true.
Constructor Detail |
public AbstractDataStore()
public AbstractDataStore(boolean isWriteable)
isWriteable
- true for writeable DataStore.Method Detail |
protected InProcessLockingManager createLockingManager()
Subclasses that implement real locking may override this method to
return null
.
protected java.util.Map createMetadata(java.lang.String typeName)
CreateTypeEntry uses this method to aquire metadata information, if available.
public abstract java.lang.String[] getTypeNames() throws java.io.IOException
getTypeNames
in interface DataStore
java.io.IOException
public abstract FeatureType getSchema(java.lang.String typeName) throws java.io.IOException
getSchema
in interface DataStore
typeName
- typeName of requested FeatureType
java.io.IOException
- If typeName cannot be foundprotected abstract FeatureReader getFeatureReader(java.lang.String typeName) throws java.io.IOException
typeName
-
java.io.IOException
protected FeatureWriter getFeatureWriter(java.lang.String typeName) throws java.io.IOException
typeName
-
java.io.IOException
java.io.IOException
- Subclass may throw IOException
java.lang.UnsupportedOperationException
- Subclass may implementprotected FeatureWriter createFeatureWriter(java.lang.String typeName, Transaction transaction) throws java.io.IOException
A feature writer writes to the resource so it should considered to always be committing. The transaction is passed in so that it can be known what FeatureListeners should be notified of the changes. If the Transaction is AUTOCOMMIT then all listeners should be notified. If not all listeners that are NOT registered with that transaction should be notified.
typeName
- transaction
- a feature writer
java.io.IOException
java.io.IOException
- Subclass may throw IOException
java.lang.UnsupportedOperationException
- Subclass may implementpublic void createSchema(FeatureType featureType) throws java.io.IOException
createSchema
in interface DataStore
featureType
- Requested FeatureType
java.io.IOException
java.io.IOException
- Subclass may throw IOException
java.lang.UnsupportedOperationException
- Subclass may implementpublic void updateSchema(java.lang.String typeName, FeatureType featureType)
DataStore
The provided featureType should completely cover the existing schema. All attributes should be accounted for and the typeName should match.
Suggestions:
updateSchema
in interface DataStore
typeName
- public FeatureSource getView(Query query) throws java.io.IOException, SchemaException
DataStore
The provided Query does not need to completely cover the existing schema for Query.getTypeName(). The result will mostly likely only be a FeatureSource and probably wont' allow write access by the FeatureStore method.
By using Query we allow support for reprojection, in addition to overriding the CoordinateSystem used by the native FeatureType.
We may wish to limit this method to only support Queries using Filter.ALL.
Update - GeoServer has an elegatent implementation of this functionality that we could steal. GeoServerFeatureSource, GeoServerFeatureStore and GeoServerFeatureLocking serve as a working prototype.
getView
in interface DataStore
SchemaException
- If fetureType is not covered by existing schema
java.io.IOException
- If FeatureSource is not availablepublic FeatureSource getFeatureSource(java.lang.String typeName) throws java.io.IOException
We should be able to optimize this to only get the RowSet once
getFeatureSource
in interface DataStore
typeName
-
java.io.IOException
DataStore.getFeatureSource(java.lang.String)
public FeatureReader getFeatureReader(Query query, Transaction transaction) throws java.io.IOException
DataStore
Filter is used as a low-level indication of constraints. (Implementations may resort to using a FilteredFeatureReader, or provide their own optimizations)
FeatureType provides a template for the returned FeatureReader
Transaction to externalize DataStore state on a per Transaction basis. The most common example is a JDBC datastore saving a Connection for use across several FeatureReader requests. Similarly a Shapefile reader may wish to redirect FeatureReader requests to a alternate filename over the course of a Transaction.
Notes For Implementing DataStore
Subclasses may need to retrieve additional attributes, beyond those
requested by featureType.getAttributeTypes(), in order to correctly
apply the filter
.
These Additional attribtues should be not be returned by
FeatureReader. Subclasses may use ReTypeFeatureReader to aid in
acomplishing this.
Helper classes for implementing a FeatureReader (in order):
Sample use (not optimized):
if (filter == Filter.ALL) {
return new EmptyFeatureReader(featureType);
}
String typeName = featureType.getTypeName();
FeatureType schema = getSchema( typeName );
FeatureReader reader = new DefaultFeatureReader( getAttributeReaders(), schema );
if (filter != Filter.NONE) {
reader = new FilteringFeatureReader(reader, filter);
}
if (transaction != Transaction.AUTO_COMMIT) {
Map diff = state(transaction).diff(typeName);
reader = new DiffFeatureReader(reader, diff);
}
if (!featureType.equals(reader.getFeatureType())) {
reader = new ReTypeFeatureReader(reader, featureType);
}
return reader
Locking support does not need to be provided for FeatureReaders.
getFeatureReader
in interface DataStore
query
- Requested form of the returned Features and the filter used
to constraints the resultstransaction
- Transaction this query opperates against
java.io.IOException
protected FeatureReader getFeatureReader(java.lang.String typeName, Query query) throws java.io.IOException
query
A subclass that supports the creation of such an optimized FeatureReader
shold override this method. Otherwise, it just returns
getFeatureReader(typeName)
java.io.IOException
protected Filter getUnsupportedFilter(java.lang.String typeName, Filter filter)
If the complete filter is supported, the subclass must return Filter.NONE
public FeatureWriter getFeatureWriter(java.lang.String typeName, Filter filter, Transaction transaction) throws java.io.IOException
DataStore
To limit FeatureWriter to the FeatureTypes defined by this DataStore, typeName is used to indicate FeatureType. The resulting feature writer will allow modifications against the same FeatureType provided by getSchema( typeName )
The FeatureWriter will provide access to the existing contents of the FeatureType referenced by typeName. The provided filter will be used to skip over Features as required.
Notes For Implementing DataStore
The returned FeatureWriter does not support the addition of new
Features to FeatureType (it would need to police your modifications to
agree with filer
). As such it will return
false
for getNext() when it reaches the end of the Query
and NoSuchElementException when next() is called.
Helper classes for implementing a FeatureWriter (in order):
getFeatureWriter
in interface DataStore
typeName
- Indicates featureType to be modifiedfilter
- constraints used to limit the modificationtransaction
- Transaction this query opperates against
java.io.IOException
public FeatureWriter getFeatureWriter(java.lang.String typeName, Transaction transaction) throws java.io.IOException
DataStore
FeatureWriters will need to be limited to the FeatureTypes defined by the DataStore, the easiest way to express this limitation is to the FeatureType by a provided typeName.
The returned FeatureWriter will return false
for getNext()
when it reaches the end of the Query.
getFeatureWriter
in interface DataStore
typeName
- Indicates featureType to be modifiedtransaction
- Transaction to opperates against
java.io.IOException
public FeatureWriter getFeatureWriterAppend(java.lang.String typeName, Transaction transaction) throws java.io.IOException
DataStore
This FeatureWriter will return false
for hasNext(), however
next() may be used to aquire new Features that may be writen out to add
new content.
getFeatureWriterAppend
in interface DataStore
typeName
- Indicates featureType to be modifiedtransaction
- Transaction to opperates against
java.io.IOException
public LockingManager getLockingManager()
By default AbstractDataStore makes use of InProcessLockingManager.
getLockingManager
in interface DataStore
DataStore.getLockingManager()
protected com.vividsolutions.jts.geom.Envelope getBounds(Query query) throws java.io.IOException
Will return null if there is not fast way to compute the bounds. Since it's based on some kind of header/cached information, it's not guaranteed to be real bound of the features
query
-
SchemaNotFoundException
java.io.IOException
protected int getCount(Query query) throws java.io.IOException
If getBounds(Query) returns -1
due to expense consider
using getFeatures(Query).getCount()
as a an alternative.
query
- Contains the Filter and MaxFeatures to find the bounds for.
-1
if count is too expensive to calculate or any errors or occur.
java.io.IOException
java.io.IOException
- if there are errors getting the count
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |