sk.uniba.euromath.tools
Class URLDir

java.lang.Object
  extended by sk.uniba.euromath.tools.URLDir

public final class URLDir
extends Object

Representation of directory, denoted by given URL.

Author:
Martin Vysny

Constructor Summary
URLDir()
          Creates instance of object with current directory.
URLDir(String url)
          Creates instance of object with given url.
URLDir(URI uri)
          Creates instance of object with given uri.
URLDir(URL url)
          Creates instance of object with given url.
 
Method Summary
static URLDir create(File file)
          Creates object pointing onto given directory.
static URL createURL(String url)
          From given string creates an URL instance.
static URL getCurrentDir()
          Returns current dir, as an URL object.
static String getFileName(String url)
          Returns the last path part from given url, without the query and fragment parts.
 URI getURI()
          Returns this instance as URI.
 URL getURL()
          Returns this instance as URL.
 URL resolve(String uri)
          Resolves given uri against this object.
 URL resolve(URI uri)
          Resolves given uri against this object.
 URLDir resolveDir(String uri)
          Resolves given uri against this object.
 String toString()
           
static URI toURI(URL url)
          From given URL creates an URI instance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

URLDir

public URLDir(String url)
       throws MalformedURLException,
              URISyntaxException
Creates instance of object with given url. If URL is relative, then it is rooted in current directory.

Parameters:
url - url. Must denote a directory.
Throws:
MalformedURLException - if url is invalid.
URISyntaxException - if url is invalid.

URLDir

public URLDir(URL url)
Creates instance of object with given url. If URL is relative, then it is rooted in current directory.

Parameters:
url - url. Must denote a directory.

URLDir

public URLDir(URI uri)
       throws MalformedURLException
Creates instance of object with given uri. If uri is relative, then it is rooted in current directory.

Parameters:
uri - uri. Must denote a directory.
Throws:
MalformedURLException - if given uri is not a valid URI

URLDir

public URLDir()
Creates instance of object with current directory.

Method Detail

create

public static URLDir create(File file)
Creates object pointing onto given directory. The file must point into an existing directory in the local filesystem.

Parameters:
file - the file
Returns:
the object pointing into the directory denoted by the file parameter.

getCurrentDir

public static URL getCurrentDir()
Returns current dir, as an URL object.

Returns:
current dir. The URL ends with slash.

resolve

public URL resolve(String uri)
            throws MalformedURLException,
                   URISyntaxException
Resolves given uri against this object. See URI.resolve for details.

Parameters:
uri - uri to resolve.
Returns:
resolved url
Throws:
MalformedURLException - if given uri is not a valid URI
URISyntaxException - if given uri is not a valid URI

resolve

public URL resolve(URI uri)
            throws MalformedURLException
Resolves given uri against this object. See URI.resolve for details.

Parameters:
uri - uri to resolve.
Returns:
resolved url
Throws:
MalformedURLException - if given uri is not a valid URI

resolveDir

public URLDir resolveDir(String uri)
                  throws MalformedURLException,
                         URISyntaxException
Resolves given uri against this object. See URI.resolve for details.

Parameters:
uri - uri to resolve. Must be a directory.
Returns:
resolved url
Throws:
MalformedURLException - if given uri is not a valid URI
URISyntaxException - if given uri is not a valid URI

toString

public String toString()
Overrides:
toString in class Object

toURI

public static URI toURI(URL url)
From given URL creates an URI instance.

Parameters:
url - this string will be converted to URI object.
Returns:
URI object, representing given url.

createURL

public static URL createURL(String url)
From given string creates an URL instance. It doesn't expect error, so MalformedURLException is thrown as an IllegalArgumentException.

Parameters:
url - this string will be converted to URL object.
Returns:
URL object, representing given url.

getURI

public URI getURI()
Returns this instance as URI.

Returns:
URI representation.

getURL

public URL getURL()
Returns this instance as URL.

Returns:
URL representation.

getFileName

public static String getFileName(String url)
Returns the last path part from given url, without the query and fragment parts.

Parameters:
url -
Returns:
the file name, or null if none can be obtained.


Copyright © 2003-2006 null. All Rights Reserved.