org.orbeon.oxf.resources
Class PriorityResourceManagerImpl

java.lang.Object
  extended by org.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 developer to bundle a resource, and still allow the user to override it easily.


Constructor Summary
PriorityResourceManagerImpl(Map<String,String> props)
           
 
Method Summary
 boolean canWrite(String key)
          Indicates if the resource manager implementation suports write operations
 boolean exists(String key)
          Check if a resource exists given its key.
 Node getContentAsDOM(String key)
          Gets a W3C DOM node for the specified key.
 org.dom4j.Document getContentAsDOM4J(String key)
          Gets a DOM4J document for the specified key.
 org.dom4j.Document getContentAsDOM4J(String key, XMLUtils.ParserConfiguration parserConfiguration, boolean handleLexical)
          Gets a DOM4J document for the specified key.
 void getContentAsSAX(String key, XMLReceiver xmlReceiver)
          Gets a document form the resource manager and send SAX events to the specified receiver.
 void getContentAsSAX(String key, XMLReceiver xmlReceiver, XMLUtils.ParserConfiguration parserConfiguration, boolean handleLexical)
          Gets a document form the resource manager and send SAX events to the specified receiver.
 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.
 XMLReceiver getWriteContentHandler(String key)
          Returns a receiver 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 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

PriorityResourceManagerImpl

public PriorityResourceManagerImpl(Map<String,String> 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 org.dom4j.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

getContentAsDOM4J

public org.dom4j.Document getContentAsDOM4J(String key,
                                            XMLUtils.ParserConfiguration parserConfiguration,
                                            boolean handleLexical)
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
parserConfiguration - parser configuration
handleLexical - whether the XML parser must output SAX LexicalHandler events, including comments @return a document element

getContentAsSAX

public void getContentAsSAX(String key,
                            XMLReceiver xmlReceiver)
Description copied from interface: ResourceManager
Gets a document form the resource manager and send SAX events to the specified receiver. 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
xmlReceiver - receiver where SAX events are sent

getContentAsSAX

public void getContentAsSAX(String key,
                            XMLReceiver xmlReceiver,
                            XMLUtils.ParserConfiguration parserConfiguration,
                            boolean handleLexical)
Description copied from interface: ResourceManager
Gets a document form the resource manager and send SAX events to the specified receiver. 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
xmlReceiver - receiver where SAX events are sent
parserConfiguration - parser configuration
handleLexical - whether the XML parser must output SAX LexicalHandler events, including comments

getContentAsStream

public InputStream getContentAsStream(String key)
Description copied from interface: ResourceManager
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)
Description copied from interface: ResourceManager
Gets the last modified timestamp for the specified resource

Specified by:
lastModified in interface ResourceManager
Parameters:
key - a Resource Manager key
Returns:
a timestamp

length

public int length(String key)
Description copied from interface: ResourceManager
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)
Description copied from interface: ResourceManager
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)
Description copied from interface: ResourceManager
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)
Description copied from interface: ResourceManager
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 XMLReceiver getWriteContentHandler(String key)
Description copied from interface: ResourceManager
Returns a receiver that can write to the Resource Manager.

Specified by:
getWriteContentHandler in interface ResourceManager
Parameters:
key - a Resource Manager key
Returns:
receiver

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

exists

public boolean exists(String key)
Description copied from interface: ResourceManager
Check if a resource exists given its key.

Specified by:
exists in interface ResourceManager
Parameters:
key - a Resource Manager key
Returns:
true iif the resource exists