com.ebmwebsourcing.easycommons.uri
Class UriManager

java.lang.Object
  extended by com.ebmwebsourcing.easycommons.uri.UriManager

public class UriManager
extends java.lang.Object

Author:
Vincent Zurczak - EBM WebSourcing

Constructor Summary
UriManager()
           
 
Method Summary
static java.net.URI buildNewURI(java.net.URI referenceUri, java.lang.String uriSuffix)
          Builds an URI from an URI and a suffix.
static java.net.URI filePathToUri(java.lang.String path)
          Builds an URL from a string and escape illegal characters.
static java.net.URL filePathToUrl(java.lang.String path)
          Builds an URL from a string and escape illegal characters.
static boolean isAbsoluteUri(java.lang.String uriAsString)
          Determines whether a string is an absolute URI.
static java.net.URI urlToUri(java.lang.String urlAsString)
          Builds an URI from an URL string (with an handle for URLs not compliant with RFC 2396).
static java.net.URI urlToUri(java.net.URL url)
          Builds an URI from an URL (with an handle for URLs not compliant with RFC 2396).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UriManager

public UriManager()
Method Detail

urlToUri

public static java.net.URI urlToUri(java.net.URL url)
Builds an URI from an URL (with an handle for URLs not compliant with RFC 2396).

Parameters:
url -
Returns:

urlToUri

public static java.net.URI urlToUri(java.lang.String urlAsString)
Builds an URI from an URL string (with an handle for URLs not compliant with RFC 2396).

Parameters:
urlAsString -
Returns:

filePathToUri

public static java.net.URI filePathToUri(java.lang.String path)
Builds an URL from a string and escape illegal characters.

Parameters:
path -
Returns:

filePathToUrl

public static java.net.URL filePathToUrl(java.lang.String path)
Builds an URL from a string and escape illegal characters.

Parameters:
path -
Returns:

buildNewURI

public static java.net.URI buildNewURI(java.net.URI referenceUri,
                                       java.lang.String uriSuffix)
                                throws java.lang.Exception
Builds an URI from an URI and a suffix.

This suffix can be an absolute URL, or a relative path with respect to the first URI. In this case, the suffix is resolved with respect to the URI.

If the suffix is already an URL, its is returned.
If the suffix is a relative file path and cannot be resolved, an exception is thrown.

The returned URI is normalized.

Parameters:
referenceUri - the reference URI
uriSuffix - the URI suffix (not null)
Returns:
the new URI
Throws:
java.lang.Exception - if the resolution failed

isAbsoluteUri

public static boolean isAbsoluteUri(java.lang.String uriAsString)
Determines whether a string is an absolute URI.

Parameters:
uriAsString - the potential URI, as a string
Returns:
true if it is an absolute URI, false otherwise or if it is not a valid URI


Copyright © 2008-2010 eBM WebSourcing. All Rights Reserved.