org.geotools.data.wfs
Class WFSDataStore

java.lang.Object
  extended byorg.geotools.data.AbstractDataStore
      extended byorg.geotools.data.wfs.WFSDataStore
All Implemented Interfaces:
DataStore

public class WFSDataStore
extends AbstractDataStore

DOCUMENT ME!

Author:
dzwiers

Field Summary
protected  java.net.Authenticator auth
           
protected static int AUTO_PROTOCOL
           
protected  WFSCapabilities capabilities
           
protected static int GET_PROTOCOL
           
protected static int POST_PROTOCOL
           
protected  int protocol
           
 
Fields inherited from class org.geotools.data.AbstractDataStore
isWriteable, listenerManager, LOGGER
 
Constructor Summary
protected WFSDataStore(java.net.URL host, java.lang.Boolean protocol, java.lang.String username, java.lang.String password, int timeout, int buffer)
          Construct WFSDataStore.
 
Method Summary
protected static java.net.URL createGetCapabilitiesRequest(java.net.URL host)
           
protected  com.vividsolutions.jts.geom.Envelope getBounds(Query query)
          Computes the bounds of the features for the specified feature type that satisfy the query provided that there is a fast way to get that result.
protected static java.net.HttpURLConnection getConnection(java.net.URL url, java.net.Authenticator auth, boolean isPost)
           
 FeatureReader getFeatureReader(Query query, Transaction transaction)
          Access a FeatureReader providing access to Feature information.
protected  FeatureReader getFeatureReader(java.lang.String typeName)
          Subclass must implement.
protected  FeatureReader getFeatureReader(java.lang.String typeName, Query query)
          GR: this method is called from inside getFeatureReader(Query ,Transaction ) to allow subclasses return an optimized FeatureReader wich supports the filter and attributes truncation specified in query A subclass that supports the creation of such an optimized FeatureReader shold override this method.
protected  WFSFeatureReader getFeatureReaderGet(Query request, Transaction transaction)
           
protected  WFSFeatureReader getFeatureReaderPost(Query query, Transaction transaction)
           
 FeatureSource getFeatureSource(java.lang.String typeName)
          Default implementation based on getFeatureReader and getFeatureWriter.
 FeatureType getSchema(java.lang.String typeName)
          DOCUMENT ME!
protected  FeatureType getSchemaGet(java.lang.String typeName)
           
protected  FeatureType getSchemaPost(java.lang.String typeName)
           
 java.lang.String[] getTypeNames()
          Convience method for retriving all the names from the Catalog Entires
protected  Filter getUnsupportedFilter(java.lang.String typeName, Filter filter)
          GR: if a subclass supports filtering, it should override this method to return the unsupported part of the passed filter, so a FilteringFeatureReader will be constructed upon it.
 
Methods inherited from class org.geotools.data.AbstractDataStore
createFeatureWriter, createLockingManager, createMetadata, createSchema, getCount, getFeatureWriter, getFeatureWriter, getFeatureWriter, getFeatureWriterAppend, getLockingManager, getView, updateSchema
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

capabilities

protected WFSCapabilities capabilities

AUTO_PROTOCOL

protected static final int AUTO_PROTOCOL
See Also:
Constant Field Values

POST_PROTOCOL

protected static final int POST_PROTOCOL
See Also:
Constant Field Values

GET_PROTOCOL

protected static final int GET_PROTOCOL
See Also:
Constant Field Values

protocol

protected int protocol

auth

protected java.net.Authenticator auth
Constructor Detail

WFSDataStore

protected WFSDataStore(java.net.URL host,
                       java.lang.Boolean protocol,
                       java.lang.String username,
                       java.lang.String password,
                       int timeout,
                       int buffer)
                throws org.xml.sax.SAXException,
                       java.io.IOException
Construct WFSDataStore.

Parameters:
host - - may not yet be a capabilities url
protocol - - true,false,null (post,get,auto)
username - - iff password
password - - iff username
timeout - - default 3000 (ms)
buffer - - default 10 (features)
Throws:
org.xml.sax.SAXException
java.io.IOException
Method Detail

getConnection

protected static java.net.HttpURLConnection getConnection(java.net.URL url,
                                                          java.net.Authenticator auth,
                                                          boolean isPost)
                                                   throws java.io.IOException
Throws:
java.io.IOException

createGetCapabilitiesRequest

protected static java.net.URL createGetCapabilitiesRequest(java.net.URL host)

getTypeNames

public java.lang.String[] getTypeNames()
Description copied from class: AbstractDataStore
Convience method for retriving all the names from the Catalog Entires

Specified by:
getTypeNames in interface DataStore
Specified by:
getTypeNames in class AbstractDataStore
See Also:
AbstractDataStore.getTypeNames()

getSchema

public FeatureType getSchema(java.lang.String typeName)
                      throws java.io.IOException
DOCUMENT ME!

Specified by:
getSchema in interface DataStore
Specified by:
getSchema in class AbstractDataStore
Parameters:
typeName - DOCUMENT ME!
Returns:
DOCUMENT ME!
Throws:
java.io.IOException
See Also:
AbstractDataStore.getSchema(java.lang.String)

getSchemaGet

protected FeatureType getSchemaGet(java.lang.String typeName)
                            throws org.xml.sax.SAXException,
                                   java.io.IOException
Throws:
org.xml.sax.SAXException
java.io.IOException

getSchemaPost

