org.geotools.data.shapefile
Class ShapefileDataStoreFactory

java.lang.Object
  extended by org.geotools.data.shapefile.ShapefileDataStoreFactory

public class ShapefileDataStoreFactory
extends Object

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.

Version:
$Id: ShapefileDataStoreFactory.java 29603 2008-03-11 22:49:05Z jgarnett $
Author:
Chris Holmes, TOPP

Field Summary
static Param CREATE_SPATIAL_INDEX
          Optional - Enable/disable the automatic creation of spatial index
static Param DBFCHARSET
          Optional - character used to decode strings from the DBF file
protected static Logger LOGGER
           
static Param MEMORY_MAPPED
          Optional - enable/disable the use of memory-mapped io
static Param NAMESPACEP
          Optional - uri of the FeatureType's namespace
static 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)
           
 DataStore createDataStore(Map params)
          Returns an instance of DataStore iff the resource pointed to the Map of paramers can be handled as a shapefile.
 DataStore createDataStore(URL url)
          We may need to create a new datastore if the provided file does not exist.
 DataStore createDataStore(URL url, boolean memorymapped)
           
 DataStore 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()
           
 String[] getFileExtensions()
           
 Map getImplementationHints()
          Returns the implementation hints.
 Param[] getParametersInfo()
          Describe parameters.
 String getTypeName(URL url)
           
 boolean isAvailable()
          Test to see if this datastore is available, if it has all the appropriate libraries to construct a datastore.
static URL toDbfURL(URL url)
          Figure out the URL for the "dbf" file
static String toFilename(URL url)
          Convert a URL to a String that is suitable for manipulation of its extension (generally the last three characters of the file).
static String toFilename(URL url, String ext)
          Convert the URL to a string that includes the provided extension (this method respects the case of the original file extension.
static URL toFixURL(URL url)
          Figure out the URL for the "fix" file
static URL toGrxURL(URL url)
          Figure out the URL for the "grx" file
static URL toPrjURL(URL url)
          Figure out the URL for the "prj" file
static URL toQixURL(URL url)
          Figure out the URL for the "qix" file
static URL toShpURL(URL url)
          Figure out the URL for the "shp" file
static URL toShxURL(URL url)
          Figure out the URL for the "shx" file
static URL toXmlURL(URL url)
          Figure out the URL for the "prj" file
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOGGER

protected static final Logger LOGGER

URLP

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


NAMESPACEP

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


MEMORY_MAPPED

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


CREATE_SPATIAL_INDEX

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


DBFCHARSET

public static final 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.

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 DataStore 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.

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 DataStore 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.

Throws:
IOException

getDisplayName

public String getDisplayName()

getDescription

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

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.

Returns:
true if and only if this factory is available to create DataStores.

getParametersInfo

public Param[] getParametersInfo()
Describe parameters.

See Also:
org.geotools.data.DataStoreFactorySpi#getParametersInfo()

getFileExtensions

public String[] getFileExtensions()
See Also:
org.geotools.data.dir.FileDataStoreFactorySpi#getFileExtensions()

canProcess

public boolean canProcess(URL f)
See Also:
org.geotools.data.dir.FileDataStoreFactorySpi#canProcess(java.net.URL)

createDataStore

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

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
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.

Returns:
An empty map.

toFilename

public static String toFilename(URL url)
                         throws MalformedURLException
Convert a URL to a String that is suitable for manipulation of its extension (generally the last three characters of the file). This uses URL.toExternalForm() in order to preserve valuable information about the URL's Authority.

Parameters:
url - the url to convert to a String. Must not be null.
Returns:
a String representation of the URL
Throws:
MalformedURLException - if the url is invalid

toFilename

public static String toFilename(URL url,
                                String ext)
                         throws MalformedURLException
Convert the URL to a string that includes the provided extension (this method respects the case of the original file extension. This implementation calls toFileName( URL ) and then knocks off the known extensions (ie "shp", "dbf", "shx") if present and makes use of the provided extension.

Parameters:
url -
ext -
Returns:
Throws:
MalformedURLException

toFixURL

public static URL toFixURL(URL url)
                    throws MalformedURLException
Figure out the URL for the "fix" file

Throws:
MalformedURLException

toQixURL

public static URL toQixURL(URL url)
                    throws MalformedURLException
Figure out the URL for the "qix" file

Throws:
MalformedURLException

toGrxURL

public static URL toGrxURL(URL url)
                    throws MalformedURLException
Figure out the URL for the "grx" file

Throws:
MalformedURLException

toXmlURL

public static URL toXmlURL(URL url)
                    throws MalformedURLException
Figure out the URL for the "prj" file

Throws:
MalformedURLException

toPrjURL

public static URL toPrjURL(URL url)
                    throws MalformedURLException
Figure out the URL for the "prj" file

Throws:
MalformedURLException

toShxURL

public static URL toShxURL(URL url)
                    throws MalformedURLException
Figure out the URL for the "shx" file

Throws:
MalformedURLException

toDbfURL

public static URL toDbfURL(URL url)
                    throws MalformedURLException
Figure out the URL for the "dbf" file

Throws:
MalformedURLException

toShpURL

public static URL toShpURL(URL url)
                    throws MalformedURLException
Figure out the URL for the "shp" file

Throws:
MalformedURLException