org.geotools.data.store
Class AbstractDataStore2

Object
  extended by AbstractDataStore2
All Implemented Interfaces:
DataAccess<SimpleFeatureType,SimpleFeature>, DataStore

public class AbstractDataStore2
extends Object
implements DataStore

Represents a stating point for implementing your own DataStore.

The goal is to have this class provide everything else if you only need to provide:

To support writing:

All remaining functionality is implemented against these methods, including Transaction and Locking Support. These implementations will not be optimal but they will work.

To support custom query optimizations: To provide high-level writing optimizations: To provide low-level writing optimizations: To provide high-level writing optimizations:

Pleae note that there may be a better place for you to start out from, (like JDBCDataStore).

Author:
jgarnett
Module:
modules/library/main (gt-main.jar)

Field Summary
protected static Logger LOGGER
          The logger for the data module.
 
Constructor Summary
AbstractDataStore2()
          Default (Writeable) DataStore
 
Method Summary
protected  List createContents()
          Subclass must overrride to connet to contents.
protected  InProcessLockingManager createLockingManager()
          Currently returns an InProcessLockingManager.
 void createSchema(SimpleFeatureType featureType)
          Subclass should implement to provide for creation.
 void dispose()
          Dummy implementation, it's a no-op.
 List entries()
          List of ActiveTypeEntry entries - one for each featureType provided by this Datastore
 ActiveTypeEntry entry(String typeName)
           
 FeatureReader<SimpleFeatureType,SimpleFeature> getFeatureReader(Query query, Transaction transaction)
          Access a FeatureReader providing access to Feature information.
 FeatureSource<SimpleFeatureType,SimpleFeature> getFeatureSource(Name typeName)
          Delegates to getFeatureSource(String) with name.getLocalPart()
 FeatureSource<SimpleFeatureType,SimpleFeature> getFeatureSource(String typeName)
          Aqure FeatureSource for indicated typeName.
 FeatureWriter<SimpleFeatureType,SimpleFeature> getFeatureWriter(String typeName, Filter filter, Transaction transaction)
          Access FeatureWriter for modification of existing DataStore contents.
 FeatureWriter<SimpleFeatureType,SimpleFeature> getFeatureWriter(String typeName, Transaction transaction)
          TODO summary sentence for getFeatureWriter ...
 FeatureWriter<SimpleFeatureType,SimpleFeature> getFeatureWriterAppend(String typeName, Transaction transaction)
          FeatureWriter setup to add new content.
 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()
 SimpleFeatureType getSchema(String typeName)
          Retrive schema information for typeName
 String[] getTypeNames()
          Convience method for retriving all the names from the Catalog Entires
 FeatureSource<SimpleFeatureType,SimpleFeature> getView(Query query)
          Create a FeatureSource that represents your Query.
 void updateSchema(Name typeName, SimpleFeatureType featureType)
          Delegates to updateSchema(String, SimpleFeatureType) with name.getLocalPart()
 void updateSchema(String typeName, SimpleFeatureType featureType)
          Subclass should implement to provide modification support.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOGGER

protected static final Logger LOGGER
The logger for the data module.

Constructor Detail

AbstractDataStore2

public AbstractDataStore2()
Default (Writeable) DataStore

Method Detail

createLockingManager

protected InProcessLockingManager createLockingManager()
Currently returns an InProcessLockingManager.

Subclasses that implement real locking may override this method to return null.

Returns:
InProcessLockingManager or null.

entries

public List entries()
List of ActiveTypeEntry entries - one for each featureType provided by this Datastore


createContents

protected List createContents()
Subclass must overrride to connet to contents.

An implementation that has any doubt about its contents should aquire them during object creation (where an IOException can be thrown).

This method is lazyly called to create a List of ActiveTypeEntry for each FeatureCollection in this DataStore.

Returns:
List.

getTypeNames

public String[] getTypeNames()
Convience method for retriving all the names from the Catalog Entires

Specified by:
getTypeNames in interface DataStore
Returns:
typeNames for available FeatureTypes.

entry

public ActiveTypeEntry entry(String typeName)

getInfo

public ServiceInfo getInfo()
Description copied from interface: DataAccess
Information about this service.

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).

Specified by:
getInfo in interface DataAccess<SimpleFeatureType,SimpleFeature>
Returns:
SeviceInfo

getSchema

public SimpleFeatureType getSchema(String typeName)
                            throws IOException
Retrive schema information for typeName

Specified by:
getSchema in interface DataStore
Parameters:
typeName - typeName of requested FeatureType
Returns:
FeatureType for the provided typeName
Throws:
IOException - If typeName cannot be found

createSchema

public void createSchema(SimpleFeatureType featureType)
                  throws IOException
Subclass should implement to provide for creation.

Specified by:
createSchema in interface DataAccess<SimpleFeatureType,SimpleFeature>
Parameters:
featureType - Requested FeatureType
Throws:
IOException - Subclass may throw IOException
UnsupportedOperationException - Subclass may implement

updateSchema

public void updateSchema(String typeName,
                         SimpleFeatureType featureType)
                  throws IOException
Subclass should implement to provide modification support.

Specified by:
updateSchema in interface DataStore
Throws:
IOException

getView

public FeatureSource<SimpleFeatureType,SimpleFeature> getView(Query query)
                                                       throws IOException,
                                                              SchemaException
Create a FeatureSource that represents your Query.

If we can make this part of the public API, we can phase out FeatureResults. (and reduce the number of classes people need to know about).

Specified by:
getView in interface DataStore
Parameters:
query - Query.getTypeName() locates FeatureType being viewed
Returns:
FeatureSource providing operations for featureType
Throws:
IOException - If FeatureSource is not available
SchemaException - If fetureType is not covered by existing schema

getFeatureSource

public FeatureSource<SimpleFeatureType,SimpleFeature> getFeatureSource(String typeName)
                                                                throws IOException
Aqure FeatureSource for indicated typeName.

Note this API is not sufficient; Namespace needs to be used as well.

Specified by:
getFeatureSource in interface DataStore
Returns:
FeatureSource (or subclass) providing operations for typeName
Throws:
IOException

getFeatureReader

public FeatureReader<SimpleFeatureType,SimpleFeature> getFeatureReader(Query query,
                                                                       Transaction transaction)
                                                                throws IOException
Access a FeatureReader providing access to Feature information.

This implementation passes off responsibility to the following overrideable methods:

  • getFeatureReader(String typeName) - subclass *required* to implement

