hmi.util
Class ResourcePool

java.lang.Object
  extended by hmi.util.ResourcePool

public class ResourcePool
extends Object

A utility class for pools of resources, in particular for loading and caching resource objects.

Author:
Job zwiers

Nested Class Summary
static interface ResourcePool.ResourceLoader
          A ResourcePool.ResourceLoader object should be able to load a particular type of resource files from Resources, optionally using parameters passed on via the param array
 
Field Summary
private  ResourcePool.ResourceLoader loader
           
private  Map<String,Object> resourceCache
           
private  List<Resources> resourcesList
           
 
Constructor Summary
ResourcePool()
          Create a new ResourcePool
ResourcePool(ResourcePool.ResourceLoader loader)
          Create a new ResourcePool with defined ResourceLoader
 
Method Summary
 void addResourceDirectory(String resourceDir)
          Adds the specified directory to the (front of the) list of resource directories to be searched When some resource is actually present in more than one directory in the list, the version from the directory that was added latest will take preference.
private  Resources findResources(String resourceDir)
           
 Object getResource(String resourceName)
          Tries to get a resource with the specified name , without specifying properties
 Object getResource(String resourceName, Object[] properties)
           
 void setResourceLoader(ResourcePool.ResourceLoader loader)
          Defines the ResourcePool.ResourceLoader object that will be used for loading resource files.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

resourcesList

private List<Resources> resourcesList

resourceCache

private Map<String,Object> resourceCache

loader

private ResourcePool.ResourceLoader loader
Constructor Detail

ResourcePool

public ResourcePool()
Create a new ResourcePool


ResourcePool

public ResourcePool(ResourcePool.ResourceLoader loader)
Create a new ResourcePool with defined ResourceLoader

Method Detail

setResourceLoader

public void setResourceLoader(ResourcePool.ResourceLoader loader)
Defines the ResourcePool.ResourceLoader object that will be used for loading resource files.


addResourceDirectory

public void addResourceDirectory(String resourceDir)
Adds the specified directory to the (front of the) list of resource directories to be searched When some resource is actually present in more than one directory in the list, the version from the directory that was added latest will take preference.


findResources

private Resources findResources(String resourceDir)

getResource

public Object getResource(String resourceName,
                          Object[] properties)
                   throws IOException
Throws:
IOException

getResource

public Object getResource(String resourceName)
                   throws IOException
Tries to get a resource with the specified name , without specifying properties

Throws:
IOException