com.opencms.template
Class A_CmsXmlContent

java.lang.Object
  |
  +--com.opencms.template.A_CmsXmlContent
All Implemented Interfaces:
Cloneable, I_CmsContent, I_CmsLogChannels, I_CmsXmlContent
Direct Known Subclasses:
CmsRegistry, CmsXmlControlFile, CmsXmlLanguageFileContent, CmsXmlTemplateFile, CmsXmlWpBoxDefFile, CmsXmlWpButtonsDefFile, CmsXmlWpInputDefFile, CmsXmlWpLabelDefFile

public abstract class A_CmsXmlContent
extends Object
implements I_CmsXmlContent, I_CmsLogChannels

Abstract class for OpenCms files with XML content.

This class implements basic functionality for OpenCms XML files. For each XML file content type (e.g. XML template files, XML control files, XML news article files, ...) a customized class extending this abstract class has to be implemented.

The functionality of this class is:

After creating a new instance of the children of this class it has to be initialized by calling the init method.

While initializing the content of the given file will be read and parsed with the XML parser. After this, the parsed document will be scanned for INCLUDE tags and for DATA tags. DATA tags will be stored in an internal Hashtable an can easily be accessed by the getData methods or by a PROCESS tag.

Extending classes have to implement the abstract methods getXmlDocumentTagName() and getContentDescription().

Version:
$Revision: 1.72 $ $Date: 2003/02/17 10:02:55 $
Author:
Alexander Lucas

Field Summary
static String C_ERR_NODATABLOCK
          Error message for bad <PROCESS> tags
static String C_MINIMUM_CLASSNAME
          The classname of the super XML content class
static Class[] C_PARAMTYPES_HANDLING_METHODS
          parameter types for XML node handling methods.
static Class[] C_PARAMTYPES_USER_METHODS
          parameter types for user methods called by METHOD tags
protected static int C_REGISTER_FIRST_RUN
          constant for registering handling tags
protected static int C_REGISTER_MAIN_RUN
          constant for registering handling tags
static String C_TEMPLATE_EXTENSION
          Constant extension of the template-files.
static String C_TEMPLATEPATH
          Constant pathname, where to find templates
protected  CmsObject m_cms
          CmsObject Object for accessing resources
protected  Hashtable m_firstRunTags
          This Hashtable contains some XML tags as keys and the corresponding methods as values.
protected  Vector m_knownTags
          All XML tags known by this class.
protected  Hashtable m_mainProcessTags
          This Hashtable contains some XML tags as keys and the corresponding methods as values.
 
Fields inherited from interface com.opencms.boot.I_CmsLogChannels
C_FLEX_CACHE, C_FLEX_LOADER, C_LOGGING, C_MODULE_CRITICAL, C_MODULE_DEBUG, C_MODULE_INFO, C_OPENCMS_CACHE, C_OPENCMS_CRITICAL, C_OPENCMS_CRONSCHEDULER, C_OPENCMS_DEBUG, C_OPENCMS_ELEMENTCACHE, C_OPENCMS_INFO, C_OPENCMS_INIT, C_OPENCMS_POOL, C_OPENCMS_STATICEXPORT, C_OPENCMS_STREAMING, C_PREPROCESSOR_IS_LOGGING
 
Constructor Summary
A_CmsXmlContent()
          Constructor for creating a new instance of this class
 
Method Summary
protected  void callAllUncalledMethodsSoThatEclipseDoesntComplainAboutThem()
          This method is just a hack so that the Eclise IDE will not show the methods listed here as warnings when the "unused private methods" option is selected, since they are called only using reclection API.
protected  Object callUserMethod(String methodName, String parameter, Object callingObject, Object userObj, boolean resolveMethods)
          Calls a user method in the object callingObject.
static void clearFileCache()
          Deletes all files from the file cache.
static void clearFileCache(A_CmsXmlContent doc)
          Deletes the file represented by the given A_CmsXmlContent from the file cache.
static void clearFileCache(String key)
          Deletes the file with the given key from the file cache.
 Object clone()
          Creates a clone of this object.
 void createNewFile(CmsObject cms, String filename, String documentType)
          Create a new CmsFile object containing an empty XML file of the current content type.
