org.geotools.data
Class AbstractDataStoreFactory

java.lang.Object
  extended byorg.geotools.data.AbstractDataStoreFactory
All Implemented Interfaces:
DataStoreFactorySpi, Factory
Direct Known Subclasses:
DB2DataStoreFactory, PostgisDataStoreFactory, WFSDataStoreFactory

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

Nested Class Summary
 
Nested classes inherited from class org.geotools.data.DataStoreFactorySpi
DataStoreFactorySpi.Param
 
Constructor Summary
AbstractDataStoreFactory()
           
 
Method Summary
 boolean canProcess(java.util.Map params)
          Default implementation verifies the Map against the Param information.
 java.lang.String getDisplayName()
          Default Implementation abuses the naming convention.
 java.util.Map getImplementationHints()
          Returns the implementation hints.
 org.opengis.parameter.ParameterDescriptorGroup getParameters()
           
 boolean isAvailable()
          Defaults to true, only a few datastores need to check for drivers.
 
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.DataStoreFactorySpi
createDataStore, createNewDataStore, getDescription, getParametersInfo
 

Constructor Detail

AbstractDataStoreFactory

public AbstractDataStoreFactory()
Method Detail

getDisplayName

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

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

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

canProcess

public boolean canProcess(java.util.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 DataStoreFactorySpi
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 DataStoreFactorySpi
Returns:
true, override to check for drivers etc...

getParameters

public org.opengis.parameter.ParameterDescriptorGroup getParameters()

getImplementationHints

public java.util.Map 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 © GeoTools. All Rights Reserved.