org.exolab.jms.net.uri
Class URIHelper

java.lang.Object
  |
  +--org.exolab.jms.net.uri.URIHelper

public final class URIHelper
extends java.lang.Object

Helper for operations on URIs.

Version:
$Revision: 1.4 $ $Date: 2005/12/01 13:44:38 $
Author:
Tim Anderson
See Also:
URI

Method Summary
static URI convertHostToAddress(URI uri)
          Helper to convert the host name portion of a URI to its corresponding IP address.
static URI create(java.lang.String scheme, java.lang.String host, int port)
          Helper to create an URI.
static URI create(java.lang.String scheme, java.lang.String host, int port, java.lang.String path)
          Helper to create an URI.
static URI create(java.lang.String scheme, java.lang.String host, int port, java.lang.String path, java.util.Map params)
          Helper to create an URI.
static URI create(java.lang.String scheme, java.lang.String host, int port, java.lang.String path, java.lang.String query)
          Helper to create an URI.
static org.exolab.jms.common.security.BasicPrincipal getPrincipal(URI uri)
          Returns a BasicPrincipal corresponding to the user info specified in a URI.
static URI getURISansQuery(URI uri)
          Returns a URI minus query/fragment.
static URI parse(java.lang.String uri)
          Helper to parse a String to an URI.
static URI parse(java.lang.String uri, java.lang.String scheme)
          Helper to parse an URI, verifying that it has the correct scheme.
static URI parseHostPort(java.lang.String uri, java.lang.String scheme)
          Helper to parse an URI, verifying that it has the correct scheme, host and port specification, and no path.
static java.util.Map parseQuery(java.lang.String query)
          Parse a query string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

create

public static URI create(java.lang.String scheme,
                         java.lang.String host,
                         int port)
                  throws InvalidURIException
Helper to create an URI.
Parameters:
scheme - the URI scheme
host - the host
port - the port
Returns:
a new URI
Throws:
InvalidURIException - if any argument is invalid

create

public static URI create(java.lang.String scheme,
                         java.lang.String host,
                         int port,
                         java.lang.String path)
                  throws InvalidURIException
Helper to create an URI.
Parameters:
scheme - the URI scheme
host - the host
port - the port
path - the path
Returns:
a new URI
Throws:
InvalidURIException - if any argument is invalid

create

public static URI create(java.lang.String scheme,
                         java.lang.String host,
                         int port,
                         java.lang.String path,
                         java.util.Map params)
                  throws InvalidURIException
Helper to create an URI.
Parameters:
scheme - the URI scheme
host - the host
port - the port
path - the path
params - a map of key/value pairs used to construct a query string
Returns:
a new URI
Throws:
InvalidURIException - if any argument is invalid

create

public static URI create(java.lang.String scheme,
                         java.lang.String host,
                         int port,
                         java.lang.String path,
                         java.lang.String query)
                  throws InvalidURIException
Helper to create an URI.
Parameters:
scheme - the URI scheme
host - the host
port - the port
path - the path
query - the query
Returns:
a new URI
Throws:
InvalidURIException - if any argument is invalid

parse

public static URI parse(java.lang.String uri)
                 throws InvalidURIException
Helper to parse a String to an URI. If no path was specified in, the URI, it will default to "/".
Parameters:
uri - the URI to parse
Returns:
the parsed URI
Throws:
InvalidURIException - if uri is invalid

parse

public static URI parse(java.lang.String uri,
                        java.lang.String scheme)
                 throws InvalidURIException
Helper to parse an URI, verifying that it has the correct scheme.
Parameters:
uri - the URI to parse
scheme - the expected scheme
Returns:
the parsed URI
Throws:
InvalidURIException - if uri is invalid

parseHostPort

public static URI parseHostPort(java.lang.String uri,
                                java.lang.String scheme)
                         throws InvalidURIException
Helper to parse an URI, verifying that it has the correct scheme, host and port specification, and no path.
Parameters:
uri - the URI to parse
scheme - the expected scheme
Returns:
the parsed URI
Throws:
InvalidURIException - if uri is invalid

convertHostToAddress

public static URI convertHostToAddress(URI uri)
Helper to convert the host name portion of a URI to its corresponding IP address. If the URI doesn't contain a host, or the host is specified as an IP address, or the IP address can't be determined, then the URI is returned unchanged.
Parameters:
uri - the uri to convert
Returns:
the converted URI

getPrincipal

public static org.exolab.jms.common.security.BasicPrincipal getPrincipal(URI uri)
Returns a BasicPrincipal corresponding to the user info specified in a URI.
Parameters:
uri - the URI to get the user info from
Returns:
a new BasicPrincipal containing the user info, or null if none was specified

getURISansQuery

public static URI getURISansQuery(URI uri)
Returns a URI minus query/fragment.
Parameters:
uri - the URI
Returns:
the URI minus query/fragment or uri if there is no query/fragment

parseQuery

public static java.util.Map parseQuery(java.lang.String query)
                                throws InvalidURIException
Parse a query string.

Note that this implementation doesn't support multiple parameters. with the same name. The value of the last will be returned.

Parameters:
query - the query to parse
Returns:
the parsed parameters
Throws:
InvalidURIException - if query is invalid


Copyright © 1999-2007 The OpenJMS Group. All Rights Reserved.