If you can handle some aspects of Query natively (say expressions or reprojection) override the following:

  • getFeatureReader(typeName, query) - override to handle query natively
  • getUnsupportedFilter(typeName, filter) - everything you cannot handle natively
  • getFeatureReader(String typeName) - you must implement this, but you could point it back to getFeatureReader( typeName, Query.ALL );

    Specified by:
    getFeatureReader in interface DataStore
    Parameters:
    query - Requested form of the returned Features and the filter used to constraints the results
    transaction - Transaction this query operates against
    Returns:
    FeatureReader Allows Sequential Processing of featureType
    Throws:
    IOException

  • getFeatureWriter

    public FeatureWriter<SimpleFeatureType,SimpleFeature> getFeatureWriter(String typeName,
                                                                           Filter filter,
                                                                           Transaction transaction)
                                                                    throws IOException
    Description copied from interface: DataStore
    Access FeatureWriter for modification of existing DataStore contents.

    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):

  • InProcessLockingManager.checkedWriter( writer ) - provides a check against locks before allowing modification
  • FilteringFeatureWriter - filtering support for FeatureWriter (does not allow new content)
  • DiffFeatureWriter - In-Process Transaction Support (see TransactionStateDiff)
  • EmptyFeatureWriter - provides no content for Filter.EXCLUDE optimizations
  • Specified by:
    getFeatureWriter in interface DataStore
    Parameters:
    typeName - Indicates featureType to be modified
    filter - constraints used to limit the modification
    transaction - Transaction this query operates against
    Returns:
    FeatureWriter Allows Sequential Modification of featureType
    Throws:
    IOException

    getFeatureWriter

    public FeatureWriter<SimpleFeatureType,SimpleFeature> getFeatureWriter(String typeName,
                                                                           Transaction transaction)
                                                                    throws IOException
    TODO summary sentence for getFeatureWriter ...

    Specified by:
    getFeatureWriter in interface DataStore
    Parameters:
    typeName -
    transaction -
    Returns:
    FeatureWriter
    Throws:
    IOException
    See Also:
    DataStore.getFeatureWriter(java.lang.String, org.geotools.data.Transaction)

    getFeatureWriterAppend

    public FeatureWriter<SimpleFeatureType,SimpleFeature> getFeatureWriterAppend(String typeName,
                                                                                 Transaction transaction)
                                                                          throws IOException
    FeatureWriter setup to add new content.

    Specified by:
    getFeatureWriterAppend in interface DataStore
    Parameters:
    typeName -
    transaction -
    Returns:
    FeatureWriter already skipped to the end
    Throws:
    IOException
    See Also:
    DataStore.getFeatureWriterAppend(java.lang.String, org.geotools.data.Transaction)

    getLockingManager

    public LockingManager getLockingManager()
    Locking manager used for this DataStore.

    By default AbstractDataStore makes use of InProcessLockingManager.

    Specified by:
    getLockingManager in interface DataStore
    Returns:
    DataStores may return null, if the handling locking in another fashion.
    See Also:
    DataStore.getLockingManager()

    dispose

    public void dispose()
    Dummy implementation, it's a no-op. Subclasses holding to system resources must override this method and release them.

    Specified by:
    dispose in interface DataAccess<SimpleFeatureType,SimpleFeature>

    getFeatureSource

    public FeatureSource<SimpleFeatureType,SimpleFeature> getFeatureSource(Name typeName)
                                                                    throws IOException
    Delegates to getFeatureSource(String) with name.getLocalPart()

    Specified by:
    getFeatureSource in interface DataAccess<SimpleFeatureType,SimpleFeature>
    Returns:
    Access to the named resource being made available
    Throws:
    IOException
    Since:
    2.5
    See Also:
    DataAccess.getFeatureSource(Name)

    getNames

    public List<Name> getNames()
                        throws IOException
    Returns the same list of names than getTypeNames() meaning the returned Names have no namespace set.

    Specified by:
    getNames in interface DataAccess<SimpleFeatureType,SimpleFeature>
    Returns:
    Names of the available contents.
    Throws:
    IOException
    Since:
    2.5
    See Also:
    DataAccess.getNames()

    getSchema

    public SimpleFeatureType getSchema(Name name)
                                throws IOException
    Delegates to getSchema(String) with name.getLocalPart()

    Specified by:
    getSchema in interface DataAccess<SimpleFeatureType,SimpleFeature>
    Parameters:
    name - Type name a the resource from getNames()
    Returns:
    Description of the FeatureType being made avaialble
    Throws:
    IOException
    Since:
    2.5
    See Also:
    DataAccess.getSchema(Name)

    updateSchema

    public void updateSchema(Name typeName,
                             SimpleFeatureType featureType)
                      throws IOException
    Delegates to updateSchema(String, SimpleFeatureType) with name.getLocalPart()

    Specified by:
    updateSchema in interface DataAccess<SimpleFeatureType,SimpleFeature>
    Throws:
    IOException - if the operation failed
    Since:
    2.5
    See Also:
    DataAccess.getFeatureSource(Name)


    Copyright © 1996-2009 Geotools. All Rights Reserved.