com.bankframe.services.resource
Class ResourceLocator

java.lang.Object
  extended bycom.bankframe.services.resource.ResourceLocator

public class ResourceLocator
extends java.lang.Object

This class provides utility methods for locating classes and resource files in the class path, and for accessing classes and resource files


Constructor Summary
ResourceLocator()
          Default Constructor
 
Method Summary
static java.net.URL getClassInClassPath(java.lang.Class clazz, java.lang.String className, java.util.Locale locale)
          This method gets the URL for the specified class and locale.
static java.net.URL getClassInClassPath(java.lang.String className)
          This method gets the URL for the specified class.
static java.net.URL getClassInClassPath(java.lang.String className, java.util.Locale locale)
          This method gets the URL for the specified class and locale .
static java.net.URL getFileInClassPath(java.lang.String fullFileName)
          This method gets the URL for the specified file.
static java.net.URL getFileInClassPath(java.lang.String fileName, java.lang.String fileExtension)
          This method gets the URL for the specified file.
static java.io.InputStream getInputStream(java.net.URL url)
          This method gets an InputStream for the specified URL.
static long getLastModified(java.net.URL url)
          This method returns the time (in milliseconds since 01/01/1970) that the resource was last modified.
static java.io.OutputStream getOutputStream(java.net.URL url)
          This method gets an OutputStream for the specified URL.
static java.net.URL getResourceInClassPath(java.lang.Class clazz, java.lang.String resourceName, java.util.Locale locale)
          This method gets the URL for the specified resource and locale .
static java.net.URL getResourceInClassPath(java.lang.String resourceName)
          This method gets the URL for the specified resource and locale .
static java.net.URL getResourceInClassPath(java.lang.String resourceName, java.util.Locale locale)
          This method gets the URL for the specified resource and locale .
static boolean isReadOnly(java.net.URL url)
          This method checks if the specified resource is read only.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ResourceLocator

public ResourceLocator()
Default Constructor

Method Detail

getClassInClassPath

public static java.net.URL getClassInClassPath(java.lang.Class clazz,
                                               java.lang.String className,
                                               java.util.Locale locale)
This method gets the URL for the specified class and locale. The class name should be specified in Java format e.g.: com.bankframe.resource.ResourceLocator. This method will locate the nearest matching locale to the one requested. This method will return null if the class cannot be found in the classpath.

Parameters:
clazz - the Class instance to use to search the class path
className - the name of the class
locale - the locale
Returns:
the URL of the class or null if not found in class path

getClassInClassPath

public static java.net.URL getClassInClassPath(java.lang.String className)
This method gets the URL for the specified class. The class name should be specified in Java format e.g.: com.bankframe.resource.ResourceLocator. This method will return null if the class cannot be found in the class path.

Parameters:
className - the name of the class
Returns:
the URL of the class or null if not found in class path

getClassInClassPath

public static java.net.URL getClassInClassPath(java.lang.String className,
                                               java.util.Locale locale)
This method gets the URL for the specified class and locale . The class name should be specified in Java format e.g.: com.bankframe.resource.ResourceLocator. This method will locate the nearest matching locale to the one requested. This method will return null if the class cannot be found in the class path.

Parameters:
className - the name of the class
locale - the locale
Returns:
the URL of the class or null if not found in class path

getFileInClassPath

public static java.net.URL getFileInClassPath(java.lang.String fullFileName)
This method gets the URL for the specified file. This method will return null if the file cannot be found in the classpath.

Parameters:
fullFileName - the name of the file to search for in the classpath
Returns:
the URL of the file or null if not found in classpath

getFileInClassPath

public static java.net.URL getFileInClassPath(java.lang.String fileName,
                                              java.lang.String fileExtension)
This method gets the URL for the specified file. This method will return null if the file cannot be found in the classpath.

Parameters:
fileName - the name of the file (excluding the extension)
fileExtension - the file extension (e.g. .jpg, .gif)
Returns:
the URL of the file or null if not found in classpath

getInputStream

public static java.io.InputStream getInputStream(java.net.URL url)
                                          throws java.io.IOException
This method gets an InputStream for the specified URL.

Parameters:
url - the URL of the resource
Returns:
the inputStream for the URL
Throws:
java.io.IOException

getLastModified

public static long getLastModified(java.net.URL url)
This method returns the time (in milliseconds since 01/01/1970) that the resource was last modified.

Parameters:
url - the URL of the resource
Returns:
the time of last modification or zero if an error occurs

getOutputStream

public static java.io.OutputStream getOutputStream(java.net.URL url)
                                            throws java.io.IOException
This method gets an OutputStream for the specified URL. Note that the resource may be read only, in which case calling this method will result in an java.io.IOException being thrown.

Parameters:
url - the URL of the resource
Returns:
the outputStream for the URL
Throws:
java.io.IOException - if the resource is read-only

getResourceInClassPath

public static java.net.URL getResourceInClassPath(java.lang.Class clazz,
                                                  java.lang.String resourceName,
                                                  java.util.Locale locale)
This method gets the URL for the specified resource and locale . The resource name should be specified in Java format e.g.: com.bankframe.localization.messages.BankframeMessages. This method will locate the nearest matching locale to the one requested. This method will return null if the resource cannot be found in the classpath.

Parameters:
clazz - The Class instance to use to search the class path
resourceName - Name of the resource
locale - The locale
Returns:
URL of the resource or null if not found in class path

getResourceInClassPath

public static java.net.URL getResourceInClassPath(java.lang.String resourceName)
This method gets the URL for the specified resource and locale . The resource name should be specified in Java format e.g.: com.bankframe.localization.messages.BankframeMessages. This method will locate the nearest matching locale to the one requested. This method will return null if the resource cannot be found in the classpath.

Parameters:
resourceName - Name of the resource
Returns:
URL of the resource or null if not found in class path

getResourceInClassPath

public static java.net.URL getResourceInClassPath(java.lang.String resourceName,
                                                  java.util.Locale locale)
This method gets the URL for the specified resource and locale . The resource name should be specified in Java format e.g.: com.bankframe.localization.messages.BankframeMessages. This method will locate the nearest matching locale to the one requested. This method will return null if the resource cannot be found in the classpath.

Parameters:
resourceName - the nName of the resource
locale - the locale
Returns:
the URL of the resource or null if not found in class path

isReadOnly

public static boolean isReadOnly(java.net.URL url)
This method checks if the specified resource is read only.

Parameters:
url - the URL of the resource
Returns:
true if the resource is read only, false otherwise


Copyright © 2005, 2007, Oracle. All rights reserved.