org.opencms.jsp.parse
Class A_CmsConfiguredHtmlParser

java.lang.Object
  extended byorg.opencms.jsp.parse.A_CmsConfiguredHtmlParser

public abstract class A_CmsConfiguredHtmlParser
extends java.lang.Object

Base class for all classes that are specified for the <cms:parse parserClass="name" param="config" /> tag in the parserClass Attribute.

Entry point for the tag implementation (CmsJspTagParse). It will provide a valid CmsObject and it's configuration parameter String to an internal (and unknown) I_CmsHtmlNodeVisitor implementation along with the entry point doParse(String, String) for parsing.

Since:
6.1.7
Version:
$Revision: 1.2 $
Author:
Achim Westermann

Constructor Summary
protected A_CmsConfiguredHtmlParser()
          Default constructor that initializes the internal visitor by using the abstract template method createVisitorInstance().
 
Method Summary
protected abstract  I_CmsHtmlNodeVisitor createVisitorInstance()
          Subclasses have to create their desired instance for parsing the html here.
 java.lang.String doParse(java.lang.String html, java.lang.String encoding)
          Returns the result of subsequent parsing to the <cms:parse< tag implementation.
protected  CmsObject getCmsObject()
          Returns the internal cms object for accessing core functionality.
protected  java.lang.String getParam()
          Returns the param.
protected  I_CmsHtmlNodeVisitor getVisitor()
          Returns the visitor.
 void setCmsObject(CmsObject cmsObject)
          Sets the internal cms object for accessing core functionality.
 void setParam(java.lang.String param)
          The attribute value of the attribute param of the <cms:parse> tag.
protected  void setVisitor(I_CmsHtmlNodeVisitor visitor)
          Sets the visitor.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

A_CmsConfiguredHtmlParser

protected A_CmsConfiguredHtmlParser()
Default constructor that initializes the internal visitor by using the abstract template method createVisitorInstance().

Method Detail

doParse

public java.lang.String doParse(java.lang.String html,
                                java.lang.String encoding)
                         throws org.htmlparser.util.ParserException,
                                CmsException
Returns the result of subsequent parsing to the <cms:parse< tag implementation.

setVisitor(I_CmsHtmlNodeVisitor) has to be invoked with a non null value before this method or it will always fail to parse.

Override this method to perform further configurations. Keep the exception contract in mind to avoid serving ugly HTML pages to potential clients.

Parameters:
encoding - the encoding to use for parsing.
html - the html content to parse.
Returns:
the result of subsequent parsing to the <cms:parse< tag implementation.
Throws:
org.htmlparser.util.ParserException - if sth. goes wrong at parsing.
CmsException - if sth. goes wrong at accessing OpenCms core functionality.

setCmsObject

public void setCmsObject(CmsObject cmsObject)
Sets the internal cms object for accessing core functionality.

This will be invokde by the &tl;cms:parse> tag implementation.

Parameters:
cmsObject - the internal cms object for accessing core functionality to set.

setParam

public void setParam(java.lang.String param)
The attribute value of the attribute param of the <cms:parse> tag.

Will be set by the <cms:parse> implementation.

Parameters:
param - the param to set.

createVisitorInstance

protected abstract I_CmsHtmlNodeVisitor createVisitorInstance()
Subclasses have to create their desired instance for parsing the html here.

Returns:
the instance to be used for parsing the html.

getCmsObject

protected CmsObject getCmsObject()
Returns the internal cms object for accessing core functionality.

This value will be initialized by the <cms:parse> tag.

Returns:
the internal cms object for accessing core functionality.

getParam

protected java.lang.String getParam()
Returns the param.

Returns:
the param

getVisitor

protected I_CmsHtmlNodeVisitor getVisitor()
Returns the visitor.

Returns:
the visitor

setVisitor

protected void setVisitor(I_CmsHtmlNodeVisitor visitor)
Sets the visitor.

This has to be done from the constructor of subclasses!

Parameters:
visitor - the visitor to set