com.opencms.htmlconverter
Class CmsHtmlConverter

java.lang.Object
  |
  +--com.opencms.htmlconverter.CmsHtmlConverter
All Implemented Interfaces:
I_CmsHtmlConverterInterface

public final class CmsHtmlConverter
extends Object
implements I_CmsHtmlConverterInterface

Implementation of interface I_CmsHtmlConverterInterface: Tool to check and transform HTML input code to user-defined output, for example JSP, JavaScript or other syntax.

Version:
1.0
Author:
Andreas Zahner

Constructor Summary
CmsHtmlConverter()
          default constructor
CmsHtmlConverter(String tidyConfFileName)
          constructor with name of Tidy configuration file as parameter
CmsHtmlConverter(String tidyConfFileName, String confFile)
          constructor with name of Tidy and Converter configuration files as parameters
 
Method Summary
 boolean converterConfigured()
          Checks whether CmsHtmlConverter is already configured or not
 void convertHTML(Reader input, Writer output)
          Transforms HTML code into user defined output
 String convertHTML(String inString)
          Transforms HTML code into user defined output
 String getConverterConfFile()
          If defined, returns filename of CmsHtmlConverter configuration file
 int getNumberErrors()
          returns number of found errors in last parsed html code
 String getTidyConfFile()
          If defined, returns JTidy configuration filename
 boolean hasErrors(InputStream input)
          Checks if HTML code has errors
 boolean hasErrors(String inString)
          Checks if HTML code has errors
 void setConverterConfFile(String confFile)
          Configures CmsHtmlConverter from file
 void setConverterConfString(String configuration)
          Configures CmsHtmlConverter from string
 void setOriginalUrl(URL orgUrl)
          sets the url.
 void setServletPrefix(String prefix, String relativeRoot)
          sets the prefix.
 void setTidyConfFile(String fileName)
          Configures JTidy from file
 void showErrors(InputStream input, OutputStream output)
          Checks if HTML code has errors and lists errors
 String showErrors(String inString)
          Checks if HTML code has errors and lists errors
 boolean tidyConfigured()
          Checks whether JTidy is already configured or not
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CmsHtmlConverter

public CmsHtmlConverter()
default constructor


CmsHtmlConverter

public CmsHtmlConverter(String tidyConfFileName)
constructor with name of Tidy configuration file as parameter

Parameters:
tidyConfFileName - String with Tidy configuration file name

CmsHtmlConverter

public CmsHtmlConverter(String tidyConfFileName,
                        String confFile)
constructor with name of Tidy and Converter configuration files as parameters

Parameters:
tidyConfFileName - String with Tidy configuration file name
confFile - String with Converter configuration file name
Method Detail

setServletPrefix

public void setServletPrefix(String prefix,
                             String relativeRoot)
sets the prefix.

Parameters:
prefix - The servletprefix.

setOriginalUrl

public void setOriginalUrl(URL orgUrl)
sets the url.


setTidyConfFile

public void setTidyConfFile(String fileName)
Configures JTidy from file

Specified by:
setTidyConfFile in interface I_CmsHtmlConverterInterface
Parameters:
fileName - filename of JTidy configuration file

getTidyConfFile

public String getTidyConfFile()
If defined, returns JTidy configuration filename

Specified by:
getTidyConfFile in interface I_CmsHtmlConverterInterface
Returns:
filename of JTidy configuration file

tidyConfigured

public boolean tidyConfigured()
Checks whether JTidy is already configured or not

Specified by:
tidyConfigured in interface I_CmsHtmlConverterInterface
Returns:
true if JTidy configuration file is set, otherwise false

setConverterConfFile

public void setConverterConfFile(String confFile)
Configures CmsHtmlConverter from file

Specified by:
setConverterConfFile in interface I_CmsHtmlConverterInterface
Parameters:
confFile - filename of configuration file

setConverterConfString

public void setConverterConfString(String configuration)
Configures CmsHtmlConverter from string

Specified by:
setConverterConfString in interface I_CmsHtmlConverterInterface
Parameters:
configuration - string with CmsHtmlConverter configuration

getConverterConfFile

public String getConverterConfFile()
If defined, returns filename of CmsHtmlConverter configuration file

Specified by:
getConverterConfFile in interface I_CmsHtmlConverterInterface
Returns:
filename of configuration file

converterConfigured

public boolean converterConfigured()
Checks whether CmsHtmlConverter is already configured or not

Specified by:
converterConfigured in interface I_CmsHtmlConverterInterface
Returns:
true if CmsHtmlConverter configuration is set, otherwise false

hasErrors

public boolean hasErrors(String inString)
Checks if HTML code has errors

Specified by:
hasErrors in interface I_CmsHtmlConverterInterface
Parameters:
inString - String with HTML code
Returns:
true if errors were detected, otherwise false

hasErrors

public boolean hasErrors(InputStream input)
Checks if HTML code has errors

Specified by:
hasErrors in interface I_CmsHtmlConverterInterface
Returns:
true if errors were detected, otherwise false

getNumberErrors

public int getNumberErrors()
returns number of found errors in last parsed html code

Specified by:
getNumberErrors in interface I_CmsHtmlConverterInterface
Returns:
int with number of errors

showErrors

public String showErrors(String inString)
Checks if HTML code has errors and lists errors

Specified by:
showErrors in interface I_CmsHtmlConverterInterface
Parameters:
inString - String with HTML code
Returns:
String with detected errors

showErrors

public void showErrors(InputStream input,
                       OutputStream output)
Checks if HTML code has errors and lists errors

Specified by:
showErrors in interface I_CmsHtmlConverterInterface
Parameters:
input - InputStream with HTML code
output - OutputStream with detected errors

convertHTML

public String convertHTML(String inString)
Transforms HTML code into user defined output

Specified by:
convertHTML in interface I_CmsHtmlConverterInterface
Parameters:
inString - String with HTML code
Returns:
String with transformed code

convertHTML

public void convertHTML(Reader input,
                        Writer output)
Transforms HTML code into user defined output

Specified by:
convertHTML in interface I_CmsHtmlConverterInterface
Parameters:
input - Reader with HTML code
output - Writer with transformed code