mx4j.tools.adaptor.http
Class XSLTProcessor

java.lang.Object
  extended bymx4j.tools.adaptor.http.XSLTProcessor
All Implemented Interfaces:
ProcessorMBean, javax.xml.transform.URIResolver, XSLTProcessorMBean

public class XSLTProcessor
extends java.lang.Object
implements ProcessorMBean, XSLTProcessorMBean, javax.xml.transform.URIResolver

XSLTPostProcessor pass the document through an XSLT transformation

Version:
$Revision: 1.8 $

Constructor Summary
XSLTProcessor()
           
 
Method Summary
 void addMimeType(java.lang.String extension, java.lang.String type)
          Maps a given extension with a specified MIME type
protected  javax.xml.transform.Transformer createTransformer(java.lang.String path)
           
 java.lang.String getDefaultPage()
          Returns the default start page
 java.lang.String getFile()
          Returns the jar/zip file or the directory where XSL files are loaded
protected  java.io.InputStream getInputStream(java.lang.String path)
           
 java.util.Locale getLocale()
          Returns the Locale used to internationalize the output
 java.lang.String getName()
           
 java.lang.String getPathInJar()
          Returns the path of the XSL templates inside a jar file.
 boolean isUseCache()
          Returns if the XSL Templates are cached
 boolean isUseJar()
          Returns if the XSL files are contained in a jar/zip file.
 boolean isUsePath()
          Returns if the XSL files are contained in a path.
 java.lang.String notFoundElement(java.lang.String path, HttpOutputStream out, HttpInputStream in)
          Let the processor load internally a not found element.
 java.lang.String preProcess(java.lang.String path)
          Preprocess a path and return a replacement path.
protected  void processHttpException(HttpInputStream in, HttpOutputStream out, HttpException e)
           
 javax.xml.transform.Source resolve(java.lang.String href, java.lang.String base)
           
 void setDefaultPage(java.lang.String defaultPage)
          Sets the default start page, serverbydomain as a default
 void setFile(java.lang.String file)
          Sets the jar/zip file or the directory where to find the XSL files
 void setLocale(java.util.Locale locale)
          Sets the locale used to internationalize the output
 void setLocaleString(java.lang.String locale)
          Sets the locale used to internationalize the output, as a string
 void setPathInJar(java.lang.String path)
          Specifies the path of the XSL templates inside a jar file.
 void setUseCache(boolean useCache)
          Sets the caching of the XSL Templates.
 void writeError(HttpOutputStream out, HttpInputStream in, java.lang.Exception e)
          The method will process the result exception and produce output.
 void writeResponse(HttpOutputStream out, HttpInputStream in, org.w3c.dom.Document document)
          The method will process the result string and produce an output.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XSLTProcessor

public XSLTProcessor()
Method Detail

writeResponse

public void writeResponse(HttpOutputStream out,
                          HttpInputStream in,
                          org.w3c.dom.Document document)
                   throws java.io.IOException
Description copied from interface: ProcessorMBean
The method will process the result string and produce an output. The implementor is also responsible to set the mime type, response code and send the headers before answering as follow: out.setCode(HttpConstants.STATUS_OKAY); out.setHeader("Content-type", "text/html"); out.sendHeaders(); out.write("some text");

Specified by:
writeResponse in interface ProcessorMBean
Parameters:
out - The output stream
in - The input stream
document - A document containing the data
Throws:
java.io.IOException

createTransformer

protected javax.xml.transform.Transformer createTransformer(java.lang.String path)

processHttpException

protected void processHttpException(HttpInputStream in,
                                    HttpOutputStream out,
                                    HttpException e)
                             throws java.io.IOException
Throws:
java.io.IOException

writeError

public void writeError(HttpOutputStream out,
                       HttpInputStream in,
                       java.lang.Exception e)
                throws java.io.IOException
Description copied from interface: ProcessorMBean
The method will process the result exception and produce output. The implementor is also responsible to set the mime type, response code and send the headers before answering as follow: out.setCode(HttpConstants.STATUS_OKAY); out.setHeader("Content-type", "text/html"); out.sendHeaders(); out.write("some text");

Specified by:
writeError in interface ProcessorMBean
Parameters:
out - The output stream
in - The input stream
e - The exception to be reported
Throws:
java.io.IOException

preProcess

public java.lang.String preProcess(java.lang.String path)
Description copied from interface: ProcessorMBean
Preprocess a path and return a replacement path. For instance the / path could be replaced by the server path

Specified by:
preProcess in interface ProcessorMBean
Parameters:
path - The original path
Returns:
the replacement path. If not modification the path param should be returned

notFoundElement

public java.lang.String notFoundElement(java.lang.String path,
                                        HttpOutputStream out,
                                        HttpInputStream in)
                                 throws java.io.IOException,
                                        HttpException
Description copied from interface: ProcessorMBean
Let the processor load internally a not found element. This can be used to load images, stylesheets and so on. If return is not null, the path is processed

Specified by:
notFoundElement in interface ProcessorMBean
Parameters:
path - The request element
out - The output stream
in - The input stream
Throws:
java.io.IOException
HttpException

getInputStream

protected java.io.InputStream getInputStream(java.lang.String path)

resolve

public javax.xml.transform.Source resolve(java.lang.String href,
                                          java.lang.String base)
Specified by:
resolve in interface javax.xml.transform.URIResolver

setFile

public void setFile(java.lang.String file)
Description copied from interface: XSLTProcessorMBean
Sets the jar/zip file or the directory where to find the XSL files

Specified by:
setFile in interface XSLTProcessorMBean
See Also:
XSLTProcessorMBean.getFile()

getFile

public java.lang.String getFile()
Description copied from interface: XSLTProcessorMBean
Returns the jar/zip file or the directory where XSL files are loaded

Specified by:
getFile in interface XSLTProcessorMBean
See Also:
XSLTProcessorMBean.setFile(java.lang.String)

getPathInJar

public java.lang.String getPathInJar()
Description copied from interface: XSLTProcessorMBean
Returns the path of the XSL templates inside a jar file.

Specified by:
getPathInJar in interface XSLTProcessorMBean
See Also:
XSLTProcessorMBean.setPathInJar(java.lang.String)

setPathInJar

public void setPathInJar(java.lang.String path)
Description copied from interface: XSLTProcessorMBean
Specifies the path of the XSL templates inside a jar file.

Specified by:
setPathInJar in interface XSLTProcessorMBean
See Also:
XSLTProcessorMBean.getPathInJar()

getDefaultPage

public java.lang.String getDefaultPage()
Description copied from interface: XSLTProcessorMBean
Returns the default start page

Specified by:
getDefaultPage in interface XSLTProcessorMBean
See Also:
XSLTProcessorMBean.setDefaultPage(java.lang.String)

setDefaultPage

public void setDefaultPage(java.lang.String defaultPage)
Description copied from interface: XSLTProcessorMBean
Sets the default start page, serverbydomain as a default

Specified by:
setDefaultPage in interface XSLTProcessorMBean
See Also:
XSLTProcessorMBean.getDefaultPage()

isUseJar

public boolean isUseJar()
Description copied from interface: XSLTProcessorMBean
Returns if the XSL files are contained in a jar/zip file.

Specified by:
isUseJar in interface XSLTProcessorMBean
See Also:
XSLTProcessorMBean.isUsePath(), XSLTProcessorMBean.setFile(java.lang.String)

isUsePath

public boolean isUsePath()
Description copied from interface: XSLTProcessorMBean
Returns if the XSL files are contained in a path.

Specified by:
isUsePath in interface XSLTProcessorMBean
See Also:
XSLTProcessorMBean.isUseJar(), XSLTProcessorMBean.setFile(java.lang.String)

addMimeType

public void addMimeType(java.lang.String extension,
                        java.lang.String type)
Description copied from interface: XSLTProcessorMBean
Maps a given extension with a specified MIME type

Specified by:
addMimeType in interface XSLTProcessorMBean

setUseCache

public void setUseCache(boolean useCache)
Description copied from interface: XSLTProcessorMBean
Sets the caching of the XSL Templates.

Specified by:
setUseCache in interface XSLTProcessorMBean

isUseCache

public boolean isUseCache()
Description copied from interface: XSLTProcessorMBean
Returns if the XSL Templates are cached

Specified by:
isUseCache in interface XSLTProcessorMBean

getName

public java.lang.String getName()
Specified by:
getName in interface ProcessorMBean

getLocale

public java.util.Locale getLocale()
Description copied from interface: XSLTProcessorMBean
Returns the Locale used to internationalize the output

Specified by:
getLocale in interface XSLTProcessorMBean

setLocale

public void setLocale(java.util.Locale locale)
Description copied from interface: XSLTProcessorMBean
Sets the locale used to internationalize the output

Specified by:
setLocale in interface XSLTProcessorMBean

setLocaleString

public void setLocaleString(java.lang.String locale)
Description copied from interface: XSLTProcessorMBean
Sets the locale used to internationalize the output, as a string

Specified by:
setLocaleString in interface XSLTProcessorMBean


Copyright © 2001-2005 The MX4J Contributors. All Rights Reserved.