org.geotools.data.store
Class AbstractDataStore2

java.lang.Object
  extended byorg.geotools.data.store.AbstractDataStore2
All Implemented Interfaces:
DataStore

public class AbstractDataStore2
extends java.lang.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

Field Summary
protected static java.util.logging.Logger LOGGER
          The logger for the filter module.
 
Constructor Summary
AbstractDataStore2()
          Default (Writeable) DataStore
 
Method Summary
protected  java.util.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.
 java.util.List entries()
          List of ActiveTypeEntry entries - one for each featureType provided by this Datastore
 org.geotools.data.store.ActiveTypeEntry entry(java.lang.String typeName)
           
 FeatureReader getFeatureReader(Query query, Transaction transaction)
          Access a FeatureReader providing access to Feature information.
 FeatureSource getFeatureSource(java.lang.String typeName)
          Aqure FeatureSource for indicated typeName.
 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)
          TODO summary sentence for getFeatureWriter ...
 FeatureWriter getFeatureWriterAppend(java.lang.String typeName, Transaction transaction)
          FeatureWriter setup to add new content.
 LockingManager getLockingManager()
          Locking manager used for this DataStore.
 FeatureType getSchema(java.lang.String typeName)
          Retrive schema information for typeName
 java.lang.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(java.lang.String typeName, FeatureType featureType)
          Subclass should implement to provide modification support.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOGGER

protected static final java.util.logging.Logger LOGGER
The logger for the filter 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 java.util.List entries()
List of ActiveTypeEntry entries - one for each featureType provided by this Datastore


createContents

protected java.util.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 java.lang.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 org.geotools.data.store.ActiveTypeEntry entry(java.lang.String typeName)

getSchema

public FeatureType getSchema(java.lang.String typeName)
                      throws java.io.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:
java.io.IOException - If typeName cannot be found

createSchema

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

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

updateSchema

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

Specified by:
updateSchema in interface DataStore
Parameters:
typeName -
Throws:
java.io.IOException

getView

public FeatureSource getView(Query query)
                      throws java.io.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
Returns:
FeatureSource providing opperations for featureType
Throws:
SchemaException - If fetureType is not covered by existing schema
java.io.IOException - If FeatureSource is not available

getFeatureSource

public FeatureSource getFeatureSource(java.lang.String typeName)
                               throws java.io.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
Parameters:
typeName -
Returns:
FeatureSource (or subclass) providing opperations for typeName
Throws:
java.io.IOException

getFeatureReader

public FeatureReader getFeatureReader(Query query,
                                      Transaction transaction)
                               throws java.io.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 opperates against
    Returns:
    FeatureReader Allows Sequential Processing of featureType
    Throws:
    java.io.IOException

  • getFeatureWriter

    public FeatureWriter getFeatureWriter(java.lang.String typeName,
                                          Filter filter,
                                          Transaction transaction)
                                   throws java.io.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.ALL 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 opperates against
    Returns:
    FeatureWriter Allows Sequential Modification of featureType
    Throws:
    java.io.IOException

    getFeatureWriter

    public FeatureWriter getFeatureWriter(java.lang.String typeName,
                                          Transaction transaction)
                                   throws java.io.IOException
    TODO summary sentence for getFeatureWriter ...

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

    getFeatureWriterAppend

    public FeatureWriter getFeatureWriterAppend(java.lang.String typeName,
                                                Transaction transaction)
                                         throws java.io.IOException
    FeatureWriter setup to add new content.

    Specified by:
    getFeatureWriterAppend in interface DataStore
    Parameters:
    typeName -
    transaction -
    Returns:
    FeatureWriter already skipped to the end
    Throws:
    java.io.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:
    See Also:
    DataStore.getLockingManager()


    Copyright © GeoTools. All Rights Reserved.