org.geotools.data.shapefile
Class ShapefileDataStoreFactory

Object
  extended by AbstractDataStoreFactory
      extended by ShapefileDataStoreFactory
All Implemented Interfaces:
DataAccessFactory, DataStoreFactorySpi, FileDataStoreFactorySpi, Factory
Direct Known Subclasses:
ShapefileDirectoryFactory

public class ShapefileDataStoreFactory
extends AbstractDataStoreFactory
implements FileDataStoreFactorySpi

Builds instances of the shapefile data store


Nested Class Summary
static class ShapefileDataStoreFactory.ShpFileStoreFactory
          A delegates that allow to build a directory of shapfiles store
 
Nested classes/interfaces inherited from interface DataAccessFactory
DataAccessFactory.Param
 
Field Summary
static DataAccessFactory.Param CACHE_MEMORY_MAPS
          Optional - enable/disable the use of memory-mapped io
static DataAccessFactory.Param CREATE_SPATIAL_INDEX
          Optional - Enable/disable the automatic creation of spatial index
static DataAccessFactory.Param DBFCHARSET
          Optional - character used to decode strings from the DBF file
static DataAccessFactory.Param DBFTIMEZONE
          Optional - timezone to decode dates from the DBF file
static DataAccessFactory.Param ENABLE_SPATIAL_INDEX
          Optional - enable spatial index for local files
static DataAccessFactory.Param FILE_TYPE
          Optional - discriminator for directory stores
static DataAccessFactory.Param FSTYPE
          Optional parameter used to indicate 'shape-ng' (as a marker to select the implementation of DataStore to use).
static DataAccessFactory.Param MEMORY_MAPPED
          Optional - enable/disable the use of memory-mapped io
static DataAccessFactory.Param NAMESPACEP
          Optional - uri of the FeatureType's namespace
static DataAccessFactory.Param URLP
          url to the .shp file.
 
Constructor Summary
ShapefileDataStoreFactory()
           
 
Method Summary
 boolean canProcess(Map params)
          Default implementation verifies the Map against the Param information.
 boolean canProcess(URL f)
          Tests if the provided url can be handled by this factory.
 DataStore createDataStore(Map<String,Serializable> params)
          Construct a live data source using the params specifed.
 FileDataStore createDataStore(URL url)
          A DataStore attached to the provided url, may be created if needed.
 DataStore createNewDataStore(Map<String,Serializable> params)
           
 String getDescription()
          Describe the nature of the datasource constructed by this factory.
 String getDisplayName()
          Default Implementation abuses the naming convention.
 String[] getFileExtensions()
          The list of filename extentions handled by this factory.
 Map<RenderingHints.Key,?> getImplementationHints()
          Returns the implementation hints.
 DataAccessFactory.Param[] getParametersInfo()
          MetaData about the required Parameters (for createDataStore).
 String getTypeName(URL url)
          The typeName represented by the provided url.
 boolean isAvailable()
          Defaults to true, only a few datastores need to check for drivers.
 
Methods inherited from class AbstractDataStoreFactory
getParameters
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

URLP

public static final DataAccessFactory.Param URLP
url to the .shp file.


NAMESPACEP

public static final DataAccessFactory.Param NAMESPACEP
Optional - uri of the FeatureType's namespace


MEMORY_MAPPED

public static final DataAccessFactory.Param MEMORY_MAPPED
Optional - enable/disable the use of memory-mapped io


CACHE_MEMORY_MAPS

public static final DataAccessFactory.Param CACHE_MEMORY_MAPS
Optional - enable/disable the use of memory-mapped io


FILE_TYPE

public static final DataAccessFactory.Param FILE_TYPE
Optional - discriminator for directory stores


CREATE_SPATIAL_INDEX

public static final DataAccessFactory.Param CREATE_SPATIAL_INDEX
Optional - Enable/disable the automatic creation of spatial index


DBFCHARSET

public static final DataAccessFactory.Param DBFCHARSET
Optional - character used to decode strings from the DBF file


FSTYPE

public static final DataAccessFactory.Param FSTYPE
Optional parameter used to indicate 'shape-ng' (as a marker to select the implementation of DataStore to use).


DBFTIMEZONE

public static final DataAccessFactory.Param DBFTIMEZONE
Optional - timezone to decode dates from the DBF file


ENABLE_SPATIAL_INDEX

public static final DataAccessFactory.Param ENABLE_SPATIAL_INDEX
Optional - enable spatial index for local files

Constructor Detail

ShapefileDataStoreFactory

public ShapefileDataStoreFactory()
Method Detail

getDisplayName

