org.geotools.data.directory
Class DirectoryFeatureLocking

java.lang.Object
  extended by org.geotools.data.directory.DirectoryFeatureStore
      extended by org.geotools.data.directory.DirectoryFeatureLocking
All Implemented Interfaces:
FeatureLocking<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature>, FeatureSource<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature>, FeatureStore<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature>

public class DirectoryFeatureLocking
extends DirectoryFeatureStore
implements FeatureLocking<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature>


Nested Class Summary
 
Nested classes/interfaces inherited from interface org.geotools.data.FeatureLocking
FeatureLocking.Response
 
Constructor Summary
DirectoryFeatureLocking(FeatureLocking<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature> locking, DirectoryDataStore dataStore)
           
 
Method Summary
 void addFeatureListener(FeatureListener listener)
          Adds a listener to the list that's notified each time a change to the FeatureStore occurs.
 ReferencedEnvelope getBounds()
          Gets the bounding box of this datasource.
 ReferencedEnvelope getBounds(Query query)
          Gets the bounding box of the features that would be returned by this query.
 int getCount(Query query)
          Gets the number of the features that would be returned by this query.
 DataAccess<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature> getDataStore()
          Access to the DataStore implementing this FeatureStore.
 FeatureCollection<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature> getFeatures()
          Loads all features from the datasource into the return FeatureResults.
 FeatureCollection<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature> getFeatures(org.opengis.filter.Filter filter)
          Loads features from the datasource into the returned FeatureResults, based on the passed filter.
 FeatureCollection<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature> getFeatures(Query query)
          Loads features from the datasource into the returned FeatureResults, based on the passed query.
 ResourceInfo getInfo()
          Information describing the contents of this resoruce.
 org.opengis.feature.type.Name getName()
          Returns the qualified name for the Features this FeatureSource serves.
 QueryCapabilities getQueryCapabilities()
          Returns and indication of what query capabilities this FeatureSource supports natively.
 org.opengis.feature.simple.SimpleFeatureType getSchema()
          Retrieves the featureType that features extracted from this datasource will be created with.
 java.util.Set<java.awt.RenderingHints.Key> getSupportedHints()
          Returns the set of hints this FeatureSource is able to support.
 int lockFeatures()
          FeatureLock all Features.
 int lockFeatures(org.opengis.filter.Filter filter)
          FeatureLock features described by Filter.
 int lockFeatures(Query query)
          FeatureLock features described by Query.
 void setFeatureLock(FeatureLock lock)
          All locking operations will operate against the provided lock.
 void unLockFeatures()
          Unlocks all Features.
 void unLockFeatures(org.opengis.filter.Filter filter)
          Unlock Features denoted by provided filter.
 void unLockFeatures(Query query)
          Unlock Features denoted by provided query.
 
Methods inherited from class org.geotools.data.directory.DirectoryFeatureStore
addFeatures, getTransaction, modifyFeatures, modifyFeatures, removeFeatureListener, removeFeatures, setFeatures, setTransaction
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.geotools.data.FeatureStore
addFeatures, getTransaction, modifyFeatures, modifyFeatures, removeFeatures, setFeatures, setTransaction
 
Methods inherited from interface org.geotools.data.FeatureSource
addFeatureListener, getBounds, getBounds, getCount, getDataStore, getFeatures, getFeatures, getFeatures, getInfo, getName, getQueryCapabilities, getSchema, getSupportedHints, removeFeatureListener
 

Constructor Detail

DirectoryFeatureLocking

public DirectoryFeatureLocking(FeatureLocking<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature> locking,
                               DirectoryDataStore dataStore)
Method Detail

lockFeatures

public int lockFeatures()
                 throws java.io.IOException
Description copied from interface: FeatureLocking
FeatureLock all Features.

