de.hedenus.www
Class URIUtil

java.lang.Object
  extended by de.hedenus.www.URIUtil

public class URIUtil
extends java.lang.Object

URI utilities.

Author:
Michael Hedenus

Method Summary
static java.lang.String getPath(java.lang.String uri)
          Gets path of the URI or null if no path is detected.
static java.lang.String getScheme(java.lang.String uri)
          Returns the URI's scheme nor null if the URI has no legal scheme definition.
static boolean isAbsolute(java.lang.String uri)
          Tests wether the URI starts with a legal scheme, e.g.
static boolean isLegalChar(char c)
          Returns true if the character is a letter or digit or 'other legal character'.
static boolean isLetterOrDigit(char c)
          Returns true if the character is a letter or number.
static boolean isOtherLegalChar(char c)
          Returns true if the character is 'other legal character'.
static boolean isSchemeChar(char c, int index)
          Returns true if the char is legal character for the scheme.
static void main(java.lang.String[] args)
           
static java.lang.String resolve(java.lang.String relURI, java.lang.String baseURI)
          Resolves the relative URI against the base URI.
static java.io.File toFile(java.lang.String uri)
          Translates a file: URI to a file.
static java.lang.String toURI(java.io.File file)
          Translates a file to a file: URI with no specified host.
static java.lang.String toURI(java.io.File file, java.lang.String host)
          Translates a file to a file: URI using the specified host name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

resolve

public static java.lang.String resolve(java.lang.String relURI,
                                       java.lang.String baseURI)
Resolves the relative URI against the base URI. If relURI is absolute, it is simply returned.

Parameters:
relURI - the URI to be resolved
baseURI - the base URI against which the resolving is done

getPath

public static java.lang.String getPath(java.lang.String uri)
Gets path of the URI or null if no path is detected.


isAbsolute

public static boolean isAbsolute(java.lang.String uri)
Tests wether the URI starts with a legal scheme, e.g. http:.


getScheme

public static java.lang.String getScheme(java.lang.String uri)
Returns the URI's scheme nor null if the URI has no legal scheme definition.


toFile

public static java.io.File toFile(java.lang.String uri)
Translates a file: URI to a file. The host name will be ignored.


toURI

public static java.lang.String toURI(java.io.File file)
Translates a file to a file: URI with no specified host.


toURI

public static java.lang.String toURI(java.io.File file,
                                     java.lang.String host)
Translates a file to a file: URI using the specified host name.


isSchemeChar

public static boolean isSchemeChar(char c,
                                   int index)
Returns true if the char is legal character for the scheme.

Parameters:
c - the char
index - the char's position in the URI string

isLetterOrDigit

public static boolean isLetterOrDigit(char c)
Returns true if the character is a letter or number.


isLegalChar

public static boolean isLegalChar(char c)
Returns true if the character is a letter or digit or 'other legal character'.


isOtherLegalChar

public static boolean isOtherLegalChar(char c)
Returns true if the character is 'other legal character'.


main

public static void main(java.lang.String[] args)