org.orbeon.oxf.resources
Interface ResourceManager

All Known Implementing Classes:
PriorityResourceManagerImpl, org.orbeon.oxf.resources.ResourceManagerBase

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
 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)
          Gets the last modified timestamp for the specofoed resource
 int length(String key)
          Returns the length of the file denoted by this abstract pathname.
 

Method Detail

getContentAsDOM

public 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

public 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

getContentAsSAX

public void getContentAsSAX(String key,
                            ContentHandler handler)
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.

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

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

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

getXMLReader

public 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

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

Parameters:
key - A Resource Manager key
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

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

getWriteContentHandler

public ContentHandler getWriteContentHandler(String key)
Returns a ContentHandler that can write to the Resource Manager

Parameters:
key - A Resource Manager key
Returns:
A ContentHandler

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