com.ibm.as400.ui.framework
Class SystemResourceFinder

java.lang.Object
  extended by com.ibm.as400.ui.framework.SystemResourceFinder

public class SystemResourceFinder
extends Object

Manages the resources associated with graphical panels defined using the Panel Definition Markup Language (PDML). Resources associated with a PDML panel include the following:

All resources are treated as Java system resources, which means they are located and loaded using a class loader. By default, SystemResourceFinder uses the same class loader that loaded SystemResourceFinder. However, it's possible to specify a user-defined class loader, or you can simply define a separate class loader namespace with its own classpath. See createNamespace(java.lang.String).

Since:
v4r2m0
Version:
3.0, 07/10/00
Author:
D. Petty
See Also:
createNamespace(java.lang.String)

Method Summary
Modifier and Type Method and Description
static void addPath(String id, String path)
          Appends a new file or directory name to the classpath for the specified namespace.
static void createNamespace(String id)
          Defines a new class loader-based Java namespace.
static void createNamespace(String id, ClassLoader loader)
          Defines a new class loader-based Java namespace, using the specified class loader.
static void flushImage(ImageIcon imgIcon)
          Flushes an image resource from the cache of image resources.
static void flushImages()
          Flushes the cache of image resources.
static String format(String key)
          Formats a message defined by the PDML runtime.
static String format(String key, Object[] args)
          Formats a message defined by the PDML runtime.
static String getClasspath(String id)
          Returns the current classpath for the specified namespace.
static int getHeaderLineCount()
          Returns the size of the XML header which is prepended to PDML files.
static URL getHTMLDocument(String panelName)
          Returns a URL for reading the contents of an HTML document containing online help for a panel.
static URL getHTMLDocument(String panelName, Locale locale)
          Returns a URL for reading the contents of an HTML document containing online help for a panel.
static URL getHTMLDocument(String id, String panelName)
          Returns a URL for reading the contents of an HTML document containing online help for a panel.
static URL getHTMLDocument(String id, String panelName, Locale locale)
          Returns a URL for reading the contents of an HTML document containing online help for a panel.
static ImageIcon getImageResource(String fileName)
          Returns an ImageIcon constructed using the contents of the specified image file.
static ImageIcon getImageResource(String id, String fileName)
          Returns an ImageIcon constructed using the contents of the specified image file.
static String getLastDocumentLocale()
          Returns the locale last used to load a PDML resource in the form of a language/country string.
static String getLastResourceLocale()
          Returns the locale last used to load a resource bundle in the form of a language/country string.
static InputStream getPDMLDocument(String baseName)
          Returns an InputStream for reading the contents of a PDML file.
static InputStream getPDMLDocument(String baseName, Locale locale)
          Returns an InputStream for reading the contents of a PDML file.
static InputStream getPDMLDocument(String id, String baseName)
          Returns an InputStream for reading the contents of a PDML file.
static InputStream getPDMLDocument(String id, String baseName, Locale locale)
          Returns an InputStream for reading the contents of a PDML file.
static InputStream getPDMLHeader()
          Returns the XML header which is prepended to PDML files.
static URL getResource(String id, String name)
          Finds the resource with the given name.
static InputStream getResourceAsStream(String id, String name)
          Returns an input stream for reading the specified resource.
static InputStream getSerializedPDMLDocument(String panelName)
          Returns an InputStream for reading the contents of a serialized panel definition file.
static InputStream getSerializedPDMLDocument(String panelName, Locale locale)
          Returns an InputStream for reading the contents of a serialized panel definition file.
static InputStream getSerializedPDMLDocument(String id, String panelName)
          Returns an InputStream for reading the contents of a serialized panel definition file.
static InputStream getSerializedPDMLDocument(String id, String panelName, Locale locale)
          Returns an InputStream for reading the contents of a serialized panel definition file.
static ResourceBundle getUncachedBundle(String baseName)
          Returns a resource bundle loaded from disk, bypassing the in-memory cache so that changes to the disk-resident bundle can be used.
static ResourceBundle getUncachedBundle(String baseName, Locale locale)
          Returns a resource bundle loaded from disk, bypassing the in-memory cache so that changes to the disk-resident bundle can be used.
static Class loadClass(String id, String name)
          Loads the class with the specified name.
static boolean removePath(String id, String path)
          Removes the specified file or directory name from the classpath for the specified namespace.
static void setClasspath(String id, String classpath)
          Sets the classpath for the specified namespace.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

format

public static final String format(String key)
Formats a message defined by the PDML runtime. Applications should not call this method.

