org.orbeon.oxf.resources
Class ClassLoaderResourceManagerImpl

java.lang.Object
  extended by ResourceManagerBase
      extended by org.orbeon.oxf.resources.ClassLoaderResourceManagerImpl

public class ClassLoaderResourceManagerImpl
extends ResourceManagerBase

The classloader resource manager is able to load resources from a JAR file, or from a directory in the system classpath. It is useful when resources are bundled with an application.


Constructor Summary
ClassLoaderResourceManagerImpl(Map props)
          Initialize this resource manager.
ClassLoaderResourceManagerImpl(Map props, Class c)
          Initialize this resource manager with rooted in the specified class
 
Method Summary
 boolean canWrite(String key)
          Indicates if the resource manager implementation suports write operations
 Reader getContentAsReader(String key)
          Returns a character reader from the resource manager for the specified key.
 InputStream getContentAsStream(String key)
          Returns a binary input stream for the specified key.
 OutputStream getOutputStream(String key)
          Allows writing to the resource
 String getRealPath(String key)
           
 Writer getWriter(String key)
          Allow writing to the resource
protected  long lastModifiedImpl(String key, boolean doNotThrowResourceNotFound)
          Gets the last modified timestamp for the specified resource
 int length(String key)
          Returns the length of the file denoted by this abstract pathname.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClassLoaderResourceManagerImpl

public ClassLoaderResourceManagerImpl(Map props)
Initialize this resource manager.


ClassLoaderResourceManagerImpl

public ClassLoaderResourceManagerImpl(Map props,
                                      Class c)
Initialize this resource manager with rooted in the specified class

Parameters:
c - a root class
Method Detail

getContentAsReader

public Reader getContentAsReader(String key)
Returns a character reader from the resource manager for the specified key. The key could point to any text document.

Parameters:
key - A Resource Manager key
Returns:
a character reader

getContentAsStream

public InputStream getContentAsStream(String key)
Returns a binary input stream for the specified key. The key could point to any document type (text or binary).

Parameters:
key - A Resource Manager key
Returns:
a input stream

lastModifiedImpl

protected long lastModifiedImpl(String key,
                                boolean doNotThrowResourceNotFound)
Gets the last modified timestamp for the specified resource

Parameters:
key - A Resource Manager key
doNotThrowResourceNotFound -
Returns:
a timestamp

length

public int length(String key)
Returns the length of the file denoted by this abstract pathname.

Returns:
The length, in bytes, of the file denoted by this abstract pathname, or 0L if the file does not exist

canWrite

public boolean canWrite(String key)
Indicates if the resource manager implementation suports write operations

Returns:
true if write operations are allowed

getOutputStream

public OutputStream getOutputStream(String key)
Allows writing to the resource

Parameters:
key - A Resource Manager key
Returns:
an output stream

getWriter

public Writer getWriter(String key)
Allow writing to the resource

Parameters:
key - A Resource Manager key
Returns:
a writer

getRealPath

public String getRealPath(String key)