es.prodevelop.gvsig.mobile.fmap.driver.raster.wms
Class WMSProtocolHandler

java.lang.Object
  extended byes.prodevelop.gvsig.mobile.fmap.driver.raster.wms.WMSProtocolHandler

public class WMSProtocolHandler
extends java.lang.Object

This is the class that interacts with the WMS drivers. Sends requests (capabilities, images, etc) and starts the parsing process. It also instantiates the root of the layer descriptions tree, and provides a getter used by the WMS dialog to show the results.

Author:
iver, jldominguez
See Also:
WmsRasterDriver, WMSLayerDescription

Field Summary
static java.lang.String DEFAULT_WMS_VERSION
           
static java.lang.String EXCEPTION_TAGS_CODE
          Tag used when parsing WMS responses
static java.lang.String EXCEPTION_TAGS_EXCEPTION_ROOT
          Tag used when parsing WMS responses
static java.lang.String EXCEPTION_TAGS_SERVICE_EXCEPTION
          Tag used when parsing WMS responses
 WMSLayerDescription root
           
 
Constructor Summary
WMSProtocolHandler()
           
 
Method Summary
 void close()
          Closes the protocol handler.
 void delete()
          Removes all the objects owned by this object.
 boolean getCapabilities(java.lang.String version, java.lang.String sym)
          This method starts the get capabilities request process and parses the result.
 java.util.ArrayList getFormats()
           
 java.lang.String getHost()
           
 java.util.ArrayList getInfoFormats()
           
 WMSLayerDescription getRoot()
           
static java.lang.String getSuitableWMSVersion(java.net.URL host)
          Sends a GetCapabilities to the WMS server to get the version if the version parameter is null, the WMS will return the highest version supported if not it will return the lower highest version than the one requested.
 java.lang.String getSymbol()
           
static java.lang.String getSymbol(java.lang.String url)
          Utility method to find out the convenient path separator symbol for a given url string.
 java.lang.String getVersion()
           
 boolean isInfoable()
           
static java.lang.String leaveInfoable(java.lang.String all_csv, WMSLayerDescription root, boolean getname)
          This method excludes from a comma separated string of IDs, the ones that are not infoable.
 void setHost(java.lang.String _host)
          Sets the host url
 void setSymbol(java.lang.String s)
          Sets the path separator symbol to use with the current WMS server
 void setVersion(java.lang.String v)
          Sets the WMS protocol version (1.1.1, etc)
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_WMS_VERSION

public static final java.lang.String DEFAULT_WMS_VERSION
See Also:
Constant Field Values

root

public WMSLayerDescription root

EXCEPTION_TAGS_EXCEPTION_ROOT

public static final java.lang.String EXCEPTION_TAGS_EXCEPTION_ROOT
Tag used when parsing WMS responses

See Also:
Constant Field Values

EXCEPTION_TAGS_SERVICE_EXCEPTION

public static final java.lang.String EXCEPTION_TAGS_SERVICE_EXCEPTION
Tag used when parsing WMS responses

See Also:
Constant Field Values

EXCEPTION_TAGS_CODE

public static final java.lang.String EXCEPTION_TAGS_CODE
Tag used when parsing WMS responses

See Also:
Constant Field Values
Constructor Detail

WMSProtocolHandler

public WMSProtocolHandler()
Method Detail

getRoot

public WMSLayerDescription getRoot()
Returns:
the root of the layer descriptions tree

delete

public void delete()
Removes all the objects owned by this object. This is used when the WMS dialog closes, in order to prevent memory leaks.


setVersion

public void setVersion(java.lang.String v)
Sets the WMS protocol version (1.1.1, etc)

Parameters:
v - the WMS protocol version

setSymbol

public void setSymbol(java.lang.String s)
Sets the path separator symbol to use with the current WMS server

Parameters:
s - the path separator symbol to use with the current WMS server

getVersion

public java.lang.String getVersion()
Returns:
the WMS protocol version (1.1.1, etc)

getSymbol

public java.lang.String getSymbol()
Returns:
the path separator symbol to use with the current WMS server

getFormats

public java.util.ArrayList getFormats()
Returns:
an array with the image formats supoprted by the current WMS server

getInfoFormats

public java.util.ArrayList getInfoFormats()
Returns:
an array with the image formats supported by the current WMS server

isInfoable

public boolean isInfoable()
Returns:
whether the layer described by this object is declared as infoable by the server in the getcapabilities response

getHost

public java.lang.String getHost()
Returns:
the host url

setHost

public void setHost(java.lang.String _host)
Sets the host url

Parameters:
_host - the new host url

getCapabilities

public boolean getCapabilities(java.lang.String version,
                               java.lang.String sym)
This method starts the get capabilities request process and parses the result.

Parameters:
version - the WMS protocol version to be used
sym - the path separator symbol to be used when building requests
Returns:
whether the get capabilities request was completed successfully

close

public void close()
Closes the protocol handler. Currently empty.


getSymbol

public static java.lang.String getSymbol(java.lang.String url)
Utility method to find out the convenient path separator symbol for a given url string.

Parameters:
url - the URL of interest
Returns:
the convenient path separator symbol

getSuitableWMSVersion

public static java.lang.String getSuitableWMSVersion(java.net.URL host)
                                              throws BadWMSResponseException
Sends a GetCapabilities to the WMS server to get the version if the version parameter is null, the WMS will return the highest version supported if not it will return the lower highest version than the one requested.

Parameters:
host - host URL
Returns:
suitable version supported by the server
Throws:
BadWMSResponseException

leaveInfoable

public static java.lang.String leaveInfoable(java.lang.String all_csv,
                                             WMSLayerDescription root,
                                             boolean getname)
This method excludes from a comma separated string of IDs, the ones that are not infoable. It is used for querying only on queriable layers, and prevents empty responses on some WMS servers.

Parameters:
all_csv - comma separated string of all layers requested by the user
root - the layer description object of the root layer
getname - whether we wanrt to get the names or the IDs of the layers
Returns:
a comma separated string with the IDs or names of the queryable layers