org.ujac.util.io
Class CachedResourceLoader

java.lang.Object
  extended by org.ujac.util.io.CachedResourceLoader
All Implemented Interfaces:
ResourceLoader

public class CachedResourceLoader
extends Object
implements ResourceLoader

Name: MultiResourceLoader
Description: A resource loader which caches the resources it loads by a defined real ResourceLoader to reduce I/O.

Author:
lauerc

Constructor Summary
CachedResourceLoader(ResourceLoader resourceLoader)
          Constructs a CachedResourceLoader instance with specific attributes.
 
Method Summary
 void clearCache()
          Clears the resource cache.
 byte[] loadResource(String location)
          First checks the resource cache until the desired resource is really loaded by the defined loader.
 boolean resourceExists(String location)
          Checks whether or not the desired resource exists.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CachedResourceLoader

public CachedResourceLoader(ResourceLoader resourceLoader)
Constructs a CachedResourceLoader instance with specific attributes.

Parameters:
resourceLoader - The real resource loader.
Method Detail

loadResource

public byte[] loadResource(String location)
                    throws IOException
First checks the resource cache until the desired resource is really loaded by the defined loader.

Specified by:
loadResource in interface ResourceLoader
Parameters:
location - The location of the resource.
Returns:
The loaded resource.
Throws:
IOException - In case the loading of the resource failed.
See Also:
ResourceLoader.loadResource(java.lang.String)

resourceExists

public boolean resourceExists(String location)
Checks whether or not the desired resource exists.

Specified by:
resourceExists in interface ResourceLoader
Parameters:
location - The location of the resource.
Returns:
true in case the given resource could be located, else false.

clearCache

public void clearCache()
Clears the resource cache.



Copyright © 2003-2004 UJAC.org. All Rights Reserved.