com.esri.wms.client
Class RequestHandler

java.lang.Object
  extended by com.esri.wms.client.RequestHandler
All Implemented Interfaces:
Serializable

public abstract class RequestHandler
extends Object
implements Serializable

RequestHandler is an entry point to extend the WMS client API.

You can add RequestListener or ResponseListener to handler vendor specific parameters:

 RequestHandler handler = RequestHandler.getDefaultInstance();
 RequestListener l = new RequestListener() {
 
   public String createRequest(Service service, String request) {
      ....
 
     return request;
   }
 };
 handler.setRequestListener(l);
 ServerConnection server = new ServerConnection("http://host/service",null,handler);
 String request = handler.createGetCapsRequest().toRequestString();
 

See Also:
Serialized Form

Field Summary
protected static String http_conn_impl_class
           
static String HTTP_CONNECTION_FILE
           
protected  HttpConnectionChannel httpConn
           
protected static String impl_class
          The name of the implementation class.
protected  RequestListener reqListener
          The Request Listener.
protected  List<ResponseListener> respListeners
          The response listener list.
 
Constructor Summary
protected RequestHandler()
          Instantiates an object of RequestHandler.
protected RequestHandler(ServerConnection server)
          Instantiates an object of RequestHandler.
 
Method Summary
 void addCapabilitiesFormat(String format)
          Adds a MIME type supported by the server.
 void addExceptionFormat(String format)
          Adds a MIME type supported by the server.
 void addFeatureInfoFormat(String format)
          Adds a MIME type supported by the server.
 boolean addListener(ResponseListener o)
          Adds a ResponseListener to the handler.
 void addMapFormat(String format)
          Adds a MIME type supported by the server.
abstract  GenericRequest createGetCapsRequest()
          Creates a GetCapabilities request object.
abstract  GenericRequest createGetFeatureInfoRequest(Map map, Point point, String queryLayers, int count, String mime)
          Creates a GetFeatureInfo request object from a Map object.
abstract  GenericRequest createGetMapRequest(Map map, String format)
          Creates a GetMap request object from a Map object.
 InputStream getCapabilities(String request)
          Sends a GetCapabilities request.
static RequestHandler getDefaultInstance()
          Gets a default implementation instance.
 InputStream getFeatureInfo(String request)
          Sends a GetFeatureInfo request.
 InputStream getMap(String request)
          Sends a GetMap request.
 RequestListener getRequestListener()
          Gets the request listener.
abstract  ServerConnection getServer()
          Gets the server associated with the handler.
protected  InputStream issueRequest(String serviceURL, String request)
          Issues the request to the given URL+Request.
abstract  Map parseCapabilitiesResponse(InputStream in)
          Parses out a Map object from the GetCapabilities response.
abstract  FeatureInfo parseFeatureInfoResponse(InputStream in)
          Parses out a FeatureInfo object from the GetFeatureInfo response.
 void removeAllListeners()
          Removes all of the response listeners from the handler.
 boolean removeListener(ResponseListener o)
          Removes the given response listener from the handler.
 void setCapabilitiesServiceURL(String capabilitiesServiceURL)
          Sets the URL of the GetCapabilities service.
 void setDefaultMapRef(SpatialReference defaultMapRef)
          Set the default Map Spatial reference.
 void setFeatureInfoServiceURL(String featureInfoServiceURL)
          Sets the URL of the GetFeatureInfo service.
 void setMapServiceURL(String mapServiceURL)
          Sets the URL of the GetMap service.
 void setRequestListener(RequestListener o)
          Sets the request listener.
abstract  void setServer(ServerConnection server)
          Sets the server associated with the handler.
 void setServerAbstract(String serverAbstract)
          Sets the server abstract information.
 void setServerName(String serverName)
          Sets the name of the server.
 void setServerTitle(String serverTitle)
          Sets the title of the server.
 void setServerVersion(String serverVersion)
          Set the version of the communication.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

HTTP_CONNECTION_FILE

public static final String HTTP_CONNECTION_FILE
See Also:
Constant Field Values

impl_class

protected static String impl_class
The name of the implementation class.


respListeners

protected List<ResponseListener> respListeners
The response listener list.


reqListener

protected RequestListener reqListener
The Request Listener.


httpConn

protected HttpConnectionChannel httpConn

http_conn_impl_class

protected static String http_conn_impl_class
Constructor Detail

RequestHandler

protected RequestHandler(ServerConnection server)
Instantiates an object of RequestHandler.

Parameters:
server - the server to connect.

RequestHandler

protected RequestHandler()
Instantiates an object of RequestHandler.

Method Detail

getDefaultInstance

public static RequestHandler getDefaultInstance()
Gets a default implementation instance.

Returns:
the implementation instance.

getServer

public abstract ServerConnection getServer()
Gets the server associated with the handler.

Returns:
Returns the server.

setServer

public abstract void setServer(ServerConnection server)
Sets the server associated with the handler.

Parameters:
server -

getCapabilities

public InputStream getCapabilities(String request)
                            throws IOException
Sends a GetCapabilities request.

Parameters:
request - e.g. REQUEST=GetCapabilities&VERSION=1.3.0&SERVICE=WMS
Throws:
IOException

getFeatureInfo

public InputStream getFeatureInfo(String request)
                           throws IOException
Sends a GetFeatureInfo request.

Parameters:
request - e.g.LAYERS=0,1,2,3,4,5,6&CRS=EPSG:4326&FORMAT=image/bmp&HEIGHT=300&REQUEST=GetMap&WIDTH=400&BBOX=-124.73%2C31.91%2C-109.99%2C42.96&STYLES=&VERSION=1.3.0
Throws:
IOException

getMap

public InputStream getMap(String request)
                   throws IOException
Sends a GetMap request.

Parameters:
request - e.g. LAYERS=0,1,2,3,4,5,6&CRS=EPSG:4326&FORMAT=image/bmp&HEIGHT=300&REQUEST=GetMap&WIDTH=400&BBOX=31.911976%2C-124.73%2C42.96%2C-109.96&STYLES=&VERSION=1.3.0
Throws:
IOException

issueRequest

protected InputStream issueRequest(String serviceURL,
                                   String request)
                            throws IOException
Issues the request to the given URL+Request.

Parameters:
serviceURL - the server URL e.g. http://host:8399/arcgis/services/usa_n/MapServer/WMSServer
request - the request e.g. REQUEST=GetCapabilities&VERSION=1.3.0&SERVICE=WMS
Throws:
IOException

createGetFeatureInfoRequest

public abstract GenericRequest createGetFeatureInfoRequest(Map map,
                                                           Point point,
                                                           String queryLayers,
                                                           int count,
                                                           String mime)
Creates a GetFeatureInfo request object from a Map object.

Parameters:
map - the map to query.
point - the screen point.
queryLayers - the layer string delimited by comma.
count - Number of features about which to return information (default=1).
mime - Return format of feature information (MIME type).

createGetMapRequest

public abstract GenericRequest createGetMapRequest(Map map,
                                                   String format)
Creates a GetMap request object from a Map object.

Parameters:
format - the format of the return map.

createGetCapsRequest

public abstract GenericRequest createGetCapsRequest()
Creates a GetCapabilities request object.


parseCapabilitiesResponse

public abstract Map parseCapabilitiesResponse(InputStream in)
                                       throws ServiceException
Parses out a Map object from the GetCapabilities response.

Parameters:
in - the response.
Throws:
ServiceException

parseFeatureInfoResponse

public abstract FeatureInfo parseFeatureInfoResponse(InputStream in)
                                              throws ServiceException
Parses out a FeatureInfo object from the GetFeatureInfo response.

Parameters:
in - the response.
Throws:
ServiceException

addCapabilitiesFormat

public void addCapabilitiesFormat(String format)
Adds a MIME type supported by the server.


addFeatureInfoFormat

public void addFeatureInfoFormat(String format)
Adds a MIME type supported by the server.


addMapFormat

public void addMapFormat(String format)
Adds a MIME type supported by the server.


addExceptionFormat

public void addExceptionFormat(String format)
Adds a MIME type supported by the server.


setServerAbstract

public void setServerAbstract(String serverAbstract)
Sets the server abstract information.


setServerName

public void setServerName(String serverName)
Sets the name of the server.


setServerTitle

public void setServerTitle(String serverTitle)
Sets the title of the server.


setServerVersion

public void setServerVersion(String serverVersion)
Set the version of the communication.


setFeatureInfoServiceURL

public void setFeatureInfoServiceURL(String featureInfoServiceURL)
Sets the URL of the GetFeatureInfo service.


setMapServiceURL

public void setMapServiceURL(String mapServiceURL)
Sets the URL of the GetMap service.


setCapabilitiesServiceURL

public void setCapabilitiesServiceURL(String capabilitiesServiceURL)
Sets the URL of the GetCapabilities service.


setDefaultMapRef

public void setDefaultMapRef(SpatialReference defaultMapRef)
Set the default Map Spatial reference.


addListener

public boolean addListener(ResponseListener o)
Adds a ResponseListener to the handler.

Returns:
Returns true (as per the general contract of the Collection.add method).

removeAllListeners

public void removeAllListeners()
Removes all of the response listeners from the handler.


removeListener

public boolean removeListener(ResponseListener o)
Removes the given response listener from the handler.


setRequestListener

public void setRequestListener(RequestListener o)
Sets the request listener.


getRequestListener

public RequestListener getRequestListener()
Gets the request listener.