org.exolab.castor.net.util
Class URIUtils

java.lang.Object
  extended by org.exolab.castor.net.util.URIUtils

public class URIUtils
extends Object

A utility class for URI handling

Author:
Keith Visco

Constructor Summary
URIUtils()
           
 
Method Summary
static String getDocumentBase(String href)
          Returns the document base of the href argument
static InputStream getInputStream(String href, String documentBase)
          Returns an InputStream for the file represented by the href argument
static Reader getReader(String href, String documentBase)
          Returns a Reader for the file represented by the href argument
static String getRelativeURI(String href)
          Returns the relative URI of the href argument
static String normalize(String absoluteURL)
          This method removes "." or ".." from absolute URL.
static String resolveAsString(String href, String documentBase)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

URIUtils

public URIUtils()
Method Detail

getInputStream

public static InputStream getInputStream(String href,
                                         String documentBase)
                                  throws FileNotFoundException,
                                         IOException
Returns an InputStream for the file represented by the href argument

Parameters:
href - the href of the file to get the input stream for.
documentBase - the document base of the href argument, if it is a relative href set documentBase to null if there is none.
Returns:
an InputStream to the desired resource
Throws:
FileNotFoundException - when the file could not be found
IOException

getReader

public static Reader getReader(String href,
                               String documentBase)
                        throws FileNotFoundException,
                               IOException
Returns a Reader for the file represented by the href argument

Parameters:
href - the href of the file to get the input stream for.
documentBase - the document base of the href argument, if it is a relative href set documentBase to null if there is none.
Returns:
an InputStream to the desired resource
Throws:
FileNotFoundException - when the file could not be found
IOException

getDocumentBase

public static String getDocumentBase(String href)
Returns the document base of the href argument

Returns:
the document base of the given href

getRelativeURI

public static String getRelativeURI(String href)
Returns the relative URI of the href argument

Returns:
the relative URI the given href

normalize

public static String normalize(String absoluteURL)
                        throws MalformedURLException
This method removes "." or ".." from absolute URL. I needed this method because the JDK doesn't do this automatically when creating URLs.

Parameters:
absoluteURL - the absolute URI to normalize
Throws:
MalformedURLException

resolveAsString

public static String resolveAsString(String href,
                                     String documentBase)


Copyright © 2010. All Rights Reserved.