|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
ObjectContentDataStore
public abstract class ContentDataStore
Abstract base class for data stores.
A datastore contains a set of entries (ContentEntry
). Each entry
corresponds to a "real world dataset". For instance, a shapefile datastore
would contain a single entry which would represent the shapefile on disk. A
postgis datastore could contain many entries, one for each table in the database.
Each entry is identified by a name (Name
). The name can be qualified
with a namespace uri, or unqualified (in which the namespace uri is null). An
example of a datastore that might use qualified names is WFS, where in each
entry corresponds to a WFS "Feature Type", which have namespace qualified name.
Other datastores (such as databases) use unqualified names.
When entry names of a datastore are unqualified, a default namespace uri can
be set "globally" on the datastore itself, see setNamespaceURI(String)
.
When this value is set, unqualified entry names are implicitly qualified with
the global namespace uri.
At a minimum subclasses must implement the following methods:
The following methods may also be overriden: The following methods may be overriden but only to narrow the return type to a specific subclass ofContentFeatureSource
.
Field Summary | |
---|---|
protected DataStoreFactorySpi |
dataStoreFactory
factory used to create the datastore |
protected Map<Name,ContentEntry> |
entries
name, entry map |
protected FeatureFactory |
featureFactory
Factory used to create features |
protected FilterFactory |
filterFactory
Factory used to create filters |
protected GeometryFactory |
geometryFactory
Factory used to create geometries |
protected LockingManager |
lockingManager
locking manager |
protected Logger |
LOGGER
logger |
protected String |
namespaceURI
namespace uri of the datastore itself, or default namespace |
protected FeatureTypeFactory |
typeFactory
Factory used to create feature types |
protected static int |
WRITER_ADD
writer flags |
protected static int |
WRITER_UPDATE
|
Constructor Summary | |
---|---|
ContentDataStore()
|
Method Summary | |
---|---|
protected ContentState |
createContentState(ContentEntry entry)
Instantiates a new content state for the entry. |
protected abstract ContentFeatureSource |
createFeatureSource(ContentEntry entry)
Instantiates new feature source for the entry. |
void |
createSchema(SimpleFeatureType featureType)
Creates a new schema in the datastore. |
protected abstract List<Name> |
createTypeNames()
Creates a set of qualified names corresponding to the types that the datastore provides. |
void |
dispose()
Disposes of this data store and releases any resource that it is using. |
protected ContentEntry |
ensureEntry(Name name)
Helper method to look up an entry in the datastore which throws an IOException in the event that the entry does not exist. |
protected ContentFeatureStore |
ensureFeatureStore(String typeName,
Transaction tx)
Helper method which gets a feature source ensuring that it is a feature store as well. |
protected ContentEntry |
entry(Name name)
Helper method to look up an entry in the datastore. |
DataStoreFactorySpi |
getDataStoreFactory()
Returns the factory used to create the data store. |
ContentEntry |
getEntry(Name name)
Returns the entry for a specified name, or null if no such
entry exists. |
FeatureFactory |
getFeatureFactory()
The factory used to create features. |
FeatureReader<SimpleFeatureType,SimpleFeature> |
getFeatureReader(Query query,
Transaction tx)
Returns a feature reader for the specified query and transaction. |
SimpleFeatureSource |
getFeatureSource(Name typeName)
Delegates to getFeatureSource(String) with
name.getLocalPart() |
ContentFeatureSource |
getFeatureSource(Name typeName,
Transaction tx)
Returns the feature source matching the specified name and explicitly specifies a transaction. |
ContentFeatureSource |
getFeatureSource(String typeName)
Returns the feature source matching the specified name. |
ContentFeatureSource |
getFeatureSource(String typeName,
Transaction tx)
Returns the feature source matching the specified name and explicitly specifies a transaction. |
FeatureTypeFactory |
getFeatureTypeFactory()
The factory used to create feature types. |
FeatureWriter<SimpleFeatureType,SimpleFeature> |
getFeatureWriter(String typeName,
Filter filter,
Transaction tx)
Returns a feature writer for the specified query and transaction. |
FeatureWriter<SimpleFeatureType,SimpleFeature> |
getFeatureWriter(String typeName,
Transaction tx)
Returns a feature writer for the specified type name and transaction. |
FeatureWriter<SimpleFeatureType,SimpleFeature> |
getFeatureWriterAppend(String typeName,
Transaction tx)
Returns an appending feature writer for the specified type name and transaction. |
FilterFactory |
getFilterFactory()
The factory used to create filters. |
GeometryFactory |
getGeometryFactory()
The factory used to create geometries. |
ServiceInfo |
getInfo()
Information about this service. |
LockingManager |
getLockingManager()
Retrieve a per featureID based locking service from this DataStore . |
Logger |
getLogger()
The logger for the datastore. |
List<Name> |
getNames()
Returns the same list of names than getTypeNames() meaning the
returned Names have no namespace set. |
String |
getNamespaceURI()
The namespace uri of the datastore. |
SimpleFeatureType |
getSchema(Name name)
Delegates to getSchema(String) with name.getLocalPart() |
SimpleFeatureType |
getSchema(String typeName)
Returns the feature type or schema matching the specified name. |
String[] |
getTypeNames()
Returns the names of all entries or types provided by the datastore. |
protected Name |
name(String typeName)
Helper method to wrap a non-qualified name. |
protected void |
removeEntry(Name name)
Helper method to remove an entry from the cached entry map. |
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. |
void |
setDataStoreFactory(DataStoreFactorySpi dataStoreFactory)
Sets the data store factory used to create the datastore. |
void |
setFeatureFactory(FeatureFactory featureFactory)
Sets the factory used to create features. |
void |
setFeatureTypeFactory(FeatureTypeFactory typeFactory)
Sets the factory used to create feature types. |
void |
setFilterFactory(FilterFactory filterFactory)
Sets the factory used to create filters. |
void |
setGeometryFactory(GeometryFactory geometryFactory)
Sets the factory used to create geometries. |
void |
setNamespaceURI(String namespaceURI)
Sets the namespace uri of the datastore. |
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 int WRITER_ADD
protected static final int WRITER_UPDATE
protected final Map<Name,ContentEntry> entries
protected final Logger LOGGER
protected FeatureTypeFactory typeFactory
protected FeatureFactory featureFactory
protected FilterFactory filterFactory
protected GeometryFactory geometryFactory
protected String namespaceURI
protected LockingManager lockingManager
protected DataStoreFactorySpi dataStoreFactory
Constructor Detail |
---|
public ContentDataStore()
Method Detail |
---|
public FeatureTypeFactory getFeatureTypeFactory()
public void setFeatureTypeFactory(FeatureTypeFactory typeFactory)
public void setFeatureFactory(FeatureFactory featureFactory)
public FilterFactory getFilterFactory()
public FeatureFactory getFeatureFactory()
public void setFilterFactory(FilterFactory filterFactory)
public GeometryFactory getGeometryFactory()
public void setGeometryFactory(GeometryFactory geometryFactory)
public DataStoreFactorySpi getDataStoreFactory()
null
.public void setDataStoreFactory(DataStoreFactorySpi dataStoreFactory)
WARNING: This property should only be set in cases where the datastore factory is stateless and does not maintain any references to created datastores. Setting this property in such a case will result in a memory leak.
public String getNamespaceURI()
null
.public void setNamespaceURI(String namespaceURI)
This will be used to qualify the entries or types of the datastore.
namespaceURI
- The namespace uri, may be null
.public Logger getLogger()
public 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 final String[] getTypeNames() throws IOException
This method is marked final and delegates to createTypeNames()
,
which subclasses are intended to implement.
getTypeNames
in interface DataStore
DataStore
IOException
- if data access errors occurDataStore.getTypeNames()
public void createSchema(SimpleFeatureType featureType) throws IOException
This implementation throws aUnsupportedOperationException
. Subclasses
should override to support schema creation.
createSchema
in interface DataAccess<SimpleFeatureType,SimpleFeature>
featureType
- FetureType to add to DataStore
IOException
- If featureType cannot be createdDataAccess.createSchema(FeatureType)
public final SimpleFeatureType getSchema(String typeName) throws IOException
This method calls through to getFeatureSource(typeName).getSchema()
getSchema
in interface DataStore
typeName
- the feature type name
IOException
- if typeName
is not availableDataStore.getSchema(String)
public ContentFeatureSource getFeatureSource(String typeName) throws IOException
Subclasses should not implement this method. However overriding in order
to perform a type narrowing to a subclasses of ContentFeatureSource
is acceptable.
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(String)
public ContentFeatureSource getFeatureSource(String typeName, Transaction tx) throws IOException
Subclasses should not implement this method. However overriding in order
to perform a type narrowing to a subclasses of ContentFeatureSource
is acceptable.
IOException
DataStore.getFeatureSource(String)
public ContentFeatureSource getFeatureSource(Name typeName, Transaction tx) throws IOException
Subclasses should not implement this method. However overriding in order
to perform a type narrowing to a subclasses of ContentFeatureSource
is acceptable.
IOException
DataStore.getFeatureSource(String)
public FeatureReader<SimpleFeatureType,SimpleFeature> getFeatureReader(Query query, Transaction tx) throws IOException
This method is not intended to be overridden and is marked final. This
implementation delegates to FeatureCollection
and wraps an iterator
in a FeatureReader
.
getFeatureReader
in interface DataStore
query
- a query providing the schema and constraints for
features that the reader will returntx
- a transaction that this reader will operate against
FeatureReader
IOException
- if data access errors occurpublic FeatureWriter<SimpleFeatureType,SimpleFeature> getFeatureWriter(String typeName, Filter filter, Transaction tx) throws IOException
This method is not intended to be overridden and is marked final. This
implementation delegates to FeatureCollection
and wraps an iterator
in a FeatureWriter
.
getFeatureWriter
in interface DataStore
typeName
- the type name for features that will be accessiblefilter
- defines additional constraints on the features that will
be accessibletx
- the transation that the returned writer operates
against
FeatureWriter
IOException
- if data access errors occurDataStore.getFeatureWriterAppend(String, Transaction)
protected final ContentFeatureStore ensureFeatureStore(String typeName, Transaction tx) throws IOException
typeName
- The name of the feature source.tx
- A transaction handle.
IOException
- If the feature source is not a store.public final FeatureWriter<SimpleFeatureType,SimpleFeature> getFeatureWriter(String typeName, Transaction tx) throws IOException
This method is convenience for getFeatureWriter(typeName,Filter.INCLUDE,tx)
.
getFeatureWriter
in interface DataStore
typeName
- the type name for features that will be accessibletx
- the transation that the returned writer operates
against
FeatureWriter
IOException
- if data access errors occurDataStore.getFeatureWriterAppend(String, Transaction)
public final FeatureWriter<SimpleFeatureType,SimpleFeature> getFeatureWriterAppend(String typeName, Transaction tx) throws IOException
This method is not intended to be overridden and is marked final. This
implementation delegates to FeatureCollection
and wraps an iterator
in a FeatureWriter
.
getFeatureWriterAppend
in interface DataStore
typeName
- name of the feature type for which features will be addedtx
- the transaction to operate against
FeatureWriter
that can only be used to
append new features
IOException
- if data access errors occurpublic final LockingManager getLockingManager()
DataStore
DataStore
.
getLockingManager
in interface DataStore
LockingManager
; or null
if locking
is handled by the DataStore
in a different fashionpublic final void updateSchema(String typeName, SimpleFeatureType featureType) throws IOException
DataStore
updateSchema
in interface DataStore
typeName
- name of the feature type to updatefeatureType
- the new schema to apply
IOException
- on errorpublic void dispose()
DataAccess
A DataStore
cannot be used after dispose
has
been called, neither can any data access object it helped create, such
as FeatureReader
, FeatureSource
or FeatureCollection
.
This operation can be called more than once without side effects.
There is no thread safety assurance associated with this method. For example, client code will have to make sure this method is not called while retrieving/saving data from/to the storage, or be prepared for the consequences.
dispose
in interface DataAccess<SimpleFeatureType,SimpleFeature>
public ContentEntry getEntry(Name name)
null
if no such
entry exists.
protected ContentState createContentState(ContentEntry entry)
Subclasses may override this method to return a specific subclass of
ContentState
.
entry
- The entry.
ContentState
for the entry.protected final Name name(String typeName)
protected final ContentEntry entry(Name name) throws IOException
This method will create a new instance of ContentEntry
if one
does not exist.
In the event that the name does not map to an entry
and one cannot be created null
will be returned. Note that
#ensureEntry(TypeName)
will throw an exception in this case.
The
- name of the entry.
null
if it does not exist.
IOException
protected final ContentEntry ensureEntry(Name name) throws IOException
IOException
in the event that the entry does not exist.
name
- The name of the entry.
IOException
- If the entry does not exist, or if there was an error
looking it up.protected final void removeEntry(Name name)
name
- The name of the entry.protected abstract List<Name> createTypeNames() throws IOException
Namespaces may be left null
for data stores which do not
support namespace qualified type names.
Name
.
IOException
- Any errors occuring connecting to data.protected abstract ContentFeatureSource createFeatureSource(ContentEntry entry) throws IOException
Subclasses should override this method to return a specific subclass of
ContentFeatureSource
.
entry
- The entry.
ContentFeatureSource
for the entry.
IOException
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 |