y.util
Class ResourceResolver

java.lang.Object
  |
  +--y.util.ResourceResolver

public class ResourceResolver
extends Object

This class translates strings to URLs. Strings come from different contexts and hence can be interpreted differently when forming an URL from that string. This class tries to cover most translation cases in which a string somehow serves as a description of a resource.


Method Summary
static URL getClassPathResource(String res)
          Resolves the given string and returns an URL.
static URL getFileResource(String res)
          Resolves the given string and returns an URL.
static URL getResource(String res)
          Tries to resolve the given string by all methods available to this class.
static URL getResource(String systemRes, String userHomeRes, String classPathRes)
          Tries to resolve the given strings in the given order.
static URL getSystemResource(String res)
          Resolves the given string and returns an URL.
static URL getURLResource(String res)
          Resolves the given string and returns an URL.
static URL getUserHomeResource(String res)
          Resolves the given string and returns an URL.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getResource

public static URL getResource(String systemRes,
                              String userHomeRes,
                              String classPathRes)
Tries to resolve the given strings in the given order. Different strategies are used for resolving these strings.

Parameters:
systemRes - The key of a key-value pair passed to the virtual machine with the -D option. Resolved with ResourceResolver.getSystemResource(String)
userHomeRes - A user home relative path. Resolved with ResourceResolver.getUserHomeResource(String)
classPathRes - A path relative to the classpath of the virtual machine. Resolved with ResourceResolver.getClassPathResource(String)

getUserHomeResource

public static URL getUserHomeResource(String res)
Resolves the given string and returns an URL.

Parameters:
res - A user home relative path

getClassPathResource

public static URL getClassPathResource(String res)
Resolves the given string and returns an URL.

Parameters:
res - A path relative to the classpath of the virtual machine.

getURLResource

public static URL getURLResource(String res)
Resolves the given string and returns an URL.

Parameters:
res - A string representation of an url

getFileResource

public static URL getFileResource(String res)
Resolves the given string and returns an URL. If the signified file is not readable, then null is returned.

Parameters:
res - A string representation of a file path.

getSystemResource

public static URL getSystemResource(String res)
Resolves the given string and returns an URL.

Parameters:
res - The key of a key-value pair passed to the virtual machine with the -D option. The value of this key-value pair can signify a (user home relative) file, an url, and a classpath relative path.

getResource

public static URL getResource(String res)
Tries to resolve the given string by all methods available to this class. The lookup precedence is as follows: System, UserHome, ClassPath, File and finally URL.


© Copyright 2000-2003,
yWorks GmbH.
All rights reserved.

2003