com.mslinn.JBrowCaps
Class JBrowCaps

java.lang.Object
  |
  +--com.mslinn.JBrowCaps.JBrowCaps

public class JBrowCaps
extends Object

This class wraps StyleSheet to adapt it to PrayerWell's environment.

This is an application-level object only one is required for a servlet application.

Once initialized, two hashmaps are generated, which provide HTML rendering for HTML browsers that support CSS1 and equivalent rendering for older browsers that don't support CSS.  Note that PrayerWell requires the browser to support Java applets, so Netscape V3.3 is the oldest browser that PrayerWell can work with.

See Also:
StyleSheet class notes.

Field Summary
 boolean debug
          Controls debug output sent to System.out.
 
Constructor Summary
JBrowCaps()
          Default constructor.  Because this is a bean (even though there is no requirement to be able to serialize it), the default constructor is necessary.
 
Method Summary
 String _(String tag)
          Look up HTML markup from appropriate HashMap.
 HashMap getCssFalse()
           
 HashMap getCssTrue()
           
 HashMap getStylesheetMap()
          Return appropriate HashMap according to browser type.
static String htmlEncode(String s)
          Encode HTML so that metacharacters are escaped; allow HTML to be displayed in browser.
 void initialize(HttpServletRequest request, HttpServletResponse response, ServletContext servletContext)
          Call this method on the user's first hit of their session.  After verifying that the browser supports java, this method establishes the appropriate hashmap for rendering to the user's browser.
 void setStrict(boolean strict)
          Controls if error messages are generated when an attempt is made to reference a undefined tag.
 String toString()
          Format StyleSheet for printing when debugging.  Definitions are printed in sorted order.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

debug

public boolean debug

Controls debug output sent to System.out.

Constructor Detail

JBrowCaps

public JBrowCaps()

Default constructor.  Because this is a bean (even though there is no requirement to be able to serialize it), the default constructor is necessary.

Method Detail

_

public String _(String tag)
         throws JspException

Look up HTML markup from appropriate HashMap.

Parameters:
tag - String to look up in the appropriate HashMap.
Throws:
MsException - if the value returned from the HashMap has no String representation.

getStylesheetMap

public HashMap getStylesheetMap()

Return appropriate HashMap according to browser type.


getCssTrue

public HashMap getCssTrue()
                   throws JspException
Returns:
HashMap for browsers that support css.
Throws:
TurbineException - if stylesheet is null.

getCssFalse

public HashMap getCssFalse()
                    throws JspException
Returns:
HashMap for browsers that don't support css.

htmlEncode

public static String htmlEncode(String s)

Encode HTML so that metacharacters are escaped; allow HTML to be displayed in browser.

Parameters:
s - String containing URL to encode.
Returns:
String containing encoded HTML.

initialize

public void initialize(HttpServletRequest request,
                       HttpServletResponse response,
                       ServletContext servletContext)
                throws JspException,
                       IOException

Call this method on the user's first hit of their session.  After verifying that the browser supports java, this method establishes the appropriate hashmap for rendering to the user's browser.

The call to the constructor and the application level initialization should be moved to the init() method of the Sequencer servlet one day.

Parameters:
env - Environment reference.
Throws:
MsException - if browser is too old to support Java or problem constructing stylesheet.

setStrict

public void setStrict(boolean strict)

Controls if error messages are generated when an attempt is made to reference a undefined tag.

Parameters:
strict - boolean indicating if undefined tags are to cause an error.

toString

public String toString()

Format StyleSheet for printing when debugging.  Definitions are printed in sorted order.

Overrides:
toString in class Object


Written 2001 by Mike Slinn.  All rights reserved.
4230 Wooster Ave, San Mateo, CA 94403.
Tel: 650-571-8436   www.mslinn.com