org.orbeon.oxf.resources
Class PriorityResourceManagerImpl

java.lang.Object
  extended byorg.orbeon.oxf.resources.PriorityResourceManagerImpl
All Implemented Interfaces:
ResourceManager

public class PriorityResourceManagerImpl
extends Object
implements ResourceManager

The priority resource manager delegates to two or more resource managers the loading of documents. For example, if a flat file resource manager doesn't contain a document, a second classloader resource manager might load it. This is an important feature that allows an application developper to bundle a resource, and still allow the user to override it easily.


Constructor Summary
PriorityResourceManagerImpl(Map props)
           
 
Method Summary
 boolean canWrite(String key)
          Indicates if the resource manager implementation suports write operations
 Node getContentAsDOM(String key)
          Gets a W3C DOM node for the specified key.
 Document getContentAsDOM4J(String key)
          Gets a DOM4J document for the specified key.
 void getContentAsSAX(String key, ContentHandler handler)
          Gets a document form the resource manager and send SAX events to the specified content handler.
 void getContentAsSAX(String key, ContentHandler handler, boolean validating, boolean handleXInclude)
          Gets a document form the resource manager and send SAX events to the specified content handler.
 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)
          Returns the path to the given resource on the file system.
 ContentHandler getWriteContentHandler(String key)
          Returns a ContentHandler that can write to the Resource Manager
 Writer getWriter(String key)
          Allow writing to the resource
 XMLReader getXMLReader()
          Returns a XMLReader interface to the resource manager.
 long lastModified(String key, boolean doNotThrowResourceNotFound)
          Gets the last modified timestamp for the specofoed 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

PriorityResourceManagerImpl

public PriorityResourceManagerImpl(Map props)
Method Detail

getContentAsDOM

public Node getContentAsDOM(String key)
Description copied from interface: ResourceManager
Gets a W3C DOM node for the specified key. The key must point to an XML document, or a OXFException is raised.

Specified by:
getContentAsDOM in interface ResourceManager
Parameters:
key - A Resource Manager key
Returns:
a node element

getContentAsDOM4J

public Document getContentAsDOM4J(String key)
Description copied from interface: ResourceManager
Gets a DOM4J document for the specified key. The key must point to an XML document, or a OXFException is raised.

Specified by:
getContentAsDOM4J in interface ResourceManager
Parameters:
key - A Resource Manager key
Returns:
a document element

getContentAsSAX

public void getContentAsSAX(String key,
                            ContentHandler handler)
Description copied from interface: ResourceManager
Gets a document form the resource manager and send SAX events to the specified content handler. the key must point to an XML document, or a OXFException is raised.

Specified by:
getContentAsSAX in interface ResourceManager
Parameters:
key - A Resource Manager key
handler - The content handler where SAX events are sent

getContentAsSAX

public void getContentAsSAX(String key,
                            ContentHandler handler,
                            boolean validating,
                            boolean handleXInclude)
Description copied from interface: ResourceManager
Gets a document form the resource manager and send SAX events to the specified content handler. the key must point to an XML document, or a OXFException is raised.

Specified by:
getContentAsSAX in interface ResourceManager
Parameters:
key - A Resource Manager key
handler - The content handler where SAX events are sent
validating - Whether the XML parser must attempt to validate the resource
handleXInclude - Whether the XML parser must process XInclude instructions

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).

Specified by:
getContentAsStream in interface ResourceManager
Parameters:
key - A Resource Manager key
Returns:
a input stream

lastModified

public long lastModified(String key,
                         boolean doNotThrowResourceNotFound)
Gets the last modified timestamp for the specofoed resource

Specified by:
lastModified in interface ResourceManager
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.

Specified by:
length in interface ResourceManager
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

Specified by:
canWrite in interface ResourceManager
Parameters:
key - A Resource Manager key
Returns:
true if write operations are allowed

getOutputStream

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

Specified by:
getOutputStream in interface ResourceManager
Parameters:
key - A Resource Manager key
Returns:
an output stream

getWriter

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

Specified by:
getWriter in interface ResourceManager
Parameters:
key - A Resource Manager key
Returns:
a writer

getRealPath

public String getRealPath(String key)
Description copied from interface: ResourceManager
Returns the path to the given resource on the file system. If a path on the local file system cannot be provided by the resource manager, null is returned.

Specified by:
getRealPath in interface ResourceManager

getWriteContentHandler

public ContentHandler getWriteContentHandler(String key)
Description copied from interface: ResourceManager
Returns a ContentHandler that can write to the Resource Manager

Specified by:
getWriteContentHandler in interface ResourceManager
Parameters:
key - A Resource Manager key
Returns:
A ContentHandler

getXMLReader

public XMLReader getXMLReader()
Description copied from interface: ResourceManager
Returns a XMLReader interface to the resource manager. One should then use the setContentHandler() and parse(String key)
Specified by:
getXMLReader in interface ResourceManager
Returns:
An XML reader