com.pegacat.vcf.utility
Class PluginResourceLoader

java.lang.Object
  |
  +--com.pegacat.vcf.utility.PluginResourceLoader

public class PluginResourceLoader
extends java.lang.Object

This Class provides access to a group of zip files. In the case of namespace conflicts between Zip files, the first zip file registered has priority. The zip files are accessed through PluginResource.


Field Summary
static boolean debug
          Whether to print out shtuff on the way.
protected  PluginResource[] resourceFiles
          A list of PluginResource objects that may be searched for packaged resources.
protected  java.util.HashSet unknownResources
          a cached list of 'unknown' resources that have been (unsuccessfully) looked up before.
 
Constructor Summary
PluginResourceLoader()
          Constructor - note that that the class is useless until at least one resource file has been registered with it using the addResource() method.
 
Method Summary
 void addResource(PluginResource resource)
          Adds a new zip/jar resource file to the list of files to be examined for resources.
 java.awt.Image getImage(java.lang.String imageName, java.awt.Toolkit imageCreator)
          Search all registered zip files for a particular Image, and return an awt Image object.
 java.io.InputStream getInputStream(java.lang.String resourceName)
          Search all registered zip files for a particular file, and return an input stream to that file.
 PluginResource getJarContainingResource(java.lang.String resourceName)
          Searches an internal hash, followed by all Jar files, for a particular resource.
 java.lang.String[] getPrefixedResources(java.lang.String prefix)
          Returns all resources with the given prefix.
 byte[] getResource(java.lang.String resourceName)
          Search all registered zip files for a particular file, and return the data within that file as a byte array.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

debug

public static boolean debug
Whether to print out shtuff on the way.

unknownResources

protected java.util.HashSet unknownResources
a cached list of 'unknown' resources that have been (unsuccessfully) looked up before.

resourceFiles

protected PluginResource[] resourceFiles
A list of PluginResource objects that may be searched for packaged resources.
Constructor Detail

PluginResourceLoader

public PluginResourceLoader()
Constructor - note that that the class is useless until at least one resource file has been registered with it using the addResource() method.
Method Detail

addResource

public void addResource(PluginResource resource)
Adds a new zip/jar resource file to the list of files to be examined for resources.

getInputStream

public java.io.InputStream getInputStream(java.lang.String resourceName)
                                   throws java.util.zip.ZipException
Search all registered zip files for a particular file, and return an input stream to that file.

getImage

public java.awt.Image getImage(java.lang.String imageName,
                               java.awt.Toolkit imageCreator)
                        throws java.util.zip.ZipException
Search all registered zip files for a particular Image, and return an awt Image object.

getResource

public byte[] getResource(java.lang.String resourceName)
                   throws java.util.zip.ZipException
Search all registered zip files for a particular file, and return the data within that file as a byte array. (This might be used to initialise a String object if the file is a text file, for instance.)

getJarContainingResource

public PluginResource getJarContainingResource(java.lang.String resourceName)
Searches an internal hash, followed by all Jar files, for a particular resource.

getPrefixedResources

public java.lang.String[] getPrefixedResources(java.lang.String prefix)
Returns all resources with the given prefix.
Parameters:
prefix - a string to match the start of resources against, e.g. 'icons/'