The method does not prevent addFeatures() from being used (we could add a lockDataSource() method if this functionality is required.

Specified by:
lockFeatures in interface FeatureLocking<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature>
Returns:
Number of Features locked by this opperation
Throws:
java.io.IOException

lockFeatures

public int lockFeatures(org.opengis.filter.Filter filter)
                 throws java.io.IOException
Description copied from interface: FeatureLocking
FeatureLock features described by Filter.

To implement WFS parcial Locking retrieve your features with a query operation first before trying to lock them individually. If you are not into WFS please don't ask what parcial locking is.

Specified by:
lockFeatures in interface FeatureLocking<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature>
Parameters:
filter - Filter describing the features to lock
Returns:
Number of features locked
Throws:
java.io.IOException - Thrown if anything goes wrong

setFeatureLock

public void setFeatureLock(FeatureLock lock)
Description copied from interface: FeatureLocking
All locking operations will operate against the provided lock.

This in in keeping with the stateful spirit of DataSource in which operations are against the "current" transaction. If a FeatureLock is not provided lock operations will only be applicable for the current transaction (they will expire on the next commit or rollback).

That is lockFeatures() operations will:

Calling this method with setFeatureLock( FeatureLock.TRANSACTION ) will revert to per transaction operation.

This design allows for the following:

Specified by:
setFeatureLock in interface FeatureLocking<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature>
Parameters:
lock - DOCUMENT ME!

lockFeatures

public int lockFeatures(Query query)
                 throws java.io.IOException
Description copied from interface: FeatureLocking
FeatureLock features described by Query.

To implement WFS parcial Locking retrieve your features with a query operation first before trying to lock them individually. If you are not into WFS please don't ask what parcial locking is.

Specified by:
lockFeatures in interface FeatureLocking<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature>
Parameters:
query - Query describing the features to lock
Returns:
Number of features locked
Throws:
java.io.IOException - Thrown if anything goes wrong

unLockFeatures

public void unLockFeatures()
                    throws java.io.IOException
Description copied from interface: FeatureLocking
Unlocks all Features.

Authorization must be provided prior before calling this method.


 void releaseLock( String lockId, LockingDataSource ds ){
    ds.setAuthorization( "LOCK534" );
    ds.unLockFeatures();
 }
 

Specified by:
unLockFeatures in interface FeatureLocking<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature>
Throws:
java.io.IOException

unLockFeatures

public void unLockFeatures(org.opengis.filter.Filter filter)
                    throws java.io.IOException
Description copied from interface: FeatureLocking
Unlock Features denoted by provided filter.

Authorization must be provided prior before calling this method.

Specified by:
unLockFeatures in interface FeatureLocking<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature>
Throws:
java.io.IOException

unLockFeatures

public void unLockFeatures(Query query)
                    throws java.io.IOException
Description copied from interface: FeatureLocking
Unlock Features denoted by provided query.

Authorization must be provided prior before calling this method.

Specified by:
unLockFeatures in interface FeatureLocking<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature>
Parameters:
query - Specifies fatures to unlock
Throws:
java.io.IOException

addFeatureListener

public void addFeatureListener(FeatureListener listener)
Description copied from interface: FeatureSource
Adds a listener to the list that's notified each time a change to the FeatureStore occurs.

Specified by:
addFeatureListener in interface FeatureSource<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature>
Parameters:
listener - FeatureListener

getBounds

public ReferencedEnvelope getBounds()
                             throws java.io.IOException
Description copied from interface: FeatureSource
Gets the bounding box of this datasource.

With getBounds(Query) this becomes a convenience method for getBounds(Query.ALL), that is the bounds for all features contained here.

If getBounds() returns null due to expense consider using getFeatures().getBounds() as a an alternative.

Specified by:
getBounds in interface FeatureSource<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature>
Returns:
The bounding box of the datasource or null if unknown and too expensive for the method to calculate.
Throws:
java.io.IOException - if there are errors getting the bounding box.

getBounds

public ReferencedEnvelope getBounds(Query query)
                             throws java.io.IOException
Description copied from interface: FeatureSource
Gets the bounding box of the features that would be returned by this query.

To retrieve the bounds of the DataSource please use getBounds( Query.ALL ).

This method is needed if we are to stream features to a gml out, since a FeatureCollection must have a boundedBy element.

If getBounds(Query) returns null due to expense consider using getFeatures(Query).getBounds() as a an alternative.

Specified by:
getBounds in interface FeatureSource<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature>
Parameters:
query - Contains the Filter, and optionally MaxFeatures and StartIndex to find the bounds for.
Returns:
The bounding box of the datasource or null if unknown and too expensive for the method to calculate or any errors occur.
Throws:
java.io.IOException - DOCUMENT ME!

getCount

public int getCount(Query query)
             throws java.io.IOException
Description copied from interface: FeatureSource
Gets the number of the features that would be returned by this query.

If getBounds(Query) returns -1 due to expense consider using getFeatures(Query).getCount() as a an alternative.

This method should take into account the Query's maxFeatures and startIndex, if present, in order to consistently return the number of features the query would return.

Specified by:
getCount in interface FeatureSource<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature>
Parameters:
query - Contains the Filter, and optionally MaxFeatures and StartIndex to find the count for.
Returns:
The number of Features provided by the Query or -1 if count is too expensive to calculate or any errors or occur.
Throws:
java.io.IOException - if there are errors getting the count

getDataStore

public DataAccess<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature> getDataStore()
Description copied from interface: FeatureSource
Access to the DataStore implementing this FeatureStore.

Specified by:
getDataStore in interface FeatureSource<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature>
Returns:
DataStore implementing this FeatureStore

getFeatures

public FeatureCollection<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature> getFeatures()
                                                                                                                     throws java.io.IOException
Description copied from interface: FeatureSource
Loads all features from the datasource into the return FeatureResults.

Filter.INCLUDE can also be used to get all features. Calling this function is equivalent to using Query.ALL

Specified by:
getFeatures in interface FeatureSource<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature>
Returns:
Collection The collection to put the features into.
Throws:
java.io.IOException - For all data source errors.

getFeatures

public FeatureCollection<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature> getFeatures(org.opengis.filter.Filter filter)
                                                                                                                     throws java.io.IOException
Description copied from interface: FeatureSource
Loads features from the datasource into the returned FeatureResults, based on the passed filter.

Specified by:
getFeatures in interface FeatureSource<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature>
Parameters:
filter - An OpenGIS filter; specifies which features to retrieve. null is not allowed, use Filter.INCLUDE instead.
Returns:
Collection The collection to put the features into.
Throws:
java.io.IOException - For all data source errors.

getFeatures

public FeatureCollection<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature> getFeatures(Query query)
                                                                                                                     throws java.io.IOException
Description copied from interface: FeatureSource
Loads features from the datasource into the returned FeatureResults, based on the passed query.

Specified by:
getFeatures in interface FeatureSource<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature>
Parameters:
query - a datasource query object. It encapsulates requested information, such as typeName, maxFeatures and filter.
Returns:
Collection The collection to put the features into.
Throws:
java.io.IOException - For all data source errors.
See Also:
Query

getInfo

public ResourceInfo getInfo()
Description copied from interface: FeatureSource
Information describing the contents of this resoruce.

Please note that for FeatureContent:


getName

public org.opengis.feature.type.Name getName()
Description copied from interface: FeatureSource
Returns the qualified name for the Features this FeatureSource serves.

Note this is different from getSchema().getType().getName() (that is, the feature type name), this name specifies the AttributeDescriptor name for the Features served by this source. So, FeatureSoruce.getName() == FeatureSource.getFeatures().next().getAttributeDescriptor().getName().

Though it's a common practice when dealing with SimpleFeatureType and SimpleFeature to assume they're equal. There's no conflict (as per the dynamic typing system the org.opengis.feature package defines) in a Feature and its type sharing the same name, as well as in a GML schema an element declaration and a type definition may be named the same. Yet, the distinction becomes important as we get rid of that assumption and thus allow to reuse a type definition for different FeatureSoruces, decoupling the descriptor (homologous to the Feature element declaration in a GML schema) from its type definition.

So, even if implementors are allowed to delegate to getSchema().getName() if they want to call the fatures and their type the same, client code asking a DataAccess.getFeatureSource(Name) shall use this name to request for a FeatureSource, rather than the type name, as used in pre 2.5 versions of GeoTools. For example, if we have a FeatureSource named Roads and its type is named Roads_Type, the DataAccess shall be queried through Roads, not Roads_Type.

Specified by:
getName in interface FeatureSource<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature>
Returns:
the name of the AttributeDescriptor for the Features served by this FeatureSource

getQueryCapabilities

public QueryCapabilities getQueryCapabilities()
Description copied from interface: FeatureSource
Returns and indication of what query capabilities this FeatureSource supports natively.

Specified by:
getQueryCapabilities in interface FeatureSource<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature>
Returns:
a QueryCapabilities object containing the native query capabilities.

getSchema

public org.opengis.feature.simple.SimpleFeatureType getSchema()
Description copied from interface: FeatureSource
Retrieves the featureType that features extracted from this datasource will be created with.

The schema returned is the LCD supported by all available Features. In the common case of shapfiles and database table this schema will match that of every feature available. In the degenerate GML case this will simply reflect the gml:AbstractFeatureType.

Specified by:
getSchema in interface FeatureSource<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature>
Returns:
the schema of features created by this datasource.

getSupportedHints

public java.util.Set<java.awt.RenderingHints.Key> getSupportedHints()
Description copied from interface: FeatureSource
Returns the set of hints this FeatureSource is able to support.

Hints are to be specified in the Query, for each data access where they may be required.
Depending on the actual value provide by the user, the FeatureSource may decide not to honor the hint.

Specified by:
getSupportedHints in interface FeatureSource<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature>
Returns:
a set of RenderingHints#Key objects (eventually empty, never null).


Copyright © 1996-2010 Geotools. All Rights Reserved.