org.jasig.portal.utils
Class AbsoluteURLFilter

java.lang.Object
  extended by org.jasig.portal.utils.SAX2FilterImpl
      extended by org.jasig.portal.utils.AbsoluteURLFilter
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
Direct Known Subclasses:
WMLURLFilter, XHTMLURLFilter

public abstract class AbsoluteURLFilter
extends SAX2FilterImpl

Replaces all relative URLs with absolute URLs.

Version:
$Revision: 1.13 $
Author:
Ken Weiner, kweiner@unicon.net

Field Summary
protected  java.lang.String baseUrl
           
 
Fields inherited from class org.jasig.portal.utils.SAX2FilterImpl
contentHandler, dtdHandler, entityResolver, errorHandler, lexicalHandler, locator, log
 
Constructor Summary
protected AbsoluteURLFilter(org.xml.sax.ContentHandler handler)
          A constructor which receives a ContentHandler to which filtered SAX events are passed
 
Method Summary
protected  void fixURL(java.lang.String elementName, java.lang.String attName, java.lang.String qName, org.xml.sax.Attributes atts, org.xml.sax.helpers.AttributesImpl attsImpl)
          A helper method for derivitive classes to easily fix an attribute that has a relative URL value
static AbsoluteURLFilter newAbsoluteURLFilter(java.lang.String mimeType, java.lang.String baseUrl, org.xml.sax.ContentHandler handler)
          A factory method that uses a mime type to decide which kind of AbsoluteURLFilter to instantiate.
private  java.lang.String removeUpDirs(java.lang.String url)
          Removes the '/../' in the URL.
protected  void setBaseUrl(java.lang.String url)
          Sets the base URL.
 
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, processingInstruction, 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

baseUrl

protected java.lang.String baseUrl
Constructor Detail

AbsoluteURLFilter

protected AbsoluteURLFilter(org.xml.sax.ContentHandler handler)
A constructor which receives a ContentHandler to which filtered SAX events are passed

Parameters:
handler - the ContentHandler to which filtered SAX events are passed
Method Detail

newAbsoluteURLFilter

public static final AbsoluteURLFilter newAbsoluteURLFilter(java.lang.String mimeType,
                                                           java.lang.String baseUrl,
                                                           org.xml.sax.ContentHandler handler)
                                                    throws PortalException
A factory method that uses a mime type to decide which kind of AbsoluteURLFilter to instantiate. There are currently two types of markup supported: XHTML and WML.

Parameters:
mimeType - the mime type of the markup that this filter will apply to
baseUrl - the base URL to be prepended to relative URL paths
handler - the ContentHandler to which to pass along filtered SAX events
Returns:
filter the AbsoluteURLFilter matching the mimeType
Throws:
PortalException

setBaseUrl

protected void setBaseUrl(java.lang.String url)
Sets the base URL.

Parameters:
url - the new base URL

fixURL

protected final void fixURL(java.lang.String elementName,
                            java.lang.String attName,
                            java.lang.String qName,
                            org.xml.sax.Attributes atts,
                            org.xml.sax.helpers.AttributesImpl attsImpl)
A helper method for derivitive classes to easily fix an attribute that has a relative URL value

Parameters:
elementName - the element name containing an attribute of name attName
attName - the name of the attribute of elementName
qName - the name of the current element
atts - the attibutes of the current element
attsImpl - the attributes implementation to contain the new attribute value

removeUpDirs

private java.lang.String removeUpDirs(java.lang.String url)
Removes the '/../' in the URL. Some browsers and web servers do not handle these URLs correctly.

Parameters:
url - the absolute URL generated from the fixURL method