org.geotools.data.jdbc
Class FeatureTypeHandler

java.lang.Object
  extended byorg.geotools.data.jdbc.FeatureTypeHandler
Direct Known Subclasses:
DB2FeatureTypeHandler

public class FeatureTypeHandler
extends java.lang.Object

This class acts as a manager for FIDMappers and FeatureTypeInfo on behalf of a JDBCDataStore.
At the same time, it acts as a FeatureTypeInfo cache, with a user selectable timeout. Set the timeout to 0 if you want each request to be in-line with the actual database state, to Long.MAX_VALUE in order to make it work basically in-memory, or to an intermediate value to make requests cached allowing at the same time to keep it in-line with a changing database.

Author:
wolf

Field Summary
protected  java.util.Map featureTypeMap
           
protected  java.util.Map featureTypeTimeoutMap
           
 
Constructor Summary
FeatureTypeHandler(JDBC1DataStore store, FIDMapperFactory fmFactory, long cacheTimeOut)
          Creates a new feature type handler
 
Method Summary
 void forceRefresh()
          Forces the type handler to throw away all cached information and parse again the database on type requests
 FeatureTypeInfo getFeatureTypeInfo(java.lang.String featureTypeName)
          Retreives the FeatureTypeInfo object for a FeatureType.
 FIDMapper getFIDMapper(java.lang.String typeName)
           
 FIDMapperFactory getFIDMapperFactory()
          Returns the FIDMapperFactory used by this FeatureTypeHandler
 FeatureType getSchema(java.lang.String typeName)
          Will reverse engineer and return the schema from the database.
 java.lang.String[] getTypeNames()
          Returns a list of FeatureType names contained in the parent JDBCDataStore
 void resetFIDMappers()
          Clears the map between FeatureType name and FIDMappers
 void setFIDMapper(java.lang.String typeName, FIDMapper mapper)
           
 void setFIDMapperFactory(FIDMapperFactory factory)
          Sets the FIDMapperFactory used by this FeatureTypeHandler.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

featureTypeMap

protected java.util.Map featureTypeMap

featureTypeTimeoutMap

protected java.util.Map featureTypeTimeoutMap
Constructor Detail

FeatureTypeHandler

public FeatureTypeHandler(JDBC1DataStore store,
                          FIDMapperFactory fmFactory,
                          long cacheTimeOut)
Creates a new feature type handler

Parameters:
store - the parent data store
fmFactory - the FIDMapper factory
cacheTimeOut - timeout used to purge possibly stale data from the caches
Method Detail

getTypeNames

public java.lang.String[] getTypeNames()
                                throws java.io.IOException
Returns a list of FeatureType names contained in the parent JDBCDataStore

Returns:
Throws:
java.io.IOException

resetFIDMappers

public void resetFIDMappers()
Clears the map between FeatureType name and FIDMappers


getSchema

public FeatureType getSchema(java.lang.String typeName)
                      throws java.io.IOException
Will reverse engineer and return the schema from the database.
Performance warning: this request will always hit the database for unknown types

Parameters:
typeName -
Returns:
Throws:
java.io.IOException

getFeatureTypeInfo

public FeatureTypeInfo getFeatureTypeInfo(java.lang.String featureTypeName)
                                   throws java.io.IOException
Retreives the FeatureTypeInfo object for a FeatureType.

This allows subclasses to get access to the information about a feature type, this includes the schema and the fidColumnName.

Parameters:
featureTypeName - The name of the feature type to get the info for.
Returns:
The FeatureTypeInfo object for the named feature type or null if the feature type does not exist.
Throws:
java.io.IOException - If an error occurs creating the FeatureTypeInfo.

getFIDMapper

public FIDMapper getFIDMapper(java.lang.String typeName)
                       throws java.io.IOException
Throws:
java.io.IOException
See Also:
getFIDMapper(java.lang.String)

setFIDMapper

public void setFIDMapper(java.lang.String typeName,
                         FIDMapper mapper)
See Also:
org.geotools.data.jdbc.FeatureTypeHandler#setFIDMapper(java.lang.String)

forceRefresh

public void forceRefresh()
Forces the type handler to throw away all cached information and parse again the database on type requests


getFIDMapperFactory

public FIDMapperFactory getFIDMapperFactory()
Returns the FIDMapperFactory used by this FeatureTypeHandler

Returns:

setFIDMapperFactory

public void setFIDMapperFactory(FIDMapperFactory factory)
Sets the FIDMapperFactory used by this FeatureTypeHandler. It can't be null.

Parameters:
factory -


Copyright © GeoTools. All Rights Reserved.