protected  void fastSetData(String tag, String data)
          Fast method to replace a datablock.
 String getAbsoluteFilename()
          Gets the absolute filename of the XML file represented by this content class
protected  Hashtable getAllData()
          Gets all datablocks (the datablock hashtable).
protected  String getClassName()
          Help method to print nice classnames in error messages
abstract  String getContentDescription()
          This method should be implemented by every extending class.
protected  Element getData(String tag)
          Gets a complete datablock from the datablock hashtable.
protected  String getDataValue(String tag)
          Gets the text and CDATA content of a datablock from the datablock hashtable.
 String getEncoding()
          Returns current XML document encoding.
 String getFilename()
          Gets a short filename (without path) of the XML file represented by this content class of the template file.
protected  Element getProcessedData(String tag)
          Gets a processed datablock from the datablock hashtable.
protected  Element getProcessedData(String tag, Object callingObject)
          Gets a processed datablock from the datablock hashtable.
protected  Element getProcessedData(String tag, Object callingObject, Object userObj)
          Gets a processed datablock from the datablock hashtable.
protected  Element getProcessedData(String tag, Object callingObject, Object userObj, OutputStream stream)
          Gets a processed datablock from the datablock hashtable.
protected  String getProcessedDataValue(String tag)
          Gets the text and CDATA content of a processed datablock from the datablock hashtable.
protected  String getProcessedDataValue(String tag, Object callingObject)
          Gets the text and CDATA content of a processed datablock from the datablock hashtable.
protected  String getProcessedDataValue(String tag, Object callingObject, Object userObj)
          Gets the text and CDATA content of a processed datablock from the datablock hashtable.
protected  String getProcessedDataValue(String tag, Object callingObject, Object userObj, OutputStream stream)
          Gets the text and CDATA content of a processed datablock from the datablock hashtable.
protected  String getTagValue(Element n)
          Reads all text or CDATA values from the given XML element, e.g.
protected  Document getXmlDocument()
          Gets the XML parsed content of this template file as a DOM document.
abstract  String getXmlDocumentTagName()
          This method should be implemented by every extending class.
static I_CmsXmlParser getXmlParser()
          Gets the currently used XML Parser.
 String getXmlText()
          Prints the XML parsed content to a String
 String getXmlText(Node n)
          Prints the XML parsed content of a given node and its subnodes to a String
 void getXmlText(OutputStream out)
           
 void getXmlText(OutputStream out, Node n)
           
 void getXmlText(Writer out)
          Prints the XML parsed content of this template file to the given Writer.
 void getXmlText(Writer out, Node n)
          Prints the XML parsed content of the given Node and its subnodes to the given Writer.
protected  boolean hasData(String key)
          Checks if this Template owns a datablock with the given key.
 void init(CmsObject cms, CmsFile file)
          Initialize the XML content class.
 void init(CmsObject cms, Document content, String filename)
          Initialize the class with the given parsed XML DOM document.
 void init(CmsObject cms, String filename)
          Initialize the XML content class.
protected  Document parse(byte[] content)
           
protected  Document parse(InputStream content)
          Starts the XML parser with the content of the given CmsFile object.
protected  void processDocument(Hashtable keys, Method defaultMethod, Object callingObject, Object userObj)
          Main processing funtion for the whole XML document.
protected  void processNode(Node n, Hashtable keys, Method defaultMethod, Object callingObject, Object userObj)
          Universal main processing function for parsed XML templates.
protected  void processNode(Node n, Hashtable keys, Method defaultMethod, Object callingObject, Object userObj, OutputStream stream)
           
 void readIncludeFile(A_CmsXmlContent include)
          Read the datablocks of the given content file and include them into the own Hashtable of datablocks.
 A_CmsXmlContent readIncludeFile(String filename)
          Parses the given file and stores it in the internal list of included files and appends the relevant data structures of the new file to its own structures.
 void registerTag(String tagname)
          Registers the given tag to be "known" by the system.
 void registerTag(String tagname, Class c, String methodName, int runSelector)
          Registeres a tagname together with a corresponding method for processing with processNode.
protected  void removeData(String tag)
          Remove a datablock from the internal hashtable and from the XML document
 void removeFromFileCache()
          Deletes this object from the internal XML file cache