public String getDisplayName()
Description copied from class: AbstractDataStoreFactory
Default Implementation abuses the naming convention.

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

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

getDescription

public String getDescription()
Description copied from interface: DataAccessFactory
Describe the nature of the datasource constructed by this factory.

A non localized description of this data store type.

Specified by:
getDescription in interface DataAccessFactory
Returns:
A human readable description that is suitable for inclusion in a list of available datasources.

getParametersInfo

public DataAccessFactory.Param[] getParametersInfo()
Description copied from interface: DataAccessFactory
MetaData about the required Parameters (for createDataStore).

Interpretation of FeatureDescriptor values:

This should be the same as:


 Object params = factory.getParameters();
 BeanInfo info = getBeanInfo( params );

 return info.getPropertyDescriptors();
 

Specified by:
getParametersInfo in interface DataAccessFactory
Returns:
Param array describing the Map for createDataStore

isAvailable

public boolean isAvailable()
Description copied from class: AbstractDataStoreFactory
Defaults to true, only a few datastores need to check for drivers.

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

getImplementationHints

public Map<RenderingHints.Key,?> getImplementationHints()
Description copied from class: AbstractDataStoreFactory
Returns the implementation hints. The default implementation returns en empty map.

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

createDataStore

public DataStore createDataStore(Map<String,Serializable> params)
                          throws IOException
Description copied from interface: DataStoreFactorySpi
Construct a live data source using the params specifed.

You can think of this as setting up a connection to the back end data source.

Magic Params: the following params are magic and are honoured by convention by the GeoServer and uDig application.

  • "user": is taken to be the user name
  • "passwd": is taken to be the password
  • "namespace": is taken to be the namespace prefix (and will be kept in sync with GeoServer namespace management.
When we eventually move over to the use of OpperationalParam we will have to find someway to codify this convention.

Specified by:
createDataStore in interface DataAccessFactory
Specified by:
createDataStore in interface DataStoreFactorySpi
Parameters:
params - The full set of information needed to construct a live data store. Typical key values for the map include: url - location of a resource, used by file reading datasources. dbtype - the type of the database to connect to, e.g. postgis, mysql
Returns:
The created DataStore, this may be null if the required resource was not found or if insufficent parameters were given. Note that canProcess() should have returned false if the problem is to do with insuficent parameters.
Throws:
IOException - if there were any problems setting up (creating or connecting) the datasource.

createNewDataStore

public DataStore createNewDataStore(Map<String,Serializable> params)
                             throws IOException
Specified by:
createNewDataStore in interface DataStoreFactorySpi
Throws:
IOException

canProcess

public boolean canProcess(Map params)
Description copied from class: AbstractDataStoreFactory
Default implementation verifies the Map against the Param information.

It will ensure that:

  • params is not null
  • Everything is of the correct type (or upcovertable to the correct type without Error)
  • Required Parameters are present

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
Overrides:
canProcess in class AbstractDataStoreFactory
Parameters:
params - The full set of information needed to construct a live data source.
Returns:
true if params is in agreement with getParametersInfo, override for additional checks.

canProcess

public boolean canProcess(URL f)
Description copied from interface: FileDataStoreFactorySpi
Tests if the provided url can be handled by this factory.

Specified by:
canProcess in interface FileDataStoreFactorySpi
Parameters:
f - URL to a real file (may not be local)
Returns:
true if this url can when this dataStore can resolve and read the data specified

getFileExtensions

public String[] getFileExtensions()
Description copied from interface: FileDataStoreFactorySpi
The list of filename extentions handled by this factory.

Specified by:
getFileExtensions in interface FileDataStoreFactorySpi
Returns:
List of file extensions which can be read by this dataStore.

createDataStore

public FileDataStore createDataStore(URL url)
                              throws IOException
Description copied from interface: FileDataStoreFactorySpi
A DataStore attached to the provided url, may be created if needed.

Please note that additional configuration options may be available via the traditional createDataStore( Map ) method provided by the superclass.

Specified by:
createDataStore in interface FileDataStoreFactorySpi
Parameters:
url - The data location for the
Returns:
Returns an AbstractFileDataStore created from the data source provided.
Throws:
IOException
See Also:
AbstractFileDataStore

getTypeName

public String getTypeName(URL url)
                   throws IOException
Description copied from interface: FileDataStoreFactorySpi
The typeName represented by the provided url.

Specified by:
getTypeName in interface FileDataStoreFactorySpi
Parameters:
url - The location of the datum to parse into features
Returns:
Returns the typename of the datum specified (on occasion this may involve starting the parse as well to get the FeatureType -- may not be instantanious).
Throws:
IOException


Copyright © 1996-2014 Geotools. All Rights Reserved.