protected FeatureType getSchemaPost(java.lang.String typeName)
                             throws java.io.IOException,
                                    org.xml.sax.SAXException
Throws:
java.io.IOException
org.xml.sax.SAXException

getFeatureReaderGet

protected WFSFeatureReader getFeatureReaderGet(Query request,
                                               Transaction transaction)
                                        throws java.io.UnsupportedEncodingException,
                                               java.io.IOException,
                                               org.xml.sax.SAXException
Throws:
java.io.UnsupportedEncodingException
java.io.IOException
org.xml.sax.SAXException

getFeatureReaderPost

protected WFSFeatureReader getFeatureReaderPost(Query query,
                                                Transaction transaction)
                                         throws org.xml.sax.SAXException,
                                                java.io.IOException
Throws:
org.xml.sax.SAXException
java.io.IOException

getFeatureReader

protected FeatureReader getFeatureReader(java.lang.String typeName)
                                  throws java.io.IOException
Description copied from class: AbstractDataStore
Subclass must implement.

Specified by:
getFeatureReader in class AbstractDataStore
Parameters:
typeName -
Returns:
FeatureReader over contents of typeName
Throws:
java.io.IOException

getFeatureReader

protected FeatureReader getFeatureReader(java.lang.String typeName,
                                         Query query)
                                  throws java.io.IOException
Description copied from class: AbstractDataStore
GR: this method is called from inside getFeatureReader(Query ,Transaction ) to allow subclasses return an optimized FeatureReader wich supports the filter and attributes truncation specified in query

A subclass that supports the creation of such an optimized FeatureReader shold override this method. Otherwise, it just returns getFeatureReader(typeName)

Overrides:
getFeatureReader in class AbstractDataStore
Throws:
java.io.IOException

getFeatureReader

public FeatureReader getFeatureReader(Query query,
                                      Transaction transaction)
                               throws java.io.IOException
Description copied from interface: DataStore
Access a FeatureReader providing access to Feature information.

Filter is used as a low-level indication of constraints. (Implementations may resort to using a FilteredFeatureReader, or provide their own optimizations)

FeatureType provides a template for the returned FeatureReader

Transaction to externalize DataStore state on a per Transaction basis. The most common example is a JDBC datastore saving a Connection for use across several FeatureReader requests. Similarly a Shapefile reader may wish to redirect FeatureReader requests to a alternate filename over the course of a Transaction.

Notes For Implementing DataStore

Subclasses may need to retrieve additional attributes, beyond those requested by featureType.getAttributeTypes(), in order to correctly apply the filter.
These Additional attribtues should be not be returned by FeatureReader. Subclasses may use ReTypeFeatureReader to aid in acomplishing this.

Helper classes for implementing a FeatureReader (in order):

Sample use (not optimized):


 if (filter == Filter.ALL) {
      return new EmptyFeatureReader(featureType);
  }

  String typeName = featureType.getTypeName();
  FeatureType schema = getSchema( typeName );
  FeatureReader reader = new DefaultFeatureReader( getAttributeReaders(), schema );

  if (filter != Filter.NONE) {
      reader = new FilteringFeatureReader(reader, filter);
  }

  if (transaction != Transaction.AUTO_COMMIT) {
      Map diff = state(transaction).diff(typeName);
      reader = new DiffFeatureReader(reader, diff);
  }

  if (!featureType.equals(reader.getFeatureType())) {
      reader = new ReTypeFeatureReader(reader, featureType);
  }
 return reader
 

Locking support does not need to be provided for FeatureReaders.

Specified by:
getFeatureReader in interface DataStore
Overrides:
getFeatureReader in class AbstractDataStore
Throws:
java.io.IOException
See Also:
DataStore.getFeatureReader(org.geotools.data.Query, org.geotools.data.Transaction)

getBounds

protected com.vividsolutions.jts.geom.Envelope getBounds(Query query)
                                                  throws java.io.IOException
Description copied from class: AbstractDataStore
Computes the bounds of the features for the specified feature type that satisfy the query provided that there is a fast way to get that result.

Will return null if there is not fast way to compute the bounds. Since it's based on some kind of header/cached information, it's not guaranteed to be real bound of the features

Overrides:
getBounds in class AbstractDataStore
Parameters:
query -
Returns:
the bounds, or null if too expensive
Throws:
java.io.IOException

getUnsupportedFilter

protected Filter getUnsupportedFilter(java.lang.String typeName,
                                      Filter filter)
Description copied from class: AbstractDataStore
GR: if a subclass supports filtering, it should override this method to return the unsupported part of the passed filter, so a FilteringFeatureReader will be constructed upon it. Otherwise it will just return the same filter.

If the complete filter is supported, the subclass must return Filter.NONE

Overrides:
getUnsupportedFilter in class AbstractDataStore
See Also:
AbstractDataStore.getUnsupportedFilter(java.lang.String, org.geotools.filter.Filter)

getFeatureSource

public FeatureSource getFeatureSource(java.lang.String typeName)
                               throws java.io.IOException
Description copied from class: AbstractDataStore
Default implementation based on getFeatureReader and getFeatureWriter.

We should be able to optimize this to only get the RowSet once

Specified by:
getFeatureSource in interface DataStore
Overrides:
getFeatureSource in class AbstractDataStore
Throws:
java.io.IOException
See Also:
DataStore.getFeatureSource(java.lang.String)


Copyright © GeoTools. All Rights Reserved.