protected  void setData(String tag, Element data)
          Stores a given datablock element in the datablock hashtable.
protected  void setData(String tag, String data)
          Creates a datablock consisting of a single TextNode containing data and stores this block into the datablock-hashtable.
 void setEncoding(String encoding)
          Sets new encoding for XML document.
 void setParsedData(String tag, String data)
          Creates a datablock element by parsing the data string and stores this block into the datablock-hashtable.
protected  void throwException(String errorMessage)
          Help method that handles any occuring exception by writing an error message to the OpenCms logfile and throwing a CmsException of the type "unknown".
protected  void throwException(String errorMessage, Exception e)
          Help method that handles any occuring exception by writing an error message to the OpenCms logfile and throwing a CmsException of the type "unknown".
protected  void throwException(String errorMessage, Exception e, int type)
          Help method that handles any occuring exception by writing an error message to the OpenCms logfile and throwing a CmsException of the type "unknown".
protected  void throwException(String errorMessage, int type)
          Help method that handles any occuring exception by writing an error message to the OpenCms logfile and throwing a CmsException of the given type.
 String toString()
          Gets a string representation of this object.
protected  Node treeWalker(Node root, Node n)
          Help method to walk through the DOM document tree.
protected  Node treeWalkerWidth(Node root, Node n)
          Help method to walk through the DOM document tree by a width-first-order.
 void write()
          Writes the XML document back to the OpenCms system.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

C_PARAMTYPES_HANDLING_METHODS

public static final Class[] C_PARAMTYPES_HANDLING_METHODS
parameter types for XML node handling methods.


C_PARAMTYPES_USER_METHODS

public static final Class[] C_PARAMTYPES_USER_METHODS
parameter types for user methods called by METHOD tags


C_MINIMUM_CLASSNAME

public static final String C_MINIMUM_CLASSNAME
The classname of the super XML content class

See Also:
Constant Field Values

C_TEMPLATEPATH

public static final String C_TEMPLATEPATH
Constant pathname, where to find templates

See Also:
Constant Field Values

C_TEMPLATE_EXTENSION

public static final String C_TEMPLATE_EXTENSION
Constant extension of the template-files.

See Also:
Constant Field Values

C_ERR_NODATABLOCK

public static final String C_ERR_NODATABLOCK
Error message for bad <PROCESS> tags

See Also:
Constant Field Values

m_cms

protected CmsObject m_cms
CmsObject Object for accessing resources


m_knownTags

protected Vector m_knownTags
All XML tags known by this class.


m_firstRunTags

protected Hashtable m_firstRunTags
This Hashtable contains some XML tags as keys and the corresponding methods as values. Used to pass to processNode() to read in include files and scan for datablocks.


m_mainProcessTags

protected Hashtable m_mainProcessTags
This Hashtable contains some XML tags as keys and the corresponding methods as values. Used to pass to processNode() before generating HTML output.


C_REGISTER_FIRST_RUN

protected static final int C_REGISTER_FIRST_RUN
constant for registering handling tags

See Also:
Constant Field Values

C_REGISTER_MAIN_RUN

protected static final int C_REGISTER_MAIN_RUN
constant for registering handling tags

See Also:
Constant Field Values
Constructor Detail

A_CmsXmlContent

public A_CmsXmlContent()
Constructor for creating a new instance of this class

Method Detail

callUserMethod

protected Object callUserMethod(String methodName,
                                String parameter,
                                Object callingObject,
                                Object userObj,
                                boolean resolveMethods)
                         throws CmsException
Calls a user method in the object callingObject. Every user method has to user the parameter types defined in C_PARAMTYPES_USER_METHODS to be recognized by this method.

Parameters:
methodName - Name of the method to be called.
parameter - Additional parameter passed to the method.
callingObject - Reference to the object containing the called method.
userObj - Customizable user object that will be passed through to the user method.
resolveMethods - If true the methodtags will be resolved even if they have own CacheDirectives.
Throws:
CmsException
See Also:
C_PARAMTYPES_USER_METHODS

clearFileCache

public static void clearFileCache()
Deletes all files from the file cache.


clearFileCache

public static void clearFileCache(A_CmsXmlContent doc)
Deletes the file represented by the given A_CmsXmlContent from the file cache.

