org.geotools.data.store
Class AbstractDataStore2

Object
  extended by AbstractDataStore2
All Implemented Interfaces:
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   (gt2-main.jar) (Maven report) (SVN head)

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(FeatureType 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 getFeatureReader(Query query, Transaction transaction)
          Access a FeatureReader providing access to Feature information.
 FeatureSource getFeatureSource(String typeName)
          Aqure FeatureSource for indicated typeName.
 FeatureWriter getFeatureWriter(String typeName, Filter filter, Transaction transaction)
          Access FeatureWriter for modification of existing DataStore contents.
 FeatureWriter getFeatureWriter(String typeName, Transaction transaction)
          TODO summary sentence for getFeatureWriter ...
 FeatureWriter getFeatureWriterAppend(String typeName, Transaction transaction)
          FeatureWriter setup to add new content.
 LockingManager getLockingManager()
          Locking manager used for this DataStore.
 FeatureType getSchema(String typeName)
          Retrive schema information for typeName
 String[] getTypeNames()
          Convience method for retriving all the names from the Catalog Entires
 FeatureSource getView(Query query)
          Create a FeatureSource that represents your Query.
 void updateSchema(String typeName, FeatureType 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)

getSchema

public FeatureType 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(FeatureType featureType)
                  throws IOException
Subclass should implement to provide for creation.

Specified by:
createSchema in interface DataStore
Parameters:
featureType - Requested FeatureType
Throws:
IOException - Subclass may throw IOException
UnsupportedOperationException - Subclass may implement

updateSchema

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

Specified by:
updateSchema in interface DataStore
Throws:
IOException

getView

public FeatureSource 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 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 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:

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 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 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 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 DataStore


    Copyright © 1996-2008 Geotools. All Rights Reserved.