SalesPoint Framework v3.1

resource.util
Class ResourceManager

java.lang.Object
  extended byresource.util.ResourceManager

public class ResourceManager
extends Object

The global manager for all resources. The ResourceManager is responsible for managing all binary resources of the framework. This can be images, videos, text ...

Resources are managed as follows:

The root directory is a directory ending with the name "resource". Here it is just the directory "resource". Starting from this directory all resources are given back relative to this path.

There can be multiple resouces to manage: gif-images, jpeg-images, text and others.
For all of these resources there should exist one resource module.
There is already one module for gif-resources.

Resources are requested as follows:
URL url = ResourceManager.getInstance().getResource (String type, String path);
The "type" is the name of the resource module. The path string is the path relative to the directory of the requested type and is separated with a dot.
Example:

An icon of the size 16x16 should be requested. It is located in the directory "resource/gif/icon".
The icon's name is "document.gif". So the call is:
URL url = ResourceManager.getInstance().getResource (RESOURCE_GIF, "icon.document");

Author:
Thomas Medack

Nested Class Summary
static interface ResourceManager.ResourceModul
          Interface for a resource module.
 
Field Summary
static String RESOURCE_GIF
          Type name for resource module: GIF
protected  String resourceRootPath
          The root path of all resources.
 
Constructor Summary
protected ResourceManager()
          Creates a new instance of ResourceManager.
 
Method Summary
 void addResourceModul(ResourceManager.ResourceModul rm)
          Adds a resource module to the ResourceManager.
 String getFullPath(String type, String path)
          Returns the full path of a resource..
static ResourceManager getInstance()
          Returns the singleton instance of the ResourceManager.
 URL getResource(String type, String path)
          Returns a resource as URL.
 void removeResourceModul(ResourceManager.ResourceModul rm)
          Removes a resource module from the ResourceManager.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

resourceRootPath

protected String resourceRootPath
The root path of all resources.


RESOURCE_GIF

public static final String RESOURCE_GIF
Type name for resource module: GIF

See Also:
Constant Field Values
Constructor Detail

ResourceManager

protected ResourceManager()
Creates a new instance of ResourceManager.

Method Detail

getInstance

public static ResourceManager getInstance()
Returns the singleton instance of the ResourceManager.

Returns:
the singleton instance.

addResourceModul

public void addResourceModul(ResourceManager.ResourceModul rm)
Adds a resource module to the ResourceManager.

Parameters:
rm - the resource module to be added.

removeResourceModul

public void removeResourceModul(ResourceManager.ResourceModul rm)
Removes a resource module from the ResourceManager.

Parameters:
rm - the resource module to be removed.

getResource

public URL getResource(String type,
                       String path)
Returns a resource as URL. Therefor the logical name of the resource module and the relative path starting from it have to be specified.

Example:

logical name of the gif-module: "RESOURCE_GIF". The absolute path of this module is "org/eit/ui/resource/gif". The requested resource is "document.gif".
Therefore the call is: getResource ("RESOURCE_GIF", "icon.16x16.document) (without file extension).

Parameters:
type - the logical type name
path - der relative path + file name without extension
Returns:
the resource's URL.

getFullPath

public String getFullPath(String type,
                          String path)
Returns the full path of a resource..

Parameters:
type - the logical type name
path - der relative path + file name without extension
Returns:
the resource's full path as String.

SalesPoint Framework v3.1