Package com.mslinn.JBrowCaps

This is a package that reads a CSS1 or CSS2 stylesheet, parses out the HTML tags, and builds a set of HashMaps containing equivalent HTML for browsers of different capbility.  This allows older browsers to render a page as closely as possible to the rendering performed by newer, more capable browers, without necessitating recoding all the HTML for different browsers.  This also provides for a single stylesheet being able to drive browsers by different manufacturers.  More detail can be found at the bottom of the package overview page, after this paragraph repeats.

See:
          Description

Class Summary
CssRule This is a helper class for building a StyleSheet by adding rules to it.
HtmlFormat This is a helper class for StyleSheet, and assists with HTML generation for web browsers that don't support CSS.
JBrowCaps This class wraps StyleSheet to adapt it to PrayerWell's environment.
JBrowCapsTag Seriously in need of optimization!
JBrowCapsTagExtraInfo This class is only called at translation time and for page validation.  The translation time call is the important one.

Sample usage:
StyleSheet The StyleSheet class breaks down a CSS style sheet into equivalent HTML for older browsers and stores the style sheet rules as a HashMap of HashMaps.  For any given browser capability, this class builds a separate HashMap (e.g.
 

Package com.mslinn.JBrowCaps Description

This is a package that reads a CSS1 or CSS2 stylesheet, parses out the HTML tags, and builds a set of HashMaps containing equivalent HTML for browsers of different capbility.  This allows older browsers to render a page as closely as possible to the rendering performed by newer, more capable browers, without necessitating recoding all the HTML for different browsers.  This also provides for a single stylesheet being able to drive browsers by different manufacturers.  More detail can be found at the bottom of the package overview page, after this paragraph repeats.

This package has been released as open source under the LGPL license.

One of the classes (BrowserDetector) is taken from org.apache.turbine.util.

This package contains classes that implement a browser-independant method of supporting style sheets.  Even older browsers, that can't recognize style sheets, or non-HTML browsers such as NTT DoCoMo's i-mode phones can receive suitably rendered markup through the use of this class.

The top-level class is StyleSheet, which drives the other supporting classes.  The StyleSheet class reads a CSS1 or CSS2 style sheet and calls methods in the CssRule class to parse it.  A hashmap is built for every type of browser that is to be supported.  Each entry in the hashmaps contains the markup necessary to render a tag.

The classes JBrowCapsTag and JBrowCapsTagExtraInfo implement custom JSP tags to drive the classes from JSP pages instead of imbedding ugly Java code.

A higher level class is useful to customize the raw capability for a particular application (see AppStyleSheet).

The 'magic' involves a translation performed by the HtmlFormat class in this package.  Edit this class to provide support for more tags and to support more browsers.

Key points

Sample Generated Markup
Tag CSS Rule
(read from file)
cssTrue cssFalse
h1 margin-top:1em;
margin-bottom:0.5em;
display:block;
padding-top:.15em;
padding-botton:.5em;
padding-right:.65em;
padding-left:.65em;
font-weight:bold;
font-size:xx-large
<h1> ... </h1> <b><font size=6> ... </font></b>
.error border:solid thin red;
padding:0.5em;
color:red;
background-color:white;
display:block;
<div class=error> ... </div> <p><font size=3 color=red> ... </font></p>
.small font-size:8pt <span class=small> ... </span> <font size=2> ... </font>

The StyleSheet class supports embedded C-style comments in stylesheets.

Still to do:

Limitations



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