Parameters:
key - The resource ID of the message to be formatted.
Returns:
The formatted message string.
Since:
v4r2m0

format

public static final String format(String key,
                                  Object[] args)
Formats a message defined by the PDML runtime. Applications should not call this method.

Parameters:
key - The resource ID of the message to be formatted.
args - The substitution values for the message.
Returns:
The formatted message string.
Since:
v4r2m0

getUncachedBundle

public static final ResourceBundle getUncachedBundle(String baseName)
                                              throws MissingResourceException
Returns a resource bundle loaded from disk, bypassing the in-memory cache so that changes to the disk-resident bundle can be used.

Parameters:
baseName - The package qualified name of the resource bundle.
Returns:
The requested resource bundle.
Throws:
If - the specified resource bundle cannot be located.
MissingResourceException
Since:
v4r2m0

getUncachedBundle

public static final ResourceBundle getUncachedBundle(String baseName,
                                                     Locale locale)
                                              throws MissingResourceException
Returns a resource bundle loaded from disk, bypassing the in-memory cache so that changes to the disk-resident bundle can be used.

Parameters:
baseName - The package qualified name of the resource bundle.
locale - The locale to use when searching for the resource bundle.
Returns:
The requested resource bundle.
Throws:
If - the specified resource bundle cannot be located.
MissingResourceException
Since:
v4r2m0

getLastResourceLocale

public static final String getLastResourceLocale()
Returns the locale last used to load a resource bundle in the form of a language/country string.

Returns:
A string which can be appended to the name of a file in the local file system.
Since:
v4r2m0

getPDMLDocument

public static final InputStream getPDMLDocument(String baseName)
                                         throws MissingResourceException
Returns an InputStream for reading the contents of a PDML file.

Parameters:
baseName - The package qualified name of the PDML document.
Returns:
An input stream for reading the PDML file.
Throws:
MissingResourceException - If the PDML document cannot be found.
Since:
v4r2m0

getPDMLDocument

public static final InputStream getPDMLDocument(String baseName,
                                                Locale locale)
                                         throws MissingResourceException
Returns an InputStream for reading the contents of a PDML file.

Parameters:
baseName - The package qualified name of the PDML document.
locale - The locale to use when searching for the PDML document.
Returns:
An input stream for reading the PDML file.
Throws:
MissingResourceException - If the PDML document cannot be found.
Since:
v4r2m0

getSerializedPDMLDocument

public static final InputStream getSerializedPDMLDocument(String panelName)
                                                   throws MissingResourceException
Returns an InputStream for reading the contents of a serialized panel definition file.

Parameters:
panelName - The name of the panel whose definition was serialized.
Returns:
An input stream for reading the serialized panel definition.
Throws:
MissingResourceException - If the serialized panel definition cannot be found.
Since:
v4r2m0

getSerializedPDMLDocument

public static final InputStream getSerializedPDMLDocument(String panelName,
                                                          Locale locale)
                                                   throws MissingResourceException
Returns an InputStream for reading the contents of a serialized panel definition file.

Parameters:
panelName - The name of the panel whose definition was serialized.
locale - The locale to use when searching for the serialized panel definition.
Returns:
An input stream for reading the serialized panel definition.
Throws:
MissingResourceException - If the serialized panel definition cannot be found.
Since:
v4r2m0

getLastDocumentLocale

public static final String getLastDocumentLocale()
Returns the locale last used to load a PDML resource in the form of a language/country string.

Returns:
A string which can be appended to the name of a file in the local file system.
Since:
v4r2m0

getHTMLDocument

public static final URL getHTMLDocument(String panelName)
                                 throws MissingResourceException
Returns a URL for reading the contents of an HTML document containing online help for a panel.

Parameters:
panelName - The name of the panel whose online help is requested.
Returns:
A URL for reading the HTML document.
Throws:
MissingResourceException - If the HTML document cannot be found.
Since:
v4r2m0

getHTMLDocument

public static final URL getHTMLDocument(String panelName,
                                        Locale locale)
                                 throws MissingResourceException
Returns a URL for reading the contents of an HTML document containing online help for a panel.

Parameters:
panelName - The name of the panel whose online help is requested.
locale - The locale to use when searching for the HTML document.
Returns:
A URL for reading the HTML document.
Throws:
MissingResourceException - If the HTML document cannot be found.
Since:
v4r2m0

getImageResource

public static final ImageIcon getImageResource(String fileName)
                                        throws MissingResourceException
Returns an ImageIcon constructed using the contents of the specified image file.

