Search this API

y.util
Class ResourceResolver

java.lang.Object
  extended by y.util.ResourceResolver

public class ResourceResolver
extends java.lang.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 java.net.URL getClassPathResource(java.lang.String res)
          Resolves the given string and returns an URL.
static java.net.URL getFileResource(java.lang.String res)
          Resolves the given string and returns an URL.
static java.net.URL getResource(java.lang.String res)
          Tries to resolve the given string by all methods available to this class.
static java.net.URL getResource(java.lang.String systemRes, java.lang.String userHomeRes, java.lang.String classPathRes)
          Tries to resolve the given strings in the given order.
static java.net.URL getSystemResource(java.lang.String res)
          Resolves the given string and returns an URL.
static java.net.URL getURLResource(java.lang.String res)
          Resolves the given string and returns an URL.
static java.net.URL getUserHomeResource(java.lang.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 java.net.URL getResource(java.lang.String systemRes,
                                       java.lang.String userHomeRes,
                                       java.lang.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 getSystemResource(String)
userHomeRes - A user home relative path. Resolved with getUserHomeResource(String)
classPathRes - A path relative to the classpath of the virtual machine. Resolved with getClassPathResource(String)

getUserHomeResource

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

Parameters:
res - A user home relative path

getClassPathResource

public static java.net.URL getClassPathResource(java.lang.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 java.net.URL getURLResource(java.lang.String res)
Resolves the given string and returns an URL.

Parameters:
res - A string representation of an url

getFileResource

public static java.net.URL getFileResource(java.lang.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 java.net.URL getSystemResource(java.lang.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 java.net.URL getResource(java.lang.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-2017,
yWorks GmbH.
All rights reserved.