org.jasig.portal
Class StylesheetSet

java.lang.Object
  extended by org.jasig.portal.utils.SAX2FilterImpl
      extended by org.jasig.portal.StylesheetSet
All Implemented Interfaces:
org.xml.sax.ContentHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler, org.xml.sax.ext.LexicalHandler, org.xml.sax.XMLFilter, org.xml.sax.XMLReader

public class StylesheetSet
extends SAX2FilterImpl

A tool for managing a collection of stylesheets. StylesheetSet allows you to instansiate a list of stylesheets in memory and select one according to the request/title/media parameters.

Version:
$Revision: 1.40 $
Author:
Peter Kharchenko

Nested Class Summary
(package private)  class StylesheetSet.OrderedProps
          COPIED FROM XALAN SOURCE Stores the keys and values from a file (similar to a properties file) and can return the first value which has a key contained in its string.
 
Field Summary
private static org.apache.commons.logging.Log log
           
protected static java.lang.String m_defaultMediaPropsUri
           
protected static java.util.Hashtable m_mediaPropsCache
           
protected  java.lang.String m_myMediaPropsUri
           
protected  java.util.Hashtable title_table
           
 
Fields inherited from class org.jasig.portal.utils.SAX2FilterImpl
contentHandler, dtdHandler, entityResolver, errorHandler, lexicalHandler, locator
 
Constructor Summary
StylesheetSet()
           
StylesheetSet(org.xml.sax.ContentHandler dt)
          Create a SAX filter that will pick up stylesheet bindings in a document that's processed through this filter.
StylesheetSet(java.lang.String uri)
          Creates a new StylesheetSet instance given a .ssl file URI.
 
Method Summary
 void addStyleSheet(StylesheetDescription sd)
          Add a stylesheet to the list.
protected  java.lang.String getMedia(BrowserInfo bi)
           
protected  java.lang.String getMedia(javax.servlet.http.HttpServletRequest req)
           
protected  StylesheetSet.OrderedProps getMediaProps()
           
 javax.xml.transform.Source getStylesheet()
          Obtains a default stylesheet.
 javax.xml.transform.Source getStylesheet(javax.servlet.http.HttpServletRequest req)
          Obtain a stylesheet source.
 javax.xml.transform.Source getStylesheet(java.lang.String title)
          Obtain a stylesheet transform source
 javax.xml.transform.Source getStylesheet(java.lang.String title, BrowserInfo bi)
          Obtain a stylesheet
 javax.xml.transform.Source getStylesheet(java.lang.String title, javax.servlet.http.HttpServletRequest req)
          Obtain a stylesheet source.
 javax.xml.transform.Source getStylesheet(java.lang.String title, java.lang.String media)
          Obtain a stylesheet.
 javax.xml.transform.Source getStylesheetByMedia(java.lang.String media)
          Obtain a stylesheet for a given media.
protected  StylesheetDescription getStylesheetDescription(java.lang.String media)
           
 java.lang.String getStylesheetURI(BrowserInfo bi)
          Obtain a matching stylesheet URI
 java.lang.String getStylesheetURI(javax.servlet.http.HttpServletRequest req)
          Obtain a matching stylesheet.
 java.lang.String getStylesheetURI(java.lang.String media)
          Returns the URI of the stylesheet matching the media
 java.lang.String getStylesheetURI(java.lang.String title, BrowserInfo bi)
          Describe getStylesheetURI method here.
 java.lang.String getStylesheetURI(java.lang.String title, javax.servlet.http.HttpServletRequest req)
          Obtain stylesheet URI
 java.lang.String getStylesheetURI(java.lang.String title, java.lang.String media)
          Obtain a stylesheet URI
protected  java.util.Hashtable getTitleTable()
           
 void processingInstruction(java.lang.String target, java.lang.String data)
          Fills StylesheetSet by accepting SAX events
 void setMediaProps(java.lang.String uri)
          Set the location of the media properties object.
 
Methods inherited from class org.jasig.portal.utils.SAX2FilterImpl
characters, comment, endCDATA, endDocument, endDTD, endElement, endEntity, endPrefixMapping, error, fatalError, getContentHandler, getDTDHandler, getEntityResolver, getErrorHandler, getFeature, getParent, getProperty, ignorableWhitespace, notationDecl, parse, parse, resolveEntity, setAllHandlers, setContentHandler, setDocumentLocator, setDTDHandler, setEntityResolver, setErrorHandler, setFeature, setLexicalHandler, setParent, setProperty, skippedEntity, startCDATA, startDocument, startDTD, startElement, startEntity, startPrefixMapping, unparsedEntityDecl, warning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

private static final org.apache.commons.logging.Log log

m_defaultMediaPropsUri

protected static final java.lang.String m_defaultMediaPropsUri
See Also:
Constant Field Values

m_mediaPropsCache

protected static java.util.Hashtable m_mediaPropsCache

m_myMediaPropsUri

protected java.lang.String m_myMediaPropsUri

title_table

protected java.util.Hashtable title_table
Constructor Detail

StylesheetSet

public StylesheetSet()

StylesheetSet

public StylesheetSet(org.xml.sax.ContentHandler dt)
Create a SAX filter that will pick up stylesheet bindings in a document that's processed through this filter.

Parameters:
dt - a ContentHandler of the downstream SAX listener..

StylesheetSet

public StylesheetSet(java.lang.String uri)
              throws PortalException
Creates a new StylesheetSet instance given a .ssl file URI.

Parameters:
uri - a String value
Throws:
PortalException - if an error occurs
Method Detail

getStylesheet

public javax.xml.transform.Source getStylesheet(java.lang.String title)
Obtain a stylesheet transform source

Parameters:
title - a String value
Returns:
a Source for a given stylesheet

getStylesheet

public javax.xml.transform.Source getStylesheet()
Obtains a default stylesheet.

Returns:
a Source for a default stylesheet.

getStylesheet

public javax.xml.transform.Source getStylesheet(java.lang.String title,
                                                java.lang.String media)
Obtain a stylesheet.

Parameters:
title - stylesheet title
media - stylesheet media
Returns:
a Source for the stylesheet.

getStylesheet

public javax.xml.transform.Source getStylesheet(java.lang.String title,
                                                BrowserInfo bi)
                                         throws PortalException
Obtain a stylesheet

Parameters:
title - stylesheet title
bi - current BrowserInfo value
Returns:
a Source for the stylesheet
Throws:
PortalException - if an error occurs

getStylesheetURI

public java.lang.String getStylesheetURI(java.lang.String media)
                                  throws GeneralRenderingException
Returns the URI of the stylesheet matching the media

Parameters:
media -
Returns:
the stylesheet URI
Throws:
GeneralRenderingException

getStylesheetURI

public java.lang.String getStylesheetURI(javax.servlet.http.HttpServletRequest req)
                                  throws PortalException
Obtain a matching stylesheet.

Parameters:
req - current request value.
Returns:
a String stylesheet URI
Throws:
PortalException - if an error occurs

getStylesheetURI

public java.lang.String getStylesheetURI(BrowserInfo bi)
                                  throws PortalException
Obtain a matching stylesheet URI

Parameters:
bi - a BrowserInfo value
Returns:
a String styleshet
Throws:
PortalException - if an error occurs

getStylesheetURI

public java.lang.String getStylesheetURI(java.lang.String title,
                                         javax.servlet.http.HttpServletRequest req)
                                  throws PortalException
Obtain stylesheet URI

Parameters:
title - stylesheet title
req - a HttpServletRequest value
Returns:
a String stylesheet URI
Throws:
PortalException - if an error occurs

getStylesheetURI

public java.lang.String getStylesheetURI(java.lang.String title,
                                         BrowserInfo bi)
                                  throws PortalException
Describe getStylesheetURI method here.

Parameters:
title - a stylesheet title
bi - a BrowserInfo value
Returns:
a String stylesheet URI
Throws:
PortalException - if an error occurs

getStylesheetURI

public java.lang.String getStylesheetURI(java.lang.String title,
                                         java.lang.String media)
                                  throws GeneralRenderingException
Obtain a stylesheet URI

Parameters:
title - stylesheet title
media - media value
Returns:
a String stylesheet URI
Throws:
GeneralRenderingException - if an error occurs

getStylesheetDescription

protected StylesheetDescription getStylesheetDescription(java.lang.String media)
                                                  throws GeneralRenderingException
Throws:
GeneralRenderingException

getStylesheet

public javax.xml.transform.Source getStylesheet(java.lang.String title,
                                                javax.servlet.http.HttpServletRequest req)
                                         throws PortalException
Obtain a stylesheet source.

Parameters:
title - stylesheet title
req - current request
Returns:
a Source for the stylesheet.
Throws:
PortalException - if an error occurs

getStylesheet

public javax.xml.transform.Source getStylesheet(javax.servlet.http.HttpServletRequest req)
                                         throws PortalException
Obtain a stylesheet source.

Parameters:
req - an HttpServletRequest value
Returns:
a Source for the stylesheet
Throws:
PortalException - if an error occurs

getStylesheetByMedia

public javax.xml.transform.Source getStylesheetByMedia(java.lang.String media)
                                                throws GeneralRenderingException
Obtain a stylesheet for a given media.

Parameters:
media - desired media
Returns:
a Source for the stylesheet.
Throws:
GeneralRenderingException - if an error occurs

addStyleSheet

public void addStyleSheet(StylesheetDescription sd)
Add a stylesheet to the list.

Parameters:
sd - a StylesheetDescription value

processingInstruction

public void processingInstruction(java.lang.String target,
                                  java.lang.String data)
                           throws org.xml.sax.SAXException
Fills StylesheetSet by accepting SAX events

Specified by:
processingInstruction in interface org.xml.sax.ContentHandler
Overrides:
processingInstruction in class SAX2FilterImpl
Parameters:
target -
data -
Throws:
org.xml.sax.SAXException
See Also:
ContentHandler.processingInstruction(java.lang.String, java.lang.String)

getMediaProps

protected StylesheetSet.OrderedProps getMediaProps()
                                            throws PortalException
Throws:
PortalException

setMediaProps

public void setMediaProps(java.lang.String uri)
                   throws PortalException
Set the location of the media properties object.

Parameters:
uri - a String value
Throws:
PortalException - if an error occurs

getTitleTable

protected java.util.Hashtable getTitleTable()

getMedia

protected java.lang.String getMedia(javax.servlet.http.HttpServletRequest req)
                             throws PortalException
Throws:
PortalException

getMedia

protected java.lang.String getMedia(BrowserInfo bi)
                             throws PortalException
Throws:
PortalException