Parameters:
fileName - The qualified name of the desired image file.
Returns:
An ImageIcon containing the image.
Throws:
MissingResourceException - If the image file cannot be found.
Since:
v4r2m0

getPDMLHeader

public static final InputStream getPDMLHeader()
                                       throws MissingResourceException
Returns the XML header which is prepended to PDML files. Applications should not call this method.

Returns:
An InputStream over the XML header.
Throws:
MissingResourceException
Since:
v4r2m0

getHeaderLineCount

public static final int getHeaderLineCount()
Returns the size of the XML header which is prepended to PDML files. Applications should not call this method.

Returns:
The count of lines in the XML header.
Since:
v4r2m0

createNamespace

public static final void createNamespace(String id)
Defines a new class loader-based Java namespace. The namespace has its own private classpath which may be set using setClasspath, addPath or removePath.

Parameters:
id - The string identifier which will be used to identify this namespace on subsequent method calls.
Since:
v5r1m0
See Also:
setClasspath(java.lang.String, java.lang.String), addPath(java.lang.String, java.lang.String), removePath(java.lang.String, java.lang.String)

createNamespace

public static final void createNamespace(String id,
                                         ClassLoader loader)
Defines a new class loader-based Java namespace, using the specified class loader.

Parameters:
id - The string identifier which will be used to identify this namespace on subsequent method calls.
loader - The class loader which will be used to load resources for this namespace.
Since:
v5r1m0

setClasspath

public static final void setClasspath(String id,
                                      String classpath)
Sets the classpath for the specified namespace. Only valid for namespaces created without a user-defined class loader.

Parameters:
id - The string identifier of the namespace as specified on a previous call to createNamespace.
classpath - The classpath string to set. The new classpath will completely replace any existing classpath for this namespace.
Throws:
IllegalArgumentException - If the specified namespace does not support this operation.
Since:
v5r1m0

getClasspath

public static final String getClasspath(String id)
Returns the current classpath for the specified namespace. Only valid for namespaces created without a user-defined class loader.

Parameters:
id - The string identifier of the namespace as specified on a previous call to createNamespace.
Returns:
The classpath string currently in effect for this namespace.
Throws:
IllegalArgumentException - If the specified namespace does not support this operation.
Since:
v5r1m0

addPath

public static final void addPath(String id,
                                 String path)
Appends a new file or directory name to the classpath for the specified namespace. Only valid for namespaces created without a user-defined class loader.

Parameters:
id - The string identifier of the namespace as specified on a previous call to createNamespace.
pathname - A valid name of a file system directory, ZIP file, or JAR file. The name may either be an absolute pathname or specified relative to the current directory.
Throws:
IllegalArgumentException - If the specified namespace does not support this operation, or if the specified pathname is not a valid file system directory, ZIP file name or JAR file name.
Since:
v5r1m0

removePath

public static final boolean removePath(String id,
                                       String path)
Removes the specified file or directory name from the classpath for the specified namespace. Only valid for namespaces created without a user-defined class loader.

Parameters:
id - The string identifier of the namespace as specified on a previous call to createNamespace.
pathname - The name of a file system directory, ZIP file, or JAR file.
Returns:
true if the path was successfully removed; false if the classpath does not contain the path.
Throws:
IllegalArgumentException - If the specified namespace does not support this operation, or if the specified pathname is not a valid file system directory, ZIP file name or JAR file name.
Since:
v5r1m0

loadClass

public static final Class loadClass(String id,
                                    String name)
                             throws ClassNotFoundException
Loads the class with the specified name. The class will be loaded using the class loader associated with the specified namespace.

Parameters:
id - The string identifier of the namespace as specified on a previous call to createNamespace.
name - the name of the class
Returns:
the resulting Class object
Throws:
ClassNotFoundException - if the class could not be found
Since:
v5r1m0

getResource

public static final URL getResource(String id,
                                    String name)
Finds the resource with the given name. A resource is some data (images, audio, text, etc) that can be accessed by class code in a way that is independent of the location of the code. The resource will be loaded using the class loader associated with the specified namespace.

The name of a resource is a "/"-separated path name that identifies the resource.

Parameters:
id - The string identifier of the namespace as specified on a previous call to createNamespace.
name - resource name
Returns:
a URL for reading the resource, or null if the resource could not be found or the caller doesn't have adequate privileges to get the resource.
Since:
v5r1m0

getResourceAsStream

public static final InputStream getResourceAsStream(String id,
                                                    String name)
Returns an input stream for reading the specified resource. The resource will be loaded using the class loader associated with the specified namespace.

