com.flat502.rox.http
Class MethodCallURI

java.lang.Object
  extended by com.flat502.rox.http.MethodCallURI

public class MethodCallURI
extends java.lang.Object

A simple wrapper for URI for decomposing a URI into the components we expect when mapping a GET request onto an XML-RPC method call handler.

A URI is decomposed into three parts:

  1. A mount point
  2. A method name
  3. A parameter map


Constructor Summary
MethodCallURI(java.lang.String uri)
           
MethodCallURI(java.net.URI uri)
           
 
Method Summary
 java.lang.String getMethodName()
          The method name for a URI is derived by extracting the path component from the URI and retaining the last path element.
 java.lang.String getMountPoint()
          The mount point for a URI is derived by extracting the path component from the URI and removing the last path element.
 java.lang.String[] getParameterNames()
          The parameter names for a URI are derived by extracting the query component from the URI and constructing an array from it.
 java.util.Map getParameters()
          The parameters for a URI are derived by extracting the query component from the URI and constructing a Map from it.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MethodCallURI

public MethodCallURI(java.lang.String uri)
              throws java.net.URISyntaxException
Throws:
java.net.URISyntaxException

MethodCallURI

public MethodCallURI(java.net.URI uri)
Method Detail

getMountPoint

public java.lang.String getMountPoint()
The mount point for a URI is derived by extracting the path component from the URI and removing the last path element.

Logically this acts as though the path were split on the path separator (/) and all but the last element of the resulting list were joined using the same separator.

A null or empty path component results in the mount point being set to a single path separator ("/").

Returns:
The mount point for the URI wrapped by this instance.

getMethodName

public java.lang.String getMethodName()
The method name for a URI is derived by extracting the path component from the URI and retaining the last path element.

Logically this acts as though the path were split on the path separator (/) and only the last element of the resulting list was retained.

A null or empty path component results in the method name being set to an empty String.

Returns:
The method name for the URI wrapped by this instance.

getParameters

public java.util.Map getParameters()
The parameters for a URI are derived by extracting the query component from the URI and constructing a Map from it.

This Map is never null and is always an instance of LinkedHashMap. Key insertion order matches the order in which query keys are specified in the URI.

The value for a given key in the returned Map is one of three values:

  1. A null value if the key was defined without a value in the URI (...&foo&...).
  2. A String value if the key was defined once, and with a value, in the URI (...&foo&...).
  3. A List instance if a key appears multiple times (...&foo=1&...&foo=2&...). The List contents will reflect the values assigned to the key in the order in which they appear in the URI. If a key appears multiple times and at least once occurrence appears with a value (...&foo=1&...&foo&...), then any occurrences without a value will be reflected by a null value within the List instance.

Returns:
A Map instance representing the parameters specified in the query component of the URI. If the query portion is null an empty Map is returned.

getParameterNames

public java.lang.String[] getParameterNames()
The parameter names for a URI are derived by extracting the query component from the URI and constructing an array from it.

This method provides additional information that may be lost in the translation from a query string to a Map. Specifically, if the same key is specified multiple times as part of the URI then even an ordered Map provides no means to determine exact parameter ordering.

Returns:
An array of parameter names in the order in which they occur in the query component. If the query component is null or empty a zero-length array is returned.