Class Resources

java.lang.Object
java.util.ResourceBundle
java.util.ListResourceBundle
com.oracle.coherence.common.base.Resources

public abstract class Resources extends ListResourceBundle
Implement simple basis for package (and other) resources.
Version:
1.00, 11/17/97
Author:
Cameron Purdy
  • Constructor Details

    • Resources

      public Resources()
  • Method Details

    • getString

      public String getString(String sKey, String sDefault)
      Get the specified resource text.
      Parameters:
      sKey - the resource key
      sDefault - returns this string if the resource cannot be found
      Returns:
      the requested string, formatted if specified
    • getString

      public String getString(String sKey, String[] asParam, String sDefault)
      Get the specified resource string.
      Parameters:
      sKey - the resource key
      asParam - an array of arguments to fill in replaceable parameters
      sDefault - returns this string if the resource cannot be found
      Returns:
      the requested string, formatted if specified
    • findResource

      public static URL findResource(String sName, ClassLoader loader)
      Find the URL of the resource with the given name using the specified ClassLoader or the following Classes:

      If a resource with the given name is not found, this method attempts to find the resource using a fully-qualified or relative version of the specified name. As a last attempt, the name will be treated as a URL.

      Parameters:
      sName - the name of the resource
      loader - the ClassLoader used to locate the resource; if null, or resource is not found, the list of ClassLoaders described above will be tried
      Returns:
      the URL of the resource or null if the resource could not be found and the resource name is not a valid URL specification
    • findRelativeOrAbsoluteResource

      public static URL findRelativeOrAbsoluteResource(String sName, ClassLoader loader)
      Find the URL of the resource with the given name using the specified ClassLoader. An attempt is made with both a relative URL and an absolute (fully-qualified) URL if required. This method will only search the provided ClassLoader; it is recommended to use findResource(String, ClassLoader) for a more exhaustive search.
      Parameters:
      sName - the name of the resource
      loader - the ClassLoader used to locate the resource; this method returns null if a null ClassLoader is provided
      Returns:
      the URL of the resource or null if the resource could not be found or if a null ClassLoader is provided
      See Also:
    • getFileURL

      public static URL getFileURL(String sName)
      Obtain a URL for an existing file with the specified name.
      Parameters:
      sName - the name of the file
      Returns:
      the file URL, or null if file does not exist
    • findFileOrResource

      public static URL findFileOrResource(String sName, ClassLoader loader)
      Return a URL to the specified file or resource, using the specified class loader or a context ClassLoader.

      This method attempts to locate a file with the specified name or path. If the file does not exist or cannot be read, this method attempts to locate a resource with the given name, using the specified class loader or context class loader.

      If a resource with the given name is not found, this method attempts to find the resource using a fully-qualified or relative version of the specified name. As a last attempt, the name will be treated as a URL.
      Parameters:
      sName - the name of the file or resource
      loader - the ClassLoader used to locate the resource; if null, Classes.getContextClassLoader() is used
      Returns:
      the URL of the file or resource or null if the resource could not be found and the resource name is not a valid URL specification