org.jasig.portal
Class CharacterCachingChannelIncorporationFilter

java.lang.Object
  extended by org.jasig.portal.utils.SAX2FilterImpl
      extended by org.jasig.portal.CharacterCachingChannelIncorporationFilter
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 CharacterCachingChannelIncorporationFilter
extends SAX2FilterImpl

A filter that incorporates channel content into the main SAX stream. Unlike a regular ChannelIncorporationFilter, this class can feed cache character buffers to the CachingSerializer.

Replaces <channel ID="channelSubcribeId"/> elements with channel output from the IChannelRenderer for that channelSubscribeId.

Version:
$Revision: 1.19.4.2 $ $Date: 2005/09/28 20:48:18 $
Author:
Peter Kharchenko

Field Summary
private  boolean ccaching
           
(package private)  java.util.Vector channelIdBlocks
           
private  java.lang.String channelSubscribeId
          ChannelSubscribeId of the currently-being-incorporated channel, if any.
private  java.lang.String channelTitle
           
(package private)  ChannelManager cm
           
private  java.lang.String insideElement
          Track what, if any, incorporation element we are currently processing.
private  CachingSerializer ser
           
(package private)  java.util.Vector systemCCacheBlocks
           
 
Fields inherited from class org.jasig.portal.utils.SAX2FilterImpl
contentHandler, dtdHandler, entityResolver, errorHandler, lexicalHandler, locator, log
 
Constructor Summary
CharacterCachingChannelIncorporationFilter(org.xml.sax.ContentHandler handler, ChannelManager chanm, boolean ccaching)
          Downward chaining constructor.
 
Method Summary
 void endDocument()
          Filter an end document event.
 void endElement(java.lang.String uri, java.lang.String localName, java.lang.String qName)
          Filter an end element event.
private  void endIncorporationElement()
          Reset filter state to not being "inside" an incorporation element (and therefore instead being available to process the next incorporation element encountered).
 java.util.Vector getChannelIdBlocks()
          Obtain a vector of channels to be inserted into a current character cache.
 java.util.Vector getSystemCCacheBlocks()
          Obtain system character cache blocks.
private  boolean isInIncorporationElement()
          Returns true if this filter is currently processing an incorporation element.
 void startDocument()
          Filter a start document event.
 void startElement(java.lang.String uri, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes atts)
          Filter a start element event.
 java.lang.String toString()
           
 
Methods inherited from class org.jasig.portal.utils.SAX2FilterImpl
characters, comment, endCDATA, endDTD, endEntity, endPrefixMapping, error, fatalError, getContentHandler, getDTDHandler, getEntityResolver, getErrorHandler, getFeature, getParent, getProperty, ignorableWhitespace, notationDecl, parse, parse, processingInstruction, resolveEntity, setAllHandlers, setContentHandler, setDocumentLocator, setDTDHandler, setEntityResolver, setErrorHandler, setFeature, setLexicalHandler, setParent, setProperty, skippedEntity, startCDATA, startDTD, startEntity, startPrefixMapping, unparsedEntityDecl, warning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

insideElement

private java.lang.String insideElement
Track what, if any, incorporation element we are currently processing. "channel" if we are "in" the element. "channel-title" if we are "in" the element. Null if we are not in one of these elements. Other elements are not processed by this filter (are not "incorporation elements").


cm

ChannelManager cm

channelSubscribeId

private java.lang.String channelSubscribeId
ChannelSubscribeId of the currently-being-incorporated channel, if any. Null if not currently incorporating a channel (not in an incorporation element.)


channelTitle

private java.lang.String channelTitle

ccaching

private boolean ccaching

ser

private CachingSerializer ser

systemCCacheBlocks

java.util.Vector systemCCacheBlocks

channelIdBlocks

java.util.Vector channelIdBlocks
Constructor Detail

CharacterCachingChannelIncorporationFilter

public CharacterCachingChannelIncorporationFilter(org.xml.sax.ContentHandler handler,
                                                  ChannelManager chanm,
                                                  boolean ccaching)
Downward chaining constructor.

Method Detail

getSystemCCacheBlocks

public java.util.Vector getSystemCCacheBlocks()
Obtain system character cache blocks.

Returns:
a Vector of system character blocks in between which channel renderings should be inserted.

getChannelIdBlocks

public java.util.Vector getChannelIdBlocks()
Obtain a vector of channels to be inserted into a current character cache.

Returns:
a Vector of cache entry blocks corresponding to channel subscribe Id(s) in an order in which they appear in the overall document.

startDocument

public void startDocument()
                   throws org.xml.sax.SAXException
Description copied from class: SAX2FilterImpl
Filter a start document event.

Specified by:
startDocument in interface org.xml.sax.ContentHandler
Overrides:
startDocument in class SAX2FilterImpl
Throws:
org.xml.sax.SAXException - The client may throw an exception during processing.
See Also:
ContentHandler.startDocument()

endDocument

public void endDocument()
                 throws org.xml.sax.SAXException
Description copied from class: SAX2FilterImpl
Filter an end document event.

Specified by:
endDocument in interface org.xml.sax.ContentHandler
Overrides:
endDocument in class SAX2FilterImpl
Throws:
org.xml.sax.SAXException - The client may throw an exception during processing.
See Also:
ContentHandler.endDocument()

startElement

public void startElement(java.lang.String uri,
                         java.lang.String localName,
                         java.lang.String qName,
                         org.xml.sax.Attributes atts)
                  throws org.xml.sax.SAXException
Description copied from class: SAX2FilterImpl
Filter a start element event.

Specified by:
startElement in interface org.xml.sax.ContentHandler
Overrides:
startElement in class SAX2FilterImpl
Parameters:
uri - The element's Namespace URI, or the empty string.
localName - The element's local name, or the empty string.
qName - The element's qualified (prefixed) name, or the empty string.
atts - The element's attributes.
Throws:
org.xml.sax.SAXException - The client may throw an exception during processing.
See Also:
ContentHandler.startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes)

endElement

public void endElement(java.lang.String uri,
                       java.lang.String localName,
                       java.lang.String qName)
                throws org.xml.sax.SAXException
Description copied from class: SAX2FilterImpl
Filter an end element event.

Specified by:
endElement in interface org.xml.sax.ContentHandler
Overrides:
endElement in class SAX2FilterImpl
Parameters:
uri - The element's Namespace URI, or the empty string.
localName - The element's local name, or the empty string.
qName - The element's qualified (prefixed) name, or the empty string.
Throws:
org.xml.sax.SAXException - The client may throw an exception during processing.
See Also:
ContentHandler.endElement(java.lang.String, java.lang.String, java.lang.String)

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

isInIncorporationElement

private boolean isInIncorporationElement()
Returns true if this filter is currently processing an incorporation element. The purpose of this method is to allow ignoring of elements starting within elements this filter is already incorporating, and allow ignoring of end elements except when those end elements end incorporation elements.

Returns:
true if in an incorporation element, false otherwise

endIncorporationElement

private void endIncorporationElement()
Reset filter state to not being "inside" an incorporation element (and therefore instead being available to process the next incorporation element encountered).

Throws:
java.lang.IllegalStateException - if not currently inside an element.