org.geotools.data.wfs
Class WFSDataStoreFactory

Object
  extended by AbstractDataStoreFactory
      extended by WFSDataStoreFactory
All Implemented Interfaces:
DataAccessFactory, DataStoreFactorySpi, Factory

public class WFSDataStoreFactory
extends AbstractDataStoreFactory

A DataStoreFactorySpi to connect to a Web Feature Service.

Produces a WFSDataStore is the correct set of connection parameters are provided. For instance, the only mandatory one is URL.

As with all the DataStoreFactorySpi implementations, this one is not intended to be used directly but through the DataStoreFinder mechanism, so client application should not have strong dependencies over this module.

Upon a valid URL to a WFS GetCapabilities document, this factory will perform version negotiation between the server supported protocol versions and this plugin supported ones, and will return a DataStore capable of communicating with the server using the agreed WFS protocol version.

In the case the provided GetCapabilities URL explicitly contains a VERSION parameter and both the server and client support that version, that version will be used.

That said, for the time being, the current default version is 1.0.0 instead of 1.1.0, since the former is the one that supports transactions. When further development provides transaction support for the WFS 1.1.0 version, propper version negotiation capabilities will be added.

Among feeding the wfs datastore with a WFSProtocol that can handle the WFS version agreed upong the server and this client, this factory will try to provide the datastore with a WFSStrategy appropriate for the WFS implementation, if that could be somehow guessed. That is so the datastore itself nor the protocol need to worry about any implementation specific limitation or deviation from the standard the actual server may have.

Author:
dzwiers, Gabriel Roldan (TOPP)
See Also:
WFSDataStore, WFSProtocol, WFSStrategy
Module:

Nested Class Summary
static class WFSDataStoreFactory.WFSFactoryParam<T>
          A WFSDataStoreFactory.WFSFactoryParam subclass that allows to provide a default value to the lookUp method.
 
Nested classes/interfaces inherited from interface DataAccessFactory
DataAccessFactory.Param
 
Field Summary
static WFSDataStoreFactory.WFSFactoryParam<Integer> BUFFER_SIZE
          Optional Integer parameter stating how many Feature instances to buffer at once.
static WFSDataStoreFactory.WFSFactoryParam<String> ENCODING
          Optional String DataStore parameter supplying a JVM supported charset name to use as the character encoding for XML requests sent to the server.
static WFSDataStoreFactory.WFSFactoryParam<Boolean> LENIENT
          Optional Boolean DataStore parameter indicating whether to be lenient about parsing bad data
static WFSDataStoreFactory.WFSFactoryParam<Integer> MAXFEATURES
          Optional positive Integer used as a hard limit for the amount of Features to retrieve for each FeatureType.
static WFSDataStoreFactory.WFSFactoryParam<String> PASSWORD
          Optional String DataStore parameter supplying the password to use when the server requires HTTP authentication Shall be used together with USERNAME or not used at all.
protected  Map<Map,WFSDataStore> perParameterSetDataStoreCache
           
static WFSDataStoreFactory.WFSFactoryParam<Boolean> PROTOCOL
          Optional Boolean DataStore parameter acting as a hint for the HTTP protocol to use preferably against the WFS instance, with the following semantics: null (not supplied): use "AUTO", let the DataStore decide.
static WFSDataStoreFactory.WFSFactoryParam<Integer> TIMEOUT
          Optional Integer DataStore parameter indicating a timeout in milliseconds for the HTTP connections.
static WFSDataStoreFactory.WFSFactoryParam<Boolean> TRY_GZIP
          Optional Boolean data store parameter indicating whether to set the accept GZip encoding on the HTTP request headers sent to the server
static WFSDataStoreFactory.WFSFactoryParam<URL> URL
          Mandatory DataStore parameter indicating the URL for the WFS GetCapabilities document.
static WFSDataStoreFactory.WFSFactoryParam<String> USERNAME
          Optional String DataStore parameter supplying the user name to use when the server requires HTTP authentication Shall be used together with PASSWORD or not used at all.
 
Constructor Summary
WFSDataStoreFactory()
           
 
Method Summary
 boolean canProcess(Map params)
          Checks whether params contains a valid set of parameters to connecto to a WFS.
 WFSDataStore createDataStore(Map params)
          Requests the WFS Capabilities document from the url parameter in params and returns a WFSDataStore according to the version of the GetCapabilities document returned.
static URL createGetCapabilitiesRequest(URL host)
          Creates a HTTP GET Method based WFS GetCapabilities request.
static URL createGetCapabilitiesRequest(URL host, Version version)
          Creates a HTTP GET Method based WFS GetCapabilities request for the given protocol version.
 DataStore createNewDataStore(Map params)
          Unsupported operation, can't create a WFS service.
 String getDescription()
          Describe the nature of the datasource constructed by this factory.
 String getDisplayName()
          Default Implementation abuses the naming convention.
 DataAccessFactory.Param[] getParametersInfo()
          Returns the set of parameter descriptors needed to connect to a WFS.
 boolean isAvailable()
          Defaults to true, only a few datastores need to check for drivers.
 
Methods inherited from class AbstractDataStoreFactory
getImplementationHints, getParameters
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

URL

public static final WFSDataStoreFactory.WFSFactoryParam<URL> URL
Mandatory DataStore parameter indicating the URL for the WFS GetCapabilities document.


PROTOCOL

public static final WFSDataStoreFactory.WFSFactoryParam<Boolean> PROTOCOL
Optional Boolean DataStore parameter acting as a hint for the HTTP protocol to use preferably against the WFS instance, with the following semantics:


USERNAME

public static final WFSDataStoreFactory.WFSFactoryParam<String> USERNAME
Optional String DataStore parameter supplying the user name to use when the server requires HTTP authentication

Shall be used together with PASSWORD or not used at all.

See Also:
Authenticator

PASSWORD

public static final WFSDataStoreFactory.WFSFactoryParam<String> PASSWORD
Optional String DataStore parameter supplying the password to use when the server requires HTTP authentication

Shall be used together with USERNAME or not used at all.

See Also:
Authenticator

ENCODING

public static final WFSDataStoreFactory.WFSFactoryParam<String> ENCODING
Optional String DataStore parameter supplying a JVM supported charset name to use as the character encoding for XML requests sent to the server.


TIMEOUT

public static final WFSDataStoreFactory.WFSFactoryParam<Integer> TIMEOUT
Optional Integer DataStore parameter indicating a timeout in milliseconds for the HTTP connections.


BUFFER_SIZE

public static final WFSDataStoreFactory.WFSFactoryParam<Integer> BUFFER_SIZE
Optional Integer parameter stating how many Feature instances to buffer at once. Only implemented for WFS 1.0.0 support.


TRY_GZIP

public static final WFSDataStoreFactory.WFSFactoryParam<Boolean> TRY_GZIP
Optional Boolean data store parameter indicating whether to set the accept GZip encoding on the HTTP request headers sent to the server


LENIENT

public static final WFSDataStoreFactory.WFSFactoryParam<Boolean> LENIENT
Optional Boolean DataStore parameter indicating whether to be lenient about parsing bad data


MAXFEATURES

public static final WFSDataStoreFactory.WFSFactoryParam<Integer> MAXFEATURES
Optional positive Integer used as a hard limit for the amount of Features to retrieve for each FeatureType. A value of zero or not providing this parameter means no limit.


perParameterSetDataStoreCache

protected Map<Map,WFSDataStore> perParameterSetDataStoreCache
Constructor Detail

WFSDataStoreFactory

public WFSDataStoreFactory()
Method Detail

createDataStore

public WFSDataStore createDataStore(Map params)
                             throws IOException
Requests the WFS Capabilities document from the url parameter in params and returns a WFSDataStore according to the version of the GetCapabilities document returned.

Note the URL provided as parameter must refer to the actual GetCapabilities request. If you need to specify a preferred version or want the GetCapabilities request to be generated from a base URL build the URL with the createGetCapabilitiesRequest(URL, Version) first.

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.
See Also:
DataStoreFactorySpi.createDataStore(java.util.Map)

createNewDataStore

public DataStore createNewDataStore(Map params)
                             throws IOException
Unsupported operation, can't create a WFS service.

Throws:
UnsupportedOperationException - always, as this operation is not applicable to WFS.
IOException
See Also:
DataStoreFactorySpi.createNewDataStore(java.util.Map)

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.

Returns:
A human readable description that is suitable for inclusion in a list of available datasources.
See Also:
DataAccessFactory.getDescription()

getParametersInfo

public DataAccessFactory.Param[] getParametersInfo()
Returns the set of parameter descriptors needed to connect to a WFS.

Returns:
Param array describing the Map for createDataStore
See Also:
DataAccessFactory.getParametersInfo(), URL, PROTOCOL, USERNAME, PASSWORD, TIMEOUT, BUFFER_SIZE, TRY_GZIP, LENIENT, ENCODING

canProcess

public boolean canProcess(Map params)
Checks whether params contains a valid set of parameters to connecto to a WFS.

Rules are:

Availability of the other optional parameters is not checked for existence.

Specified by:
canProcess in interface DataAccessFactory
Overrides:
canProcess in class AbstractDataStoreFactory
Parameters:
params - non null map of datastore parameters.
Returns:
true if params is in agreement with getParametersInfo, override for additional checks.
See Also:
DataAccessFactory.canProcess(java.util.Map)

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
See Also:
DataAccessFactory.getDisplayName()

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, no extra or external requisites for datastore availability.
See Also:
DataAccessFactory.isAvailable()

createGetCapabilitiesRequest

public static URL createGetCapabilitiesRequest(URL host,
                                               Version version)
Creates a HTTP GET Method based WFS GetCapabilities request for the given protocol version.

If the query string in the host URL already contains a VERSION number, that version is discarded.

Parameters:
host - non null URL from which to construct the WFS GetCapabilities request by discarding the query string, if any, and appending the propper query string.
Returns:

createGetCapabilitiesRequest

public static URL createGetCapabilitiesRequest(URL host)
Creates a HTTP GET Method based WFS GetCapabilities request.

If the query string in the host URL already contains a VERSION number, that version is used, otherwise the queried version will be 1.0.0.

NOTE the default version will be 1.0.0 until the support for 1.1.0 gets stable enough for general use. If you want to use a 1.1.0 WFS you'll have to explicitly provide the VERSION=1.1.0 parameter in the GetCapabilities request meanwhile.

Parameters:
host - non null URL pointing either to a base WFS service access point, or to a full GetCapabilities request.
Returns:


Copyright © 1996-2009 Geotools. All Rights Reserved.