Parameters:
id - The string identifier of the namespace as specified on a previous call to createNamespace.
name - the resource name
Returns:
an input stream for reading the resource, or null if the resource could not be found
Since:
v5r1m0

getPDMLDocument

public static final InputStream getPDMLDocument(String id,
                                                String baseName)
                                         throws MissingResourceException
Returns an InputStream for reading the contents of a PDML file. The file will be loaded using the class loader associated with the specified namespace.

Parameters:
id - The string identifier of the namespace as specified on a previous call to createNamespace.
baseName - The package qualified name of the PDML document.
Returns:
An input stream for reading the PDML file.
Throws:
MissingResourceException - If the PDML document cannot be found.
Since:
v5r1m0

getPDMLDocument

public static final InputStream getPDMLDocument(String id,
                                                String baseName,
                                                Locale locale)
                                         throws MissingResourceException
Returns an InputStream for reading the contents of a PDML file. The file will be loaded using the class loader associated with the specified namespace.

Parameters:
id - The string identifier of the namespace as specified on a previous call to createNamespace.
baseName - The package qualified name of the PDML document.
locale - The locale to use when searching for the PDML document.
Returns:
An input stream for reading the PDML file.
Throws:
MissingResourceException - If the PDML document cannot be found.
Since:
v5r1m0

getSerializedPDMLDocument

public static final InputStream getSerializedPDMLDocument(String id,
                                                          String panelName)
                                                   throws MissingResourceException
Returns an InputStream for reading the contents of a serialized panel definition file. The file will be loaded using the class loader associated with the specified namespace.

Parameters:
id - The string identifier of the namespace as specified on a previous call to createNamespace.
panelName - The name of the panel whose definition was serialized.
Returns:
An input stream for reading the serialized panel definition.
Throws:
MissingResourceException - If the serialized panel definition cannot be found.
Since:
v5r1m0

getSerializedPDMLDocument

public static final InputStream getSerializedPDMLDocument(String id,
                                                          String panelName,
                                                          Locale locale)
                                                   throws MissingResourceException
Returns an InputStream for reading the contents of a serialized panel definition file. The file will be loaded using the class loader associated with the specified namespace.

Parameters:
id - The string identifier of the namespace as specified on a previous call to createNamespace.
panelName - The name of the panel whose definition was serialized.
locale - The locale to use when searching for the serialized panel definition.
Returns:
An input stream for reading the serialized panel definition.
Throws:
MissingResourceException - If the serialized panel definition cannot be found.
Since:
v5r1m0

getHTMLDocument

public static final URL getHTMLDocument(String id,
                                        String panelName)
                                 throws MissingResourceException
Returns a URL for reading the contents of an HTML document containing online help for a panel. The file will be loaded using the class loader associated with the specified namespace.

Parameters:
id - The string identifier of the namespace as specified on a previous call to createNamespace.
panelName - The name of the panel whose online help is requested.
Returns:
A URL for reading the HTML document.
Throws:
MissingResourceException - If the HTML document cannot be found.
Since:
v5r1m0

getHTMLDocument

public static final URL getHTMLDocument(String id,
                                        String panelName,
                                        Locale locale)
                                 throws MissingResourceException
Returns a URL for reading the contents of an HTML document containing online help for a panel. The file will be loaded using the class loader associated with the specified namespace.

Parameters:
id - The string identifier of the namespace as specified on a previous call to createNamespace.
panelName - The name of the panel whose online help is requested.
locale - The locale to use when searching for the HTML document.
Returns:
A URL for reading the HTML document.
Throws:
MissingResourceException - If the HTML document cannot be found.
Since:
v5r1m0

getImageResource

public static final ImageIcon getImageResource(String id,
                                               String fileName)
                                        throws MissingResourceException
Returns an ImageIcon constructed using the contents of the specified image file. The file will be loaded using the class loader associated with the specified namespace.

Parameters:
id - The string identifier of the namespace as specified on a previous call to createNamespace.
fileName - The qualified name of the desired image file.
Returns:
An ImageIcon containing the image.
Throws:
MissingResourceException - If the image file cannot be found.
Since:
v5r1m0

flushImages

public static final void flushImages()
Flushes the cache of image resources. After this method is called, subsequent calls to getImageResource will reload the images from disk instead of obtaining them from the in-memory cache.

Since:
v5r1m0

flushImage

public static final void flushImage(ImageIcon imgIcon)
Flushes an image resource from the cache of image resources. After this method is called, subsequent calls to getImageResource will reload the image from disk instead of obtaining it from the in-memory cache.

Since:
v5r1m0