Interface for a SessionContext.
This interface describes a SessionContext. The SessionContext is a data
container containing structured XML which can be retrieved/set by the
sunshine transformer.
This interface does not specify how the session context stores the data.
This is left to the implementation itself, but actually this interface
is build in the DOM model.
As this context is used in a web context, all methods must be synchronized.
| Method from org.apache.cocoon.sunshine.context.SessionContext Detail: |
public void appendXML(String path,
DocumentFragment fragment) throws ProcessingException
Append a document fragment at the given path.
The implementation of this method is context specific.
Usually the children of the fragment are appended as new children of the
node specified by the path.
If the path is not existent it is created and this method should work
in the same way as setXML. |
public Object getAttribute(String key) throws ProcessingException
Get the value of a context attribute.
If the attribute is not available return null. |
public Object getAttribute(String key,
Object defaultObject) throws ProcessingException
Get the value of a context attribute.
If the attribute is not available the return the
defaultObject. |
public String getName()
Get the name of the context |
public NodeList getNodeList(String path) throws ProcessingException
Get a copy of all nodes specified by the path. |
public Node getSingleNode(String path) throws ProcessingException
Get a copy of the first node specified by the path.
If the node does not exist, null is returned. |
public String getValueOfNode(String path) throws ProcessingException
Get the value of this node.
This is similiar to the xsl:value-of function.
If the node does not exist, null is returned. |
public DocumentFragment getXML(String path) throws ProcessingException
Get a document fragment.
If the node specified by the path exist, its content is returned
as a DocumentFragment.
If the node does not exists, null is returned. |
public void loadXML(String path,
SourceParameters parameters,
Map objectModel,
SourceResolver resolver,
ComponentManager manager) throws IOException, SAXException, ProcessingException
Try to load XML into the context.
If the context does not provide the ability of loading,
an exception is thrown. |
public void removeXML(String path) throws ProcessingException
Remove some content from the context.
The implementation of this method is context specific.
Usually this method should remove all children of the node specified
by the path. |
public void saveXML(String path,
SourceParameters parameters,
Map objectModel,
SourceResolver resolver,
ComponentManager manager) throws IOException, SAXException, ProcessingException
Try to save XML from the context.
If the context does not provide the ability of saving,
an exception is thrown. |
public void setAttribute(String key,
Object value) throws ProcessingException
Set a context attribute.
Attributes over a means to store any data (object) in a session
context. If value is null the attribute is
removed. If already an attribute exists with the same key, the value
is overwritten with the new one. |
public void setNode(String path,
Node node) throws ProcessingException
Set the value of a node. The node is copied before insertion. |
public void setValueOfNode(String path,
String value) throws ProcessingException
Set the value of a node.
All children of the node are removed beforehand and one single text
node with the given value is appended to the node. |
public void setXML(String path,
DocumentFragment fragment) throws ProcessingException
Set a document fragment at the given path.
The implementation of this method is context specific.
Usually all children of the node specified by the path are removed
and the children of the fragment are inserted as new children.
If the path is not existent it is created. |
public void setup(String value,
Resource load,
Resource save)
Set the name of the context.
This method must be invoked in the init phase.
In addition a load and a save resource can be provided. |
public boolean streamXML(String path,
ContentHandler contentHandler,
LexicalHandler lexicalHandler) throws SAXException, ProcessingException
Stream the XML directly to the handler.
This streams the contents of getXML() to the given handler without
creating a DocumentFragment containing a copy of the data.
If no data is available (if the path does not exist) false is
returned, otherwise true. |