org.orbeon.oxf.resources
Interface ResourceManager

All Known Implementing Classes:
PriorityResourceManagerImpl

public interface ResourceManager

This is the main interface a resource manager must implement. A resource manager key is a path-like string, locating a resource. For example: /config/text.xml /pages/icon.gif Resources Manager could store resource in flat files (see FlatFileResourceManagerImpl), in relational databases (see DBResourceManagerImpl) or in an application dependent way.


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.
 

Method Detail

getContentAsDOM

Node getContentAsDOM(String key)
Gets a W3C DOM node for the specified key. The key must point to an XML document, or a OXFException is raised.

Parameters:
key - a Resource Manager key
Returns:
a node element

getContentAsDOM4J

org.dom4j.Document getContentAsDOM4J(String key)
Gets a DOM4J document for the specified key. The key must point to an XML document, or a OXFException is raised.

Parameters:
key - a Resource Manager key
Returns:
a document element

getContentAsDOM4J

org.dom4j.Document getContentAsDOM4J(String key,
                                     XMLUtils.ParserConfiguration parserConfiguration,
                                     boolean handleLexical)
Gets a DOM4J document for the specified key. The key must point to an XML document, or a OXFException is raised.

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

void getContentAsSAX(String key,
                     XMLReceiver xmlReceiver)
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.

Parameters:
key - a Resource Manager key
xmlReceiver - receiver where SAX events are sent

getContentAsSAX

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. the key must point to an XML document, or a OXFException is raised.

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

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

getXMLReader

XMLReader getXMLReader()
Returns a XMLReader interface to the resource manager. One should then use the setContentHandler() and parse(String key)
Returns:
An XML reader

lastModified

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

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

length

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

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

Parameters:
key - a Resource Manager key
Returns:
true if write operations are allowed

getWriteContentHandler

XMLReceiver getWriteContentHandler(String key)
Returns a receiver that can write to the Resource Manager.

Parameters:
key - a Resource Manager key
Returns:
receiver

getOutputStream

OutputStream getOutputStream(String key)
Allows writing to the resource

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

getWriter

Writer getWriter(String key)
Allow writing to the resource

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

getRealPath

String getRealPath(String key)
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.


exists

boolean exists(String key)
Check if a resource exists given its key.

Parameters:
key - a Resource Manager key
Returns:
true iif the resource exists