|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
ObjectAbstractDataStore
public abstract class 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 SimpleFeatureSource implementation |
protected static Logger |
LOGGER
The logger for the filter module. |
Constructor Summary | |
---|---|
AbstractDataStore()
Default (Writeable) DataStore |
|
AbstractDataStore(boolean isWriteable)
AbstractDataStore creation. |
Method Summary | |
---|---|
protected FeatureWriter<SimpleFeatureType,SimpleFeature> |
createFeatureWriter(String typeName,
Transaction transaction)
Subclass should implement this to provide writing support. |
protected InProcessLockingManager |
createLockingManager()
Currently returns an InProcessLockingManager. |
protected Map |
createMetadata(String typeName)
Subclass override to provide access to metadata. |
void |
createSchema(SimpleFeatureType featureType)
Subclass should implement to provide writing support. |
void |
dispose()
Dummy implementation, it's a no-op. |
protected ReferencedEnvelope |
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<SimpleFeatureType,SimpleFeature> |
getFeatureReader(Query query,
Transaction transaction)
Gets a FeatureReader for features selected by the given
Query . |
protected abstract FeatureReader<SimpleFeatureType,SimpleFeature> |
getFeatureReader(String typeName)
Subclass must implement. |
protected FeatureReader<SimpleFeatureType,SimpleFeature> |
getFeatureReader(String typeName,
Query query)
GR: this method is called from inside getFeatureReader(Query ,Transaction ) to allow subclasses return an optimized FeatureReader query
A subclass that supports the creation of such an optimized FeatureReader
shold override this method. |
SimpleFeatureSource |
getFeatureSource(Name typeName)
Delegates to getFeatureSource(String) with
name.getLocalPart() |
SimpleFeatureSource |
getFeatureSource(String typeName)
Default implementation based on getFeatureReader and getFeatureWriter. |
FeatureWriter<SimpleFeatureType,SimpleFeature> |
getFeatureWriter(String typeName,
Filter filter,
Transaction transaction)
Gets a FeatureWriter to modify features in this DataStore . |
FeatureWriter<SimpleFeatureType,SimpleFeature> |
getFeatureWriter(String typeName,
Transaction transaction)
Gets a FeatureWriter to modify features in this DataStore . |
FeatureWriter<SimpleFeatureType,SimpleFeature> |
getFeatureWriterAppend(String typeName,
Transaction transaction)
Gets a FeatureWriter that can add new features to the DataStore . |
ServiceInfo |
getInfo()
Information about this service. |
LockingManager |
getLockingManager()
Locking manager used for this DataStore. |
List<Name> |
getNames()
Returns the same list of names than getTypeNames() meaning the
returned Names have no namespace set. |
SimpleFeatureType |
getSchema(Name name)
Delegates to getSchema(String) with name.getLocalPart() |
abstract SimpleFeatureType |
getSchema(String typeName)
Retrive schema information for typeName |
protected Set |
getSupportedHints()
If you are using the automated FeatureSource/Store/Locking creation, this method allows for the specification of the supported hints. |
abstract String[] |
getTypeNames()
helper method for retrieving all the names. |
protected Filter |
getUnsupportedFilter(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. |
void |
removeSchema(Name typeName)
Used to permanently remove a schema from the underlying storage This functionality is similar to an "drop table" statement in SQL. |
void |
removeSchema(String typeName)
Used to permanently remove a schema from the underlying storage This functionality is similar to an "drop table" statement in SQL. |
protected TransactionStateDiff |
state(Transaction transaction)
Used to retrive the TransactionStateDiff for this transaction. |
void |
updateSchema(Name typeName,
SimpleFeatureType featureType)
Delegates to updateSchema(String, SimpleFeatureType) with
name.getLocalPart() |
void |
updateSchema(String typeName,
SimpleFeatureType featureType)
Applies a new schema to the given feature type. |
Methods inherited from class Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final 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 writable DataStore.Method Detail |
---|
protected InProcessLockingManager createLockingManager()
Subclasses that implement real locking may override this method to
return null
.
protected Map createMetadata(String typeName)
CreateTypeEntry uses this method to aquire metadata information, if available.
public abstract String[] getTypeNames() throws IOException
getTypeNames
in interface DataStore
DataStore
IOException
- if data access errors occurpublic ServiceInfo getInfo()
DataAccess
This method offers access to a summary of header or metadata information describing the service.
Subclasses may return a specific ServiceInfo instance that has additional information (such as FilterCapabilities).
getInfo
in interface DataAccess<SimpleFeatureType,SimpleFeature>
public abstract SimpleFeatureType getSchema(String typeName) throws IOException
getSchema
in interface DataStore
typeName
- the feature type name
IOException
- if typeName
is not availableprotected abstract FeatureReader<SimpleFeatureType,SimpleFeature> getFeatureReader(String typeName) throws IOException
typeName
-
IOException
protected FeatureWriter<SimpleFeatureType,SimpleFeature> createFeatureWriter(String typeName, Transaction transaction) throws 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
IOException
IOException
- Subclass may throw IOException
UnsupportedOperationException
- Subclass may implementpublic void createSchema(SimpleFeatureType featureType) throws IOException
createSchema
in interface DataAccess<SimpleFeatureType,SimpleFeature>
featureType
- Requested FeatureType
IOException
IOException
- Subclass may throw IOException
UnsupportedOperationException
- Subclass may implementpublic void updateSchema(String typeName, SimpleFeatureType featureType)
DataStore
updateSchema
in interface DataStore
typeName
- name of the feature type to updatefeatureType
- the new schema to applypublic SimpleFeatureSource getFeatureSource(String typeName) throws IOException
We should be able to optimize this to only get the RowSet once
getFeatureSource
in interface DataStore
typeName
- the feature type
SimpleFeatureSource
(or possibly a subclass) providing
operations for features of the specified type
IOException
- if data access errors occurDataStore.getFeatureSource(java.lang.String)
public FeatureReader<SimpleFeatureType,SimpleFeature> getFeatureReader(Query query, Transaction transaction) throws IOException
DataStore
FeatureReader
for features selected by the given
Query
. FeatureReader
provies an iterator-style
API to feature data.
The Query
provides the schema for the form of the returned
features as well as a Filter
to constrain the features
available via the reader.
The Transaction
can be used to externalize the state of the
DataStore
. Examples of this include a JDBCDataStore
sharing a connection for use across several FeatureReader
requests;
and a ShapefileDataStore
redirecting requests to an alternate file
during the course of a Transaction
.
getFeatureReader
in interface DataStore
query
- a query providing the schema and constraints for
features that the reader will returntransaction
- a transaction that this reader will operate against
FeatureReader
IOException
- if data access errors occurprotected FeatureReader<SimpleFeatureType,SimpleFeature> getFeatureReader(String typeName, Query query) throws IOException
query
A subclass that supports the creation of such an optimized FeatureReader
shold override this method. Otherwise, it just returns
getFeatureReader(typeName)
IOException
protected Filter getUnsupportedFilter(String typeName, Filter filter)
If the complete filter is supported, the subclass must return Filter.INCLUDE
protected TransactionStateDiff state(Transaction transaction)
By default a TransactionStateDiff will be created that holds any changes in memory.
transaction
-
public FeatureWriter<SimpleFeatureType,SimpleFeature> getFeatureWriter(String typeName, Filter filter, Transaction transaction) throws IOException
DataStore
FeatureWriter
to modify features in this DataStore
.
FeatureWriter
provides an iterator style API to features.
The returned writer does not allow features to be added.
getFeatureWriter
in interface DataStore
typeName
- the type name for features that will be accessiblefilter
- defines additional constraints on the features that will
be accessibletransaction
- the transation that the returned writer operates
against
FeatureWriter
IOException
- if data access errors occurDataStore.getFeatureWriterAppend(String, Transaction)
public FeatureWriter<SimpleFeatureType,SimpleFeature> getFeatureWriter(String typeName, Transaction transaction) throws IOException
DataStore
FeatureWriter
to modify features in this DataStore
.
FeatureWriter
provides an iterator style API to features.
The returned writer does not allow features to be added.
getFeatureWriter
in interface DataStore
typeName
- the type name for features that will be accessibletransaction
- the transation that the returned writer operates
against
FeatureWriter
IOException
- if data access errors occurDataStore.getFeatureWriterAppend(String, Transaction)
public FeatureWriter<SimpleFeatureType,SimpleFeature> getFeatureWriterAppend(String typeName, Transaction transaction) throws IOException
DataStore
FeatureWriter
that can add new features to the DataStore
.
The FeatureWriter
will return false
when its hasNext()
method is called, but next()
can be used to acquire new features.
getFeatureWriterAppend
in interface DataStore
typeName
- name of the feature type for which features will be addedtransaction
- the transaction to operate against
FeatureWriter
that can only be used to
append new features
IOException
- if data access errors occurpublic LockingManager getLockingManager()
By default AbstractDataStore makes use of InProcessLockingManager.
getLockingManager
in interface DataStore
LockingManager
; or null
if locking
is handled by the DataStore
in a different fashionDataStore.getLockingManager()
protected ReferencedEnvelope getBounds(Query query) throws 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
IOException
protected int getCount(Query query) throws 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.
IOException
IOException
- if there are errors getting the countprotected Set getSupportedHints()
public void dispose()
dispose
in interface DataAccess<SimpleFeatureType,SimpleFeature>
public SimpleFeatureSource getFeatureSource(Name typeName) throws IOException
getFeatureSource(String)
with
name.getLocalPart()
getFeatureSource
in interface DataAccess<SimpleFeatureType,SimpleFeature>
getFeatureSource
in interface DataStore
typeName
- the qualified name of the feature type
SimpleFeatureSource
(or possibly a subclass) providing
operations for features of the specified type
IOException
- if data access errors occurDataAccess.getFeatureSource(Name)
public List<Name> getNames() throws IOException
getTypeNames()
meaning the
returned Names have no namespace set.
getNames
in interface DataAccess<SimpleFeatureType,SimpleFeature>
IOException
DataAccess.getNames()
public SimpleFeatureType getSchema(Name name) throws IOException
getSchema(String)
with name.getLocalPart()
getSchema
in interface DataAccess<SimpleFeatureType,SimpleFeature>
name
- Type name a the resource from getNames()
IOException
DataAccess.getSchema(Name)
public void updateSchema(Name typeName, SimpleFeatureType featureType) throws IOException
updateSchema(String, SimpleFeatureType)
with
name.getLocalPart()
updateSchema
in interface DataAccess<SimpleFeatureType,SimpleFeature>
IOException
- if the operation failedDataAccess.getFeatureSource(Name)
public void removeSchema(Name typeName) throws IOException
DataAccess
This functionality is similar to an "drop table" statement in SQL. Implementation is optional; it may not be supported by all servers or files.
removeSchema
in interface DataAccess<SimpleFeatureType,SimpleFeature>
IOException
- if the operation failedDataAccess.removeSchema(Name)
public void removeSchema(String typeName) throws IOException
DataStore
This functionality is similar to an "drop table" statement in SQL. Implementation is optional; it may not be supported by all servers or files.
removeSchema
in interface DataStore
IOException
- if the operation failedDataStore.removeSchema(String)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |