mls.view
Class Viewer

java.lang.Object
  |
  +--mls.common.XmlObject
        |
        +--mls.view.Viewer
Direct Known Subclasses:
HtmlViewer, WmlViewer

public abstract class Viewer
extends XmlObject

An XML/XSLT based viewer that processes XML data and XSL page templates to generate markup This class could be optimized by caching stylesheet templates as DOM documents


Field Summary
static java.lang.String CACHE
           
private static java.lang.String ERROR
           
static java.lang.String NO_CACHE
           
protected  java.lang.String TEMPLATE_DIR
           
protected static java.lang.String XML_PROLOGUE
           
 
Fields inherited from class mls.common.XmlObject
INDENT
 
Constructor Summary
Viewer()
           
 
Method Summary
private  void merge(org.w3c.dom.Document xml, org.w3c.dom.Document xsl, java.io.PrintWriter out)
          Generate XML from the specified XML data and XSL stylesheet
private  void merge(java.lang.Object data, java.lang.String xsl, java.io.PrintWriter out)
          Generate XML from the specified data and XSL stylesheet
private  void merge(java.lang.String xml, java.lang.String xsl, java.io.PrintWriter out)
          Generate XML from the specified xml data and XSL stylesheet
(package private) abstract  void printPrologue(java.io.PrintWriter out)
          Print a document prologue - Implemented by child class
protected  void setCache(java.lang.String cachePage, javax.servlet.http.HttpServletResponse response)
          Set general cache headers based on cachePage flag
(package private) abstract  void setType(javax.servlet.http.HttpServletResponse response)
          Sets the output type in the reponse for this type of viewer Implemented by child class
 void viewError(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.String error)
          Display an error page containing the specified error message Calls the more general viewError method
 void viewError(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.String error, java.lang.Throwable throwable)
          Display an error page containing the specified error message and error (throwable) information
(package private) abstract  void viewFixed(javax.servlet.http.HttpServletResponse response, java.lang.String textToDisplay)
          View a canned page - Implemented by child class
 void viewPage(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.String templateName, java.lang.Object object, java.lang.String cachePage)
          Display the specified page containing the specified object
 void viewPage(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.String templateName, java.lang.String className, java.lang.String cachePage)
          Display the specified page containing a blank object of the specified class.
 
Methods inherited from class mls.common.XmlObject
dump, dumpElement, getChildren, getChildren, getElement, getElement, getElement, getElementText, getParser, indent, narrow, nElements, parse, parseString
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

NO_CACHE

public static final java.lang.String NO_CACHE

CACHE

public static final java.lang.String CACHE

TEMPLATE_DIR

protected java.lang.String TEMPLATE_DIR

ERROR

private static final java.lang.String ERROR

XML_PROLOGUE

protected static final java.lang.String XML_PROLOGUE
Constructor Detail

Viewer

public Viewer()
Method Detail

viewPage

public void viewPage(javax.servlet.http.HttpServletRequest request,
                     javax.servlet.http.HttpServletResponse response,
                     java.lang.String templateName,
                     java.lang.String className,
                     java.lang.String cachePage)
              throws java.lang.Exception
Display the specified page containing a blank object of the specified class. Calls object-based method
Parameters:
request - the Http request from the user agent
response - where the response is to be written
templateName - the name of the XML template
className - the name of the class to view

viewPage

public void viewPage(javax.servlet.http.HttpServletRequest request,
                     javax.servlet.http.HttpServletResponse response,
                     java.lang.String templateName,
                     java.lang.Object object,
                     java.lang.String cachePage)
              throws java.lang.Exception
Display the specified page containing the specified object
Parameters:
request - the Http request from the user agent
response - where the response is to be written
templateName - the name of the XML template
object - the object to view

viewError

public void viewError(javax.servlet.http.HttpServletRequest request,
                      javax.servlet.http.HttpServletResponse response,
                      java.lang.String error)
               throws java.io.IOException
Display an error page containing the specified error message Calls the more general viewError method
Parameters:
request - the Http request from the user agent
response - where the response is to be written
error - An error message to display

viewError

public void viewError(javax.servlet.http.HttpServletRequest request,
                      javax.servlet.http.HttpServletResponse response,
                      java.lang.String error,
                      java.lang.Throwable throwable)
               throws java.io.IOException
Display an error page containing the specified error message and error (throwable) information
Parameters:
request - the Http request from the user agent
response - where the response is to be written
error - an error message to display
throwable - An error from which additional info will be displayed

setType

abstract void setType(javax.servlet.http.HttpServletResponse response)
Sets the output type in the reponse for this type of viewer Implemented by child class
Parameters:
response - where the response is to be written

setCache

protected void setCache(java.lang.String cachePage,
                        javax.servlet.http.HttpServletResponse response)
Set general cache headers based on cachePage flag
Parameters:
cachePage - A string set to CACHE or NO_CACHE
response - where the response is to be written

printPrologue

abstract void printPrologue(java.io.PrintWriter out)
Print a document prologue - Implemented by child class
Parameters:
out - a print writer for output

viewFixed

abstract void viewFixed(javax.servlet.http.HttpServletResponse response,
                        java.lang.String textToDisplay)
                 throws java.io.IOException
View a canned page - Implemented by child class
Parameters:
response - where the response is to be written
textToDisplay - the text to display

merge

private void merge(java.lang.Object data,
                   java.lang.String xsl,
                   java.io.PrintWriter out)
            throws java.lang.Exception
Generate XML from the specified data and XSL stylesheet
Parameters:
xml - a Java object containing data
xsl - an XSL stylesheet file which will generate appropriate markup
out - an output print writer

merge

private void merge(java.lang.String xml,
                   java.lang.String xsl,
                   java.io.PrintWriter out)
            throws java.lang.Exception
Generate XML from the specified xml data and XSL stylesheet
Parameters:
xml - an XML file containing data as XML
xsl - an XSL stylesheet file which will generate appropriate markup
out - an output print writer

merge

private void merge(org.w3c.dom.Document xml,
                   org.w3c.dom.Document xsl,
                   java.io.PrintWriter out)
            throws java.lang.Exception
Generate XML from the specified XML data and XSL stylesheet
Parameters:
xml - a DOM document containing data as XML
xsl - an XSL stylesheet which will generate appropriate markup
out - an output print writer