|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnu.staldal.lsp.LSPHelper
public class LSPHelper
Helper class for loading and executing an LSP pages and serialize the output to a byte stream.
This class should generally be considered as Singleton, usually only
one instance is required. An instance of this class is thread-safe,
except for the setXXX
methods which should not be
invoked concurrently with any other method.
Constructor Summary | |
---|---|
LSPHelper(java.lang.ClassLoader classLoader)
Create an LSPHelper. |
Method Summary | |
---|---|
java.lang.String |
executePage(LSPPage thePage,
java.util.Map<java.lang.String,java.lang.Object> lspParams,
java.lang.Object extContext)
Executes an LSP page and serialize the result to a String Uses any stylesheet specified in the LSP page. |
void |
executePage(LSPPage thePage,
java.util.Map<java.lang.String,java.lang.Object> lspParams,
java.lang.Object extContext,
java.io.OutputStream out)
Executes an LSP page and serialize the result to an OutputStream . |
void |
executePage(LSPPage thePage,
java.util.Map<java.lang.String,java.lang.Object> lspParams,
java.lang.Object extContext,
javax.xml.transform.stream.StreamResult out)
Executes an LSP page and serialize the result to an StreamResult . |
java.lang.String |
executePage(LSPPage thePage,
java.util.Map<java.lang.String,java.lang.Object> lspParams,
java.lang.Object extContext,
javax.xml.transform.Templates compiledStylesheet)
Executes an LSP page, transform the the result with an XSLT stylesheet and serialize the result to a String. |
void |
executePage(LSPPage thePage,
java.util.Map<java.lang.String,java.lang.Object> lspParams,
java.lang.Object extContext,
javax.xml.transform.Templates compiledStylesheet,
java.io.OutputStream out)
Executes an LSP page, transform the the result with an XSLT stylesheet and serialize the result to an OutputStream
The output properties specified in the stylesheet will be used,
and those specified in the LSP page will be ignored. |
void |
executePage(LSPPage thePage,
java.util.Map<java.lang.String,java.lang.Object> lspParams,
java.lang.Object extContext,
javax.xml.transform.Templates compiledStylesheet,
javax.xml.transform.stream.StreamResult out)
Executes an LSP page, transform the the result with an XSLT stylesheet and serialize the result to an StreamResult
The output properties specified in the stylesheet will be used,
and those specified in the LSP page will be ignored. |
java.lang.String |
getContentType(LSPPage thePage)
Get Content-Type (Internet Media Type, MIME type) with character encoding as "charset" parameter from an LSP page. |
static java.lang.String |
getContentType(java.util.Properties outputProperties)
Get Content-Type (Internet Media Type, MIME type) with character encoding as "charset" parameter from an JAXP/TrAX OutputProperties object. |
java.lang.String |
getContentType(javax.xml.transform.Templates compiledStylesheet)
Get Content-Type (Internet Media Type, MIME type) with character encoding as "charset" parameter from compiled stylesheet. |
LSPPage |
getPage(java.lang.String pageName)
Get the LSPPage instance for a given page name. |
javax.xml.transform.Templates |
getStylesheet(java.lang.String stylesheetName)
Get an compiled XSLT stylesheet. |
void |
setHtmlEncoding(java.lang.String htmlEncoding)
Set the default character encoding for HTML. |
void |
setHtmlType(java.lang.String htmlType)
Set the default media-type for HTML. |
void |
setTextEncoding(java.lang.String textEncoding)
Set the default character encoding for TEXT. |
void |
setTextType(java.lang.String textType)
Set the default media-type for TEXT. |
void |
setXhtmlEncoding(java.lang.String xhtmlEncoding)
Set the default character encoding for XHTML. |
void |
setXhtmlType(java.lang.String xhtmlType)
Set the default media-type for XHTML. |
void |
setXmlEncoding(java.lang.String xmlEncoding)
Set the default character encoding for XML. |
void |
setXmlType(java.lang.String xmlType)
Set the default media-type for XML. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public LSPHelper(java.lang.ClassLoader classLoader)
classLoader
- ClassLoader
to load LSP pages and stylesheet source withMethod Detail |
---|
public void setHtmlType(java.lang.String htmlType)
Default is "text/html", and this should not be changed.
htmlType
- the default media-type for HTMLpublic void setXhtmlType(java.lang.String xhtmlType)
Default is "text/html", but another reasonable choice is "application/xhtml+xml".
xhtmlType
- the default media-type for XHTMLpublic void setXmlType(java.lang.String xmlType)
Default is "text/xml", but another reasonable choice is "application/xml".
xmlType
- the default media-type for XMLpublic void setTextType(java.lang.String textType)
Default is "text/plain".
textType
- the default media-type for TEXTpublic void setHtmlEncoding(java.lang.String htmlEncoding)
Default is "iso-8859-1".
htmlEncoding
- default character encoding for HTMLpublic void setXhtmlEncoding(java.lang.String xhtmlEncoding)
Default is "UTF-8".
xhtmlEncoding
- default character encoding for XHTMLpublic void setXmlEncoding(java.lang.String xmlEncoding)
Default is "UTF-8".
xmlEncoding
- default character encoding for XMLpublic void setTextEncoding(java.lang.String textEncoding)
Default is "iso-8859-1".
textEncoding
- default character encoding for TEXTpublic javax.xml.transform.Templates getStylesheet(java.lang.String stylesheetName) throws javax.xml.transform.TransformerConfigurationException
The compiled stylesheets are cached and reused. Stylesheet source
is loaded from the supplied ClassLoader
.
stylesheetName
- the name of the XSLT stylesheet
null
if the given stylesheet is not found
javax.xml.transform.TransformerConfigurationException
- if the stylesheet cannot be compiledpublic LSPPage getPage(java.lang.String pageName) throws java.lang.InstantiationException, java.lang.IllegalAccessException, java.lang.VerifyError
LSPPage
instance for a given page name.
LSPPage
instances are cached and reused.
pageName
- the name of the LSP page
null
if the given page is not found
java.lang.InstantiationException
- if the LSP page cannot be loaded
java.lang.IllegalAccessException
- if the LSP page cannot be loaded
java.lang.VerifyError
- if the LSP page is damagedpublic java.lang.String getContentType(LSPPage thePage)
thePage
- the LSP page.
public java.lang.String getContentType(javax.xml.transform.Templates compiledStylesheet)
compiledStylesheet
- the compiled stylesheet
public static java.lang.String getContentType(java.util.Properties outputProperties)
outputProperties
- JAXP/TrAX OutputProperties object.
OutputKeys
public void executePage(LSPPage thePage, java.util.Map<java.lang.String,java.lang.Object> lspParams, java.lang.Object extContext, javax.xml.transform.stream.StreamResult out) throws java.io.FileNotFoundException, org.xml.sax.SAXException, java.io.IOException
StreamResult
.
Uses any stylesheet specified in the LSP page.
thePage
- the LSP pagelspParams
- parameters to the LSP pageextContext
- external context which will be passed to ExtLibsout
- the StreamResult
java.io.FileNotFoundException
- if the stylesheet cannot be found
org.xml.sax.SAXException
- if any error occurs while executing the page
java.io.IOException
- if any I/O error occurs while executing the pagepublic void executePage(LSPPage thePage, java.util.Map<java.lang.String,java.lang.Object> lspParams, java.lang.Object extContext, java.io.OutputStream out) throws java.io.FileNotFoundException, org.xml.sax.SAXException, java.io.IOException
OutputStream
. Uses any stylesheet specified in the
LSP page.
thePage
- the LSP pagelspParams
- parameters to the LSP pageextContext
- external context which will be passed to ExtLibsout
- the OutputStream
java.io.FileNotFoundException
- if the stylesheet cannot be found
org.xml.sax.SAXException
- if any error occurs while executing the page
java.io.IOException
- if any I/O error occurs while executing the pagepublic java.lang.String executePage(LSPPage thePage, java.util.Map<java.lang.String,java.lang.Object> lspParams, java.lang.Object extContext) throws java.io.FileNotFoundException, org.xml.sax.SAXException, java.io.IOException
thePage
- the LSP pagelspParams
- parameters to the LSP pageextContext
- external context which will be passed to ExtLibs
java.io.FileNotFoundException
- if the stylesheet cannot be found
org.xml.sax.SAXException
- if any error occurs while executing the page
java.io.IOException
- if any I/O error occurs while executing the pagepublic void executePage(LSPPage thePage, java.util.Map<java.lang.String,java.lang.Object> lspParams, java.lang.Object extContext, javax.xml.transform.Templates compiledStylesheet, javax.xml.transform.stream.StreamResult out) throws org.xml.sax.SAXException, java.io.IOException
StreamResult
The output properties specified in the stylesheet will be used, and those specified in the LSP page will be ignored. Also, the default output properties specified in this class will be ignored. Make sure to specify the output method in the stylesheet using <xsl:output>.
thePage
- the LSP pagelspParams
- parameters to the LSP pageextContext
- external context which will be passed to ExtLibscompiledStylesheet
- the compiled XSLT stylesheetout
- the StreamResult
org.xml.sax.SAXException
- if any error occurs while executing the page
java.io.IOException
- if any I/O error occurs while executing the pagepublic void executePage(LSPPage thePage, java.util.Map<java.lang.String,java.lang.Object> lspParams, java.lang.Object extContext, javax.xml.transform.Templates compiledStylesheet, java.io.OutputStream out) throws org.xml.sax.SAXException, java.io.IOException
OutputStream
The output properties specified in the stylesheet will be used, and those specified in the LSP page will be ignored. Also, the default output properties specified in this class will be ignored. Make sure to specify the output method in the stylesheet using <xsl:output>.
thePage
- the LSP pagelspParams
- parameters to the LSP pageextContext
- external context which will be passed to ExtLibscompiledStylesheet
- the compiled XSLT stylesheetout
- the OutputStream
org.xml.sax.SAXException
- if any error occurs while executing the page
java.io.IOException
- if any I/O error occurs while executing the pagepublic java.lang.String executePage(LSPPage thePage, java.util.Map<java.lang.String,java.lang.Object> lspParams, java.lang.Object extContext, javax.xml.transform.Templates compiledStylesheet) throws org.xml.sax.SAXException, java.io.IOException
The output properties specified in the stylesheet will be used, and those specified in the LSP page will be ignored. Also, the default output properties specified in this class will be ignored. Make sure to specify the output method in the stylesheet using <xsl:output>.
thePage
- the LSP pagelspParams
- parameters to the LSP pageextContext
- external context which will be passed to ExtLibscompiledStylesheet
- the compiled XSLT stylesheet
org.xml.sax.SAXException
- if any error occurs while executing the page
java.io.IOException
- if any I/O error occurs while executing the page
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |