org.geotools.data
Class AbstractDataStoreFactory

Object
  extended by AbstractDataStoreFactory
All Implemented Interfaces:
DataAccessFactory, DataStoreFactorySpi, Factory
Direct Known Subclasses:
DB2DataStoreFactory, JDBCDataStoreFactory, PostgisDataStoreFactory, WFSDataStoreFactory

public abstract class AbstractDataStoreFactory
extends Object
implements DataStoreFactorySpi

A best of toolkit for DataStoreFactory implementors.

Will also allow me to mess with the interface API without breaking every last DataStoreFactorySpi out there.

The default implementations often hinge around the use of getParameterInfo and the correct use of Param by your subclass.

You still have to implement a few methods:


 public DataSourceMetadataEnity createMetadata( Map params ) throws IOException {
            String host = (String) HOST.lookUp(params);
      String user = (String) USER.lookUp(params);
      Integer port = (Integer) PORT.lookUp(params);
      String database = (String) DATABASE.lookUp(params);

      String description = "Connection to "+getDisplayName()+" on "+host+" as "+user ;
      return new DataSourceMetadataEnity( host+":"+port, database, description );
 }

Author:
Jody Garnett, Refractions Research
Module:
modules/library/main (gt-main.jar)

Nested Class Summary
 
Nested classes/interfaces inherited from interface DataAccessFactory
DataAccessFactory.Param
 
Constructor Summary
AbstractDataStoreFactory()
           
 
Method Summary
 boolean canProcess(Map params)
          Default implementation verifies the Map against the Param information.
 String getDisplayName()
          Default Implementation abuses the naming convention.
 Map<RenderingHints.Key,?> getImplementationHints()
          Returns the implementation hints.
 ParameterDescriptorGroup getParameters()
           
 boolean isAvailable()
          Defaults to true, only a few datastores need to check for drivers.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface DataStoreFactorySpi
createDataStore, createNewDataStore
 
Methods inherited from interface DataAccessFactory
getDescription, getParametersInfo
 

Constructor Detail

AbstractDataStoreFactory

public AbstractDataStoreFactory()
Method Detail

getDisplayName

public String getDisplayName()
Default Implementation abuses the naming convention.

Will return Foo for org.geotools.data.foo.FooFactory.

Specified by:
getDisplayName in interface DataAccessFactory
Returns:
return display name based on class name

canProcess

public boolean canProcess(Map params)
Default implementation verifies the Map against the Param information.

It will ensure that:

Why would you ever want to override this method? If you want to check that a expected file exists and is a directory.

Overrride:

 public boolean canProcess( Map params ) {
     if( !super.canProcess( params ) ){
          return false; // was not in agreement with getParametersInfo
     }
     // example check
     File file = (File) DIRECTORY.lookup( params ); // DIRECTORY is a param
     return file.exists() && file.isDirectory();
 }
 

Specified by:
canProcess in interface DataAccessFactory
Parameters:
params -
Returns:
true if params is in agreement with getParametersInfo, override for additional checks.

isAvailable

public boolean isAvailable()
Defaults to true, only a few datastores need to check for drivers.

Specified by:
isAvailable in interface DataAccessFactory
Returns:
true, override to check for drivers etc...

getParameters

public ParameterDescriptorGroup getParameters()

getImplementationHints

public Map<RenderingHints.Key,?> getImplementationHints()
Returns the implementation hints. The default implementation returns en empty map.

Specified by:
getImplementationHints in interface Factory
Returns:
The map of hints, or an empty map if none.


Copyright © 1996-2009 Geotools. All Rights Reserved.