org.geotools.data.shapefile
Class ShapefileDataStoreFactory

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

public class ShapefileDataStoreFactory
extends Object
implements FileDataStoreFactorySpi

Implementation of the DataStore service provider interface for Shapefiles.

The specific implementation of ShapefileDataStore created by this class is not specified. For more information on the connection parameters please review the following public Param constants.

Author:
Chris Holmes, TOPP
Module:
modules/plugin/shapefile (gt-shapefile.jar)

Nested Class Summary
 
Nested classes/interfaces inherited from interface DataAccessFactory
DataAccessFactory.Param
 
Field Summary
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 Logger LOGGER
           
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)
          Takes a map of parameters which describes how to access a DataStore and determines if it can be read by the ShapefileDataStore or IndexedShapefileDataStore implementations.
 boolean canProcess(URL f)
          Tests if the provided url can be handled by this factory.
 ShapefileDataStore createDataStore(Map params)
          Returns an instance of DataStore iff the resource pointed to the Map of paramers can be handled as a shapefile.
 FileDataStore createDataStore(URL url)
          We may need to create a new datastore if the provided file does not exist.
 DataStore createDataStore(URL url, boolean memorymapped)
           
 FileDataStore createNewDataStore(Map params)
          Creates a new DataStore - for a file that does not exist yet.
 String getDescription()
          Describes the type of data the datastore returned by this factory works with.
 String getDisplayName()
          Name suitable for display to end user.
 String[] getFileExtensions()
          The list of filename extentions handled by this factory.
 Map getImplementationHints()
          Returns the implementation hints.
 DataAccessFactory.Param[] getParametersInfo()
          Describe parameters.
 String getTypeName(URL url)
          The typeName represented by the provided url.
 boolean isAvailable()
          Test to see if this datastore is available, if it has all the appropriate libraries to construct a datastore.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOGGER

public static final Logger LOGGER

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


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

Constructor Detail

ShapefileDataStoreFactory

public ShapefileDataStoreFactory()
Method Detail

canProcess

public boolean canProcess(Map params)
Takes a map of parameters which describes how to access a DataStore and determines if it can be read by the ShapefileDataStore or IndexedShapefileDataStore implementations.

Specified by:
canProcess in interface DataAccessFactory
Parameters:
params - A map of parameters describing the location of a datastore. Files should be pointed to by a 'url' param.
Returns:
true iff params contains a url param which points to a file ending in shp

createDataStore

public ShapefileDataStore createDataStore(Map params)
                                   throws IOException
Returns an instance of DataStore iff the resource pointed to the Map of paramers can be handled as a shapefile.

The specific implementation of ShapefileDataStore returned is not specified, and depends on the parameters given. For more information please review the public static Param instances available for this class.

Specified by:
createDataStore in interface DataAccessFactory
Specified by:
createDataStore in interface DataStoreFactorySpi
Parameters:
params - A param list with information on the location of a restore. For shapefiles this should contain a 'url' param which points to a file which ends in shp.
Returns:
DataStore A ShapefileDatastore
Throws:
IOException - If a connection error (such as the file not existing occurs)
DataSourceException - Thrown if the datastore which is created cannot be attached to the restore specified in params.

createNewDataStore

public FileDataStore createNewDataStore(Map params)
                                 throws IOException
Creates a new DataStore - for a file that does not exist yet.

This method has different logic than createDataStore. It is willing to be memory mapped, and generate an index for a local file that does not exist yet.

Specified by:
createNewDataStore in interface DataStoreFactorySpi
Throws:
IOException

getDisplayName

public String getDisplayName()
Description copied from interface: DataAccessFactory
Name suitable for display to end user.

A non localized display name for this data store type.

Specified by:
getDisplayName in interface DataAccessFactory
Returns:
A short name suitable for display in a user interface.

getDescription

public String getDescription()
Describes the type of data the datastore returned by this factory works with.

Specified by:
getDescription in interface DataAccessFactory
Returns:
String a human readable description of the type of restore supported by this datastore.

isAvailable

public boolean isAvailable()
Test to see if this datastore is available, if it has all the appropriate libraries to construct a datastore. This datastore just checks for the ShapefileDataStore, IndexedShapefileDataStore and Geometry implementations.

Specified by:
isAvailable in interface DataAccessFactory
Returns:
true if and only if this factory is available to create DataStores.

getParametersInfo

public DataAccessFactory.Param[] getParametersInfo()
Describe parameters.

Specified by:
getParametersInfo in interface DataAccessFactory
Returns:
Param array describing the Map for createDataStore
See Also:
DataAccessFactory.getParametersInfo()

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.
See Also:
org.geotools.data.dir.FileDataStoreFactorySpi#getFileExtensions()

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
See Also:
org.geotools.data.dir.FileDataStoreFactorySpi#canProcess(java.net.URL)

createDataStore

public FileDataStore createDataStore(URL url)
                              throws IOException
We may need to create a new datastore if the provided file does not exist.

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:
org.geotools.data.dir.FileDataStoreFactorySpi#createDataStore(java.net.URL)

createDataStore

public DataStore createDataStore(URL url,
                                 boolean memorymapped)
                          throws IOException
Throws:
IOException
See Also:
org.geotools.data.dir.FileDataStoreFactorySpi#createDataStore(java.net.URL)

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
See Also:
org.geotools.data.dir.FileDataStoreFactorySpi#getTypeName(java.net.URL)

getImplementationHints

public Map getImplementationHints()
Returns the implementation hints. The default implementation returns an empty map.

When we have FeatureFactory, GeometryFactory and so on hooked up this map will return Hints we paid attention too when we were constructed.

Specified by:
getImplementationHints in interface Factory
Returns:
An empty map.


Copyright © 1996-2009 Geotools. All Rights Reserved.