Parameters:
doc - A_CmsXmlContent representing the XML file to be deleted.

clearFileCache

public static void clearFileCache(String key)
Deletes the file with the given key from the file cache. If no such file exists nothing happens.

Parameters:
key - Key of the template file to be removed from the cache.

clone

public Object clone()
             throws CloneNotSupportedException
Creates a clone of this object.

Specified by:
clone in interface I_CmsXmlContent
Overrides:
clone in class Object
Returns:
cloned object.
Throws:
CloneNotSupportedException

createNewFile

public void createNewFile(CmsObject cms,
                          String filename,
                          String documentType)
                   throws CmsException
Create a new CmsFile object containing an empty XML file of the current content type. The String returned by getXmlDocumentTagName() will be used to build the XML document element.

Parameters:
cms - Current cms object used for accessing system resources.
filename - Name of the file to be created.
documentType - Document type of the new file.
Throws:
CmsException - if no absolute filename is given or write access failed.

fastSetData

protected void fastSetData(String tag,
                           String data)
Fast method to replace a datablock.

USE WITH CARE!

Using this method only if

Parameters:
tag - Key for this datablock.
data - String to be put in the datablock.

getAbsoluteFilename

public String getAbsoluteFilename()
Gets the absolute filename of the XML file represented by this content class

Specified by:
getAbsoluteFilename in interface I_CmsXmlContent
Returns:
Absolute filename

getAllData

protected Hashtable getAllData()
Gets all datablocks (the datablock hashtable).

Returns:
Hashtable with all datablocks.

getClassName

protected String getClassName()
Help method to print nice classnames in error messages

Returns:
class name in [ClassName] format

getContentDescription

public abstract String getContentDescription()
This method should be implemented by every extending class. It returns a short description of the content definition type (e.g. "OpenCms news article").

Returns:
content description.

getData

protected Element getData(String tag)
                   throws CmsException
Gets a complete datablock from the datablock hashtable.

Parameters:
tag - Key for the datablocks hashtable.
Returns:
Complete DOM element of the datablock for the given key or null if no datablock is found for this key.
CmsException

getDataValue

protected String getDataValue(String tag)
                       throws CmsException
Gets the text and CDATA content of a datablock from the datablock hashtable.

Parameters:
tag - Key for the datablocks hashtable.
Returns:
Datablock content for the given key or null if no datablock is found for this key.
CmsException

getFilename

public String getFilename()
Gets a short filename (without path) of the XML file represented by this content class of the template file.

Specified by:
getFilename in interface I_CmsXmlContent
Returns:
filename

getProcessedData

protected Element getProcessedData(String tag)
                            throws CmsException
Gets a processed datablock from the datablock hashtable.

Parameters:
tag - Key for the datablocks hashtable.
Returns:
Processed datablock for the given key.
Throws:
CmsException

getProcessedData

protected Element getProcessedData(String tag,
                                   Object callingObject)
                            throws CmsException
Gets a processed datablock from the datablock hashtable.

Parameters:
tag - Key for the datablocks hashtable.
callingObject - Object that should be used to look up user methods.
Returns:
Processed datablock for the given key.
Throws:
CmsException

getProcessedData

protected Element getProcessedData(String tag,
                                   Object callingObject,
                                   Object userObj)
                            throws CmsException
Gets a processed datablock from the datablock hashtable.

The userObj Object is passed to all called user methods. By using this, the initiating class can pass customized data to its methods.

Parameters:
tag - Key for the datablocks hashtable.
callingObject - Object that should be used to look up user methods.
userObj - any object that should be passed to user methods
Returns:
Processed datablock for the given key.
Throws:
CmsException

getProcessedData

protected Element getProcessedData(String tag,
                                   Object callingObject,
                                   Object userObj,
                                   OutputStream stream)
                            throws CmsException
Gets a processed datablock from the datablock hashtable.

The userObj Object is passed to all called user methods. By using this, the initiating class can pass customized data to its methods.

Parameters:
tag - Key for the datablocks hashtable.
callingObject - Object that should be used to look up user methods.
userObj - any object that should be passed to user methods
stream - OutputStream that may be used for directly streaming the results or null.
Returns:
Processed datablock for the given key.
Throws:
CmsException

getProcessedDataValue

protected String getProcessedDataValue(String tag)
                                throws CmsException
Gets the text and CDATA content of a processed datablock from the datablock hashtable.

Parameters:
tag - Key for the datablocks hashtable.
Returns:
Processed datablock for the given key.
Throws:
CmsException

getProcessedDataValue

protected String getProcessedDataValue(String tag,
                                       Object callingObject)
                                throws CmsException
Gets the text and CDATA content of a processed datablock from the datablock hashtable.

Parameters:
tag - Key for the datablocks hashtable.
callingObject - Object that should be used to look up user methods.
Returns:
Processed datablock for the given key.
Throws:
CmsException

getProcessedDataValue

protected String getProcessedDataValue(String tag,
                                       Object callingObject,
                                       Object userObj)
                                throws CmsException
Gets the text and CDATA content of a processed datablock from the datablock hashtable.

The userObj Object is passed to all called user methods. By using this, the initiating class can pass customized data to its methods.

Parameters:
tag - Key for the datablocks hashtable.
callingObject - Object that should be used to look up user methods.
userObj - any object that should be passed to user methods
Returns:
Processed datablock for the given key.
Throws:
CmsException

getProcessedDataValue

protected String getProcessedDataValue(String tag,
                                       Object callingObject,
                                       Object userObj,
                                       OutputStream stream)
                                throws CmsException
Gets the text and CDATA content of a processed datablock from the datablock hashtable. An eventually given output stream is user for streaming the generated result directly to the response output stream while processing.

The userObj Object is passed to all called user methods. By using this, the initiating class can pass customized data to its methods.

Parameters:
tag - Key for the datablocks hashtable.
callingObject - Object that should be used to look up user methods.
userObj - any object that should be passed to user methods
stream - OutputStream that may be used for directly streaming the results or null.
Returns:
Processed datablock for the given key.
Throws:
CmsException

getTagValue

protected String getTagValue(Element n)
Reads all text or CDATA values from the given XML element, e.g. <ELEMENT>foo blah <![CDATA[<H1>Hello</H1>]]></ELEMENT>.

Parameters:
n - Element that should be read out.
Returns:
Concatenated string of all text and CDATA nodes or null if no nodes were found.

getXmlDocument

protected Document getXmlDocument()
Gets the XML parsed content of this template file as a DOM document.

WARNING: The returned value is the original DOM document, not a clone. Any changes will take effect to the behaviour of this class. Especially datablocks are concerned by this!

Returns:
the content of this template file.

getXmlDocumentTagName

public abstract String getXmlDocumentTagName()
This method should be implemented by every extending class. It returns the name of the XML document tag to scan for.

Returns:
name of the XML document tag.

getXmlParser

public static I_CmsXmlParser getXmlParser()
Gets the currently used XML Parser.

Returns:
currently used parser.

getXmlText

public String getXmlText()
Prints the XML parsed content to a String

Specified by:
getXmlText in interface I_CmsXmlContent
Returns:
String with XML content

getXmlText

public void getXmlText(Writer out)
Prints the XML parsed content of this template file to the given Writer.

Specified by:
getXmlText in interface I_CmsXmlContent
Parameters:
out - Writer to print to.

getXmlText

public void getXmlText(Writer out,
                       Node n)
Prints the XML parsed content of the given Node and its subnodes to the given Writer.

Specified by:
getXmlText in interface I_CmsXmlContent
Parameters:
out - Writer to print to.
n - Node that should be printed.

getXmlText

public void getXmlText(OutputStream out)

getXmlText

public void getXmlText(OutputStream out,
                       Node n)

getXmlText

public String getXmlText(Node n)
Prints the XML parsed content of a given node and its subnodes to a String

Specified by:
getXmlText in interface I_CmsXmlContent
Parameters:
n - Node that should be printed.
Returns:
String with XML content

callAllUncalledMethodsSoThatEclipseDoesntComplainAboutThem

protected void callAllUncalledMethodsSoThatEclipseDoesntComplainAboutThem()
                                                                   throws CmsException
This method is just a hack so that the Eclise IDE will not show the methods listed here as warnings when the "unused private methods" option is selected, since they are called only using reclection API. Do not use this method.

Throws:
CmsException

hasData

protected boolean hasData(String key)
Checks if this Template owns a datablock with the given key.

Parameters:
key - Datablock key to be checked.
Returns:
true if a datablock is found, false otherwise.

init

public void init(CmsObject cms,
                 CmsFile file)
          throws CmsException
Initialize the XML content class. Load and parse the content of the given CmsFile object.

Specified by:
init in interface I_CmsXmlContent
Parameters:
cms - CmsObject Object for accessing resources.
file - CmsFile object of the file to be loaded and parsed.
Throws:
CmsException

init

public void init(CmsObject cms,
                 String filename)
          throws CmsException
Initialize the XML content class. Load and parse the content of the given CmsFile object.

If a previously cached parsed content exists, it will be re-used.

If no absolute file name ist given, template files will be searched a hierachical order using lookupAbsoluteFilename.

Specified by:
init in interface I_CmsXmlContent
Parameters:
cms - CmsObject Object for accessing resources.
filename - Filename of the file to be loaded.
Throws:
CmsException

init

public void init(CmsObject cms,
                 Document content,
                 String filename)
          throws CmsException
Initialize the class with the given parsed XML DOM document.

Specified by:
init in interface I_CmsXmlContent
Parameters:
cms - CmsObject Object for accessing system resources.
filename - OpenCms filename of the XML file.
Throws:
CmsException

parse

protected Document parse(byte[] content)
                  throws CmsException
CmsException

parse

protected Document parse(InputStream content)
                  throws CmsException
Starts the XML parser with the content of the given CmsFile object. After parsing the document it is scanned for INCLUDE and DATA tags by calling processNode with m_firstRunParameters.

Parameters:
content - String to be parsed
Returns:
Parsed DOM document.
CmsException
See Also:
processNode(org.w3c.dom.Node, java.util.Hashtable, java.lang.reflect.Method, java.lang.Object, java.lang.Object), #firstRunParameters

processDocument

protected void processDocument(Hashtable keys,
                               Method defaultMethod,
                               Object callingObject,
                               Object userObj)
                        throws CmsException
Main processing funtion for the whole XML document.

Parameters:
keys - Hashtable with XML tags to look for and corresponding methods.
defaultMethod - Method to be called if the tag is unknown.
callingObject - Reference to the object requesting the node processing.
userObj - Customizable user object that will be passed through to handling and user methods.
Throws:
CmsException
See Also:
processNode(org.w3c.dom.Node, java.util.Hashtable, java.lang.reflect.Method, java.lang.Object, java.lang.Object)

processNode

protected void processNode(Node n,
                           Hashtable keys,
                           Method defaultMethod,
                           Object callingObject,
                           Object userObj)
                    throws CmsException
Universal main processing function for parsed XML templates. The given node is processed by a tree walk.

Every XML tag will be looked up in the Hashtable "keys". If a corresponding entry is found, the tag will be handled by the corresponding function returned from the Hashtable.

If an unknown tag is detected the method defaultMethod is called instead. Is defaultMethod == null nothing will be done with unknown tags.

The invoked handling methods are allowed to return null or objects of the type String, Node, Integer or byte[]. If the return value is null, nothing happens. In all other cases the handled node in the tree will be replaced by a new node. The value of this new node depends on the type of the returned value.

Parameters:
n - Node with its subnodes to process
keys - Hashtable with XML tags to look for and corresponding methods.
defaultMethod - Method to be called if the tag is unknown.
callingObject - Reference to the Object that requested the node processing.
userObj - Customizable user object that will be passed to handling and user methods.
Throws:
CmsException

processNode

protected void processNode(Node n,
                           Hashtable keys,
                           Method defaultMethod,
                           Object callingObject,
                           Object userObj,
                           OutputStream stream)
                    throws CmsException
CmsException

readIncludeFile

public void readIncludeFile(A_CmsXmlContent include)
                     throws CmsException
Read the datablocks of the given content file and include them into the own Hashtable of datablocks.

Parameters:
include - completely initialized A_CmsXmlObject to be included
Throws:
CmsExeption
CmsException

readIncludeFile

public A_CmsXmlContent readIncludeFile(String filename)
                                throws CmsException
Parses the given file and stores it in the internal list of included files and appends the relevant data structures of the new file to its own structures.

Specified by:
readIncludeFile in interface I_CmsXmlContent
Throws:
CmsException

registerTag

public void registerTag(String tagname)
Registers the given tag to be "known" by the system. So this tag will not be handled by the default method of processNode. Under normal circumstances this feature will only be used for the XML document tag.

Parameters:
tagname - Tag name to register.

registerTag

public void registerTag(String tagname,
                        Class c,
                        String methodName,
                        int runSelector)
Registeres a tagname together with a corresponding method for processing with processNode. Tags can be registered for two different runs of the processNode method. This can be selected by the runSelector.

C_REGISTER_FIRST_RUN registeres the given tag for the first run of processNode, just after parsing a XML document. The basic functionality of this class uses this run to scan for INCLUDE and DATA tags.

C_REGISTER_MAIN_RUN registeres the given tag for the main run of processNode. This will be initiated by getProcessedData(), processDocument() or any PROCESS tag.

Parameters:
tagname - Tag name to register.
c - Class containing the handling method.
methodName - Name of the method that should handle a occurance of tag "tagname".
runSelector - see description above.

removeData

protected void removeData(String tag)
Remove a datablock from the internal hashtable and from the XML document

Parameters:
tag - Key of the datablock to delete.

removeFromFileCache

public void removeFromFileCache()
Deletes this object from the internal XML file cache


setData

protected void setData(String tag,
                       String data)
Creates a datablock consisting of a single TextNode containing data and stores this block into the datablock-hashtable.

Parameters:
tag - Key for this datablock.
data - String to be put in the datablock.

setData

protected void setData(String tag,
                       Element data)
Stores a given datablock element in the datablock hashtable.

Parameters:
tag - Key for this datablock.
data - DOM element node for this datablock.

setParsedData

public void setParsedData(String tag,
                          String data)
                   throws CmsException
Creates a datablock element by parsing the data string and stores this block into the datablock-hashtable.

Parameters:
tag - Key for this datablock.
data - String to be put in the datablock.
CmsException

throwException

protected void throwException(String errorMessage)
                       throws CmsException
Help method that handles any occuring exception by writing an error message to the OpenCms logfile and throwing a CmsException of the type "unknown".

Parameters:
errorMessage - String with the error message to be printed.
Throws:
CmsException

throwException

protected void throwException(String errorMessage,
                              int type)
                       throws CmsException
Help method that handles any occuring exception by writing an error message to the OpenCms logfile and throwing a CmsException of the given type.

Parameters:
errorMessage - String with the error message to be printed.
type - Type of the exception to be thrown.
Throws:
CmsException

throwException

protected void throwException(String errorMessage,
                              Exception e)
                       throws CmsException
Help method that handles any occuring exception by writing an error message to the OpenCms logfile and throwing a CmsException of the type "unknown".

Parameters:
errorMessage - String with the error message to be printed.
e - Original exception.
Throws:
CmsException

throwException

protected void throwException(String errorMessage,
                              Exception e,
                              int type)
                       throws CmsException
Help method that handles any occuring exception by writing an error message to the OpenCms logfile and throwing a CmsException of the type "unknown".

Parameters:
errorMessage - String with the error message to be printed.
e - Original exception.
type - Type of the exception to be thrown.
Throws:
CmsException

toString

public String toString()
Gets a string representation of this object.

Overrides:
toString in class Object
Returns:
String representation of this object.

treeWalker

protected Node treeWalker(Node root,
                          Node n)
Help method to walk through the DOM document tree. First it will be looked for children of the given node. If there are no children, the siblings and the siblings of our parents are examined. This will be done by calling treeWalkerWidth.

Parameters:
n - Node representing the actual position in the tree
Returns:
next node

treeWalkerWidth

protected Node treeWalkerWidth(Node root,
                               Node n)
Help method to walk through the DOM document tree by a width-first-order.

Parameters:
n - Node representing the actual position in the tree
Returns:
next node

write

public void write()
           throws CmsException
Writes the XML document back to the OpenCms system.

Specified by:
write in interface I_CmsXmlContent
Throws:
CmsException

getEncoding

public String getEncoding()
Returns current XML document encoding.

Returns:
String encoding of XML document

setEncoding

public void setEncoding(String encoding)
Sets new encoding for XML document.

Parameters:
encoding -