com.arsdigita.bebop.page
Class PageTransformer

java.lang.Object
  extended bycom.arsdigita.bebop.page.PageTransformer
All Implemented Interfaces:
PresentationManager
Direct Known Subclasses:
SimplePresentationManager

public class PageTransformer
extends Object
implements PresentationManager

A class for managing and obtaining a Stylesheet based on the current request's location in the site map. First, we try to find a stylesheet specific to this site node. If we can't find one, then we walk up the site map until we find a parent of this site node that has a stylesheet associated with it. If we haven't found one by the time we reach the root, then we'll do the same tree walk except we'll look for the stylesheet associated with the package mounted on each site node.

Version:
$Id: //core-platform/dev/src/com/arsdigita/bebop/page/PageTransformer.java#17 $
Author:
Bill Schneider

Field Summary
static String CACHE_DISABLE
          State flag for disabling HTTP header caching.
static String CACHE_NONE
          State flag for preventing caching in every case.
static String CACHE_USER
          State flag for per-user caching.
static String CACHE_WORLD
          State flag for enabling caching in every case.
static String CACHE_XSL_NONE
          This is used to indicate that all xsl templates used should be pulled from the disk and not from the cache.
static String FANCY_ERRORS
          This is used to indicate that the "fancy errors" should be used and that the errors should be placed in the request for later use.
static String versionId
           
 
Constructor Summary
PageTransformer()
           
 
Method Summary
static void addXSLParameters(javax.xml.transform.Transformer transformer, javax.servlet.http.HttpServletRequest request)
          This takes in a transformer and adds all of the registered xsl paraemters.
static Collection getXSLParameterNames()
          This is a Collection of all names of XSL Parameters that have been registered
static String getXSLParameterValue(String name, javax.servlet.http.HttpServletRequest request)
          This takes a name and request and returns the value that should be used in the XSL for the given name
static void registerXSLParameterGenerator(String parameterName, XSLParameterGenerator parameterGenerator)
          This adds a generator to the list of parameters available to XSLStylesheets.
static void removeXSLParameterGenerator(String parameterName)
          This removes the parameter from the list of parameters that will be added to stylesheets
 void servePage(Document doc, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp)
          Uses servePage(Document, HttpServletRequest, HttpServletResponse, Map) to implement the PresentationManager interface.
 void servePage(Document doc, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp, Map params)
          Serves an XML Document, getting and applying the appropriate XSLT.
static void setDefaultCachePolicy(String policy)
          Sets the default cache behavior for the site.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

versionId

public static final String versionId
See Also:
Constant Field Values

CACHE_XSL_NONE

public static final String CACHE_XSL_NONE
This is used to indicate that all xsl templates used should be pulled from the disk and not from the cache. If this is in the request with a value of Boolean.TRUE then all XSL Stylesheets are pulled from the disk, not the cache

See Also:
Constant Field Values

FANCY_ERRORS

public static final String FANCY_ERRORS
This is used to indicate that the "fancy errors" should be used and that the errors should be placed in the request for later use. To use this, have the code place an attribute with this name in the request with the value of Boolean.TRUE

See Also:
Constant Field Values

CACHE_NONE

public static final String CACHE_NONE
State flag for preventing caching in every case.

See Also:
Constant Field Values

CACHE_USER

public static final String CACHE_USER
State flag for per-user caching.

See Also:
Constant Field Values

CACHE_WORLD

public static final String CACHE_WORLD
State flag for enabling caching in every case.

See Also:
Constant Field Values

CACHE_DISABLE

public static final String CACHE_DISABLE
State flag for disabling HTTP header caching.

See Also:
Constant Field Values
Constructor Detail

PageTransformer

public PageTransformer()
Method Detail

setDefaultCachePolicy

public static void setDefaultCachePolicy(String policy)
Sets the default cache behavior for the site.

Parameters:
policy - a String policy, one of CACHE_NONE, CACHE_DISABLE, CACHE_USER, CACHE_WORLD

servePage

public void servePage(Document doc,
                      javax.servlet.http.HttpServletRequest req,
                      javax.servlet.http.HttpServletResponse resp)
Uses servePage(Document, HttpServletRequest, HttpServletResponse, Map) to implement the PresentationManager interface.

Specified by:
servePage in interface PresentationManager
Parameters:
doc - the XML document whose content is to be displayed to the output
req - the servlet request
resp - the servlet response

servePage

public void servePage(Document doc,
                      javax.servlet.http.HttpServletRequest req,
                      javax.servlet.http.HttpServletResponse resp,
                      Map params)
Serves an XML Document, getting and applying the appropriate XSLT. Also allows for parameters to be set for the transformer. These will become top-level xsl:params in the stylesheet. The "contextPath" parameter will always be passed to XSLT, which is the value of req.getContextPath().

Parameters:
doc - the Bebop page to serve
req - the servlet request
resp - the servlet response
params - a set of name-value pairs to pass as parameters to the Transformer

registerXSLParameterGenerator

public static void registerXSLParameterGenerator(String parameterName,
                                                 XSLParameterGenerator parameterGenerator)
This adds a generator to the list of parameters available to XSLStylesheets. If this is called a second time with the same parameter name then all previous calls are overwritten and only the last registered generator is used.


removeXSLParameterGenerator

public static void removeXSLParameterGenerator(String parameterName)
This removes the parameter from the list of parameters that will be added to stylesheets


getXSLParameterNames

public static Collection getXSLParameterNames()
This is a Collection of all names of XSL Parameters that have been registered


getXSLParameterValue

public static String getXSLParameterValue(String name,
                                          javax.servlet.http.HttpServletRequest request)
This takes a name and request and returns the value that should be used in the XSL for the given name


addXSLParameters

public static void addXSLParameters(javax.xml.transform.Transformer transformer,
                                    javax.servlet.http.HttpServletRequest request)
This takes in a transformer and adds all of the registered xsl paraemters.



Copyright (c) 2004 Red Hat, Inc. Corporation. All Rights Reserved. Generated at July 20 2004:2337 UTC