Class JDBCFeatureSource
- All Implemented Interfaces:
FeatureSource<SimpleFeatureType,
,SimpleFeature> SimpleFeatureSource
- Direct Known Subclasses:
JoiningJDBCFeatureSource
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Hints.Key
Add this hint to the query to force the filter to be interepreted as a three-way logic filter, where null values are treated as unknowns and propagate up the filter evaluation tree (e..g,A <> NULL -> NULL
)</>.Fields inherited from class ContentFeatureSource
entry, hints, lock, query, queryCapabilities, schema, transaction
-
Constructor Summary
ConstructorsModifierConstructorDescriptionJDBCFeatureSource
(ContentEntry entry, Query query) Creates the new feature store.protected
JDBCFeatureSource
(JDBCFeatureSource featureSource) Copy existing feature source -
Method Summary
Modifier and TypeMethodDescriptionprotected void
Subclass hook too add additional hints.protected SimpleFeatureType
Builds the feature type from database metadata.protected QueryCapabilities
Builds the query capabilities for this feature source.protected boolean
Determines if the datastore can natively perform a filtering.protected boolean
Determines if the datastore can natively limit the number of features returned in a query.protected boolean
Determines if the datastore can natively skip the firstoffset
number of features returned in a query.protected boolean
Determines if the datastore can natively perform "retyping" which includes limiting the number of attributes returned and reordering of those attributesprotected boolean
Determines if the datastore can natively perform sorting.protected boolean
Determines if the store can natively manage transactions.protected ReferencedEnvelope
getBoundsInternal
(Query query) Calculates the bounds of a specified query.protected int
getCountInternal
(Query query) Calculates the number of features of a specified query.Type narrow toJDBCDataStore
.Returns the primary key of the table backed by feature store.protected FeatureReader<SimpleFeatureType,
SimpleFeature> getReaderInternal
(Query query) Subclass method for returning a native reader from the datastore.getState()
Type narrow toJDBCState
.protected boolean
handleVisitor
(Query query, FeatureVisitor visitor) Subclass method which allows subclasses to natively handle a visitor.boolean
The flag which will expose columns which compose a tables identifying or primary key, through feature type attributes.void
setExposePrimaryKeyColumns
(boolean exposePrimaryKeyColumns) Sets the flag which will expose columns which compose a tables identifying or primary key, through feature type attributes.protected Filter[]
splitFilter
(Filter original) Helper method for splitting a filter.protected Filter[]
splitFilter
(Filter original, Hints hints) Methods inherited from class ContentFeatureSource
accepts, addFeatureListener, canEvent, canFilter, canLimit, canLock, canOffset, canReproject, canRetype, canSort, doLockInternal, doUnlockInternal, getAbsoluteSchema, getBounds, getBounds, getCount, getEntry, getFeatures, getFeatures, getFeatures, getInfo, getName, getQueryCapabilities, getReader, getReader, getReader, getSchema, getSupportedHints, getTransaction, getView, getView, isView, joinQuery, lockFeatures, lockFeatures, lockFeatures, processLock, removeFeatureListener, resolvePropertyNames, resolvePropertyNames, setFeatureLock, setTransaction, unLockFeatures, unLockFeatures, unLockFeatures
-
Field Details
-
FILTER_THREE_WAY_LOGIC
Add this hint to the query to force the filter to be interepreted as a three-way logic filter, where null values are treated as unknowns and propagate up the filter evaluation tree (e..g,A <> NULL -> NULL
)</>. By default, the encoding is performed using two-way logic, where null values are treated as legitimate values (likenull
in Java). Also, warning: the hint cannot be provided toFeatureStore.removeFeatures(Filter)
as that only gets aFilter
object, rather than a query object.
-
-
Constructor Details
-
JDBCFeatureSource
Creates the new feature store.- Parameters:
entry
- The datastore entry.query
- The defining query.- Throws:
IOException
-
JDBCFeatureSource
Copy existing feature source- Parameters:
featureSource
- jdbc feature source- Throws:
IOException
-
-
Method Details
-
buildQueryCapabilities
Description copied from class:ContentFeatureSource
Builds the query capabilities for this feature source. The default implementation returns a newly built QueryCapabilities, subclasses are advised to build their own.- Overrides:
buildQueryCapabilities
in classContentFeatureSource
-
addHints
Description copied from class:ContentFeatureSource
Subclass hook too add additional hints.By default, the followings are already present:
- Overrides:
addHints
in classContentFeatureSource
- Parameters:
hints
- The set of hints supported by the feature source.
-
getDataStore
Type narrow toJDBCDataStore
.- Specified by:
getDataStore
in interfaceFeatureSource<SimpleFeatureType,
SimpleFeature> - Overrides:
getDataStore
in classContentFeatureSource
- Returns:
- the data source providing this
FeatureSource
-
getState
Type narrow toJDBCState
.- Overrides:
getState
in classContentFeatureSource
-
getPrimaryKey
Returns the primary key of the table backed by feature store. -
setExposePrimaryKeyColumns
public void setExposePrimaryKeyColumns(boolean exposePrimaryKeyColumns) Sets the flag which will expose columns which compose a tables identifying or primary key, through feature type attributes.Note: setting this flag which affect all feature sources created from or working against the current transaction.
-
isExposePrimaryKeyColumns
public boolean isExposePrimaryKeyColumns()The flag which will expose columns which compose a tables identifying or primary key, through feature type attributes. -
buildFeatureType
Builds the feature type from database metadata.- Specified by:
buildFeatureType
in classContentFeatureSource
- Throws:
IOException
-
splitFilter
Helper method for splitting a filter. -
splitFilter
-
getCountInternal
Description copied from class:ContentFeatureSource
Calculates the number of features of a specified query. Subclasses must implement this method. If the computation is not fast, it's possible to return -1.- Specified by:
getCountInternal
in classContentFeatureSource
- Throws:
IOException
-
getBoundsInternal
Description copied from class:ContentFeatureSource
Calculates the bounds of a specified query. Subclasses must implement this method. If the computation is not fast, subclasses can returnnull
.- Specified by:
getBoundsInternal
in classContentFeatureSource
- Throws:
IOException
-
canFilter
Description copied from class:ContentFeatureSource
Determines if the datastore can natively perform a filtering.If the subclass can handle filtering natively it should override this method to return
true
. In this case it must do the filtering or throw an exception. This includes the case of partial native filtering where the datastore can only handle part of the filter natively. In these cases it is up to the subclass to apply a decorator to the reader it returns which will handle any part of the filter can was not applied natively. SeeFilteringFeatureReader
.Not overriding this method or returning
false
will cause the feature reader created by the subclass to be wrapped in a filtering feature reader when the query specifies a filter. SeeFilteringFeatureReader
.- Overrides:
canFilter
in classContentFeatureSource
-
canSort
Description copied from class:ContentFeatureSource
Determines if the datastore can natively perform sorting.If the subclass can handle retyping natively it should override this method to return
true
. In this case it must do the retyping or throw an exception.Not overriding this method or returning
false
will cause an exception to be thrown when the query specifies sorting.- Overrides:
canSort
in classContentFeatureSource
- See Also:
-
canRetype
Description copied from class:ContentFeatureSource
Determines if the datastore can natively perform "retyping" which includes limiting the number of attributes returned and reordering of those attributesIf the subclass can handle retyping natively it should override this method to return
true
. In this case it must do the retyping or throw an exception.Not overriding this method or returning
false
will cause the feature reader created by the subclass to be wrapped in a retyping feature reader when the query specifies a retype.- Overrides:
canRetype
in classContentFeatureSource
- See Also:
-
canLimit
Description copied from class:ContentFeatureSource
Determines if the datastore can natively limit the number of features returned in a query.If the subclass can handle a map feature cap natively then it should override this method to return
true
. In this case it must do the cap or throw an exception.Not overriding this method or returning
false
will case the feature reader created by the subclass to be wrapped in a max feature capping decorator when the query specifies a max feature cap.- Overrides:
canLimit
in classContentFeatureSource
- See Also:
-
canOffset
Description copied from class:ContentFeatureSource
Determines if the datastore can natively skip the firstoffset
number of features returned in a query.If the subclass can handle a map feature cap natively then it should override this method to return
true
. In this case it must do the cap or throw an exception.Not overriding this method or returning
false
will case the feature reader created by the subclass to be accessed offset times before being returned to the caller.- Overrides:
canOffset
in classContentFeatureSource
-
canTransact
protected boolean canTransact()Description copied from class:ContentFeatureSource
Determines if the store can natively manage transactions.If a subclass can handle transactions natively it should override this method to return
true
and deal with transactions on its own, including firing feature modifications events.- Overrides:
canTransact
in classContentFeatureSource
- Returns:
- true if transaction independence has custom implementation
-
getReaderInternal
protected FeatureReader<SimpleFeatureType,SimpleFeature> getReaderInternal(Query query) throws IOException Description copied from class:ContentFeatureSource
Subclass method for returning a native reader from the datastore.It is important to note that if the native reader intends to handle any of the following natively:
- reprojection
- filtering
- max feature limiting
- sorting
- locking
- transactions
true
:ContentFeatureSource.canReproject()
- handlesQuery.getCoordinateSystemReproject()
internally. Example would be PostGIS using Proj to handle reproejction internallyContentFeatureSource.canFilter(Query)
- handlesinternally.</li> <li>{@link #canLimit(Query)} - handles {@link Query#getMaxFeatures()} and {@link Query#getStartIndex()} internally.</li> <li>{@link #canSort(Query)} - handles {@link Query#getSortBy()} natively.</li> <li>{@link #canRetype(Query)} - handles {@link Query#getProperties()} natively. Example would be only parsing the properties the user asks for from an XML file</li> <li>{@link #canLock()} - handles read-locks natively</li> <li>{@link #canTransact()} - handles transactions natively</li> </ul> </p>
- Specified by:
getReaderInternal
in classContentFeatureSource
- Throws:
IOException
-
handleVisitor
Description copied from class:ContentFeatureSource
Subclass method which allows subclasses to natively handle a visitor.Subclasses would override this method and return true in cases where the specific visitor could be handled without iterating over the entire result set of query. An example would be handling visitors that calculate aggregate values.
- Overrides:
handleVisitor
in classContentFeatureSource
- Parameters:
query
- The query being made.visitor
- The visitor to- Returns:
- true if the visitor can be handled natively, otherwise false.
- Throws:
IOException
-