org.apache.cocoon.transformation
Class EncodeURLTransformer

java.lang.Object
  |
  +--org.apache.avalon.framework.logger.AbstractLoggable
        |
        +--org.apache.cocoon.xml.AbstractXMLProducer
              |
              +--org.apache.cocoon.xml.AbstractXMLPipe
                    |
                    +--org.apache.cocoon.transformation.AbstractTransformer
                          |
                          +--org.apache.cocoon.transformation.EncodeURLTransformer
All Implemented Interfaces:
org.apache.avalon.framework.component.Component, org.apache.avalon.framework.configuration.Configurable, org.xml.sax.ContentHandler, org.xml.sax.ext.LexicalHandler, org.apache.avalon.framework.logger.Loggable, org.apache.avalon.excalibur.pool.Poolable, org.apache.avalon.excalibur.pool.Recyclable, SitemapModelComponent, Transformer, XMLConsumer, XMLPipe, XMLProducer

public class EncodeURLTransformer
extends AbstractTransformer
implements org.apache.avalon.framework.configuration.Configurable

The encodeURL transformer emits encoded URLs.

This transformer applies encodeURL method to URLs. You may want to use this transform to avoid doing the manually encodeURL() call.

Usually this transformer is appended as last transformer before the serialization process. In this case it is possible to encode URLs introduced in the generator, and xslt transformer phase.

You can specify which attributes hold URL values in order to restrict URL rewriting to specific attributes only.

Usage in a sitemap:


   
   ...
     
     ...
       
         img/@src
         .&asterik;/@href|.&asterik;/@src|.&asterik;/@action
       
   ...
   
     
       ...
       
       ...
 

Version:
CVS $Id: EncodeURLTransformer.java,v 1.1.2.2 2002/11/10 22:53:54 huber Exp $
Author:
Bernhard Huber

Inner Class Summary
 class EncodeURLTransformer.ElementAttributeMatching
          A helper class for matching element names, and attribute names.
 
Field Summary
static java.lang.String EXCLUDE_NAME
          Configuration name for specifying excluding patterns, ie exclude-name.
static java.lang.String EXCLUDE_NAME_DEFAULT
          Configuration default exclude pattern, ie img/@src
static java.lang.String INCLUDE_NAME
          Configuration name for specifying including patterns, ie include-name.
static java.lang.String INCLUDE_NAME_DEFAULT
          Configuration default exclude pattern, ie .*\/@href|.*\/@action|frame/@src
 
Fields inherited from class org.apache.cocoon.xml.AbstractXMLProducer
contentHandler, lexicalHandler, xmlConsumer
 
Fields inherited from interface org.apache.cocoon.transformation.Transformer
ROLE
 
Constructor Summary
EncodeURLTransformer()
           
 
Method Summary
 void configure(org.apache.avalon.framework.configuration.Configuration configuration)
          BEGIN SitemapComponent methods
 long generateKey()
          Generate the unique key.
 CacheValidity generateValidity()
          Generate the validity object.
 void recycle()
          Description of the Method
 void setup(SourceResolver resolver, java.util.Map objectModel, java.lang.String source, org.apache.avalon.framework.parameters.Parameters parameters)
          Setup the transformer.
 void startElement(java.lang.String uri, java.lang.String name, java.lang.String raw, org.xml.sax.Attributes attributes)
          Start parsing an element
 
Methods inherited from class org.apache.cocoon.xml.AbstractXMLPipe
characters, comment, endCDATA, endDocument, endDTD, endElement, endEntity, endPrefixMapping, ignorableWhitespace, processingInstruction, setDocumentLocator, skippedEntity, startCDATA, startDocument, startDTD, startEntity, startPrefixMapping
 
Methods inherited from class org.apache.cocoon.xml.AbstractXMLProducer
setConsumer, setContentHandler, setLexicalHandler
 
Methods inherited from class org.apache.avalon.framework.logger.AbstractLoggable
getLogger, setLogger, setupLogger, setupLogger, setupLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.xml.sax.ContentHandler
characters, endDocument, endElement, endPrefixMapping, ignorableWhitespace, processingInstruction, setDocumentLocator, skippedEntity, startDocument, startPrefixMapping
 
Methods inherited from interface org.xml.sax.ext.LexicalHandler
comment, endCDATA, endDTD, endEntity, startCDATA, startDTD, startEntity
 
Methods inherited from interface org.apache.cocoon.xml.XMLProducer
setConsumer
 

Field Detail

EXCLUDE_NAME

public static final java.lang.String EXCLUDE_NAME
Configuration name for specifying excluding patterns, ie exclude-name.
Since:
 

INCLUDE_NAME

public static final java.lang.String INCLUDE_NAME
Configuration name for specifying including patterns, ie include-name.
Since:
 

EXCLUDE_NAME_DEFAULT

public static final java.lang.String EXCLUDE_NAME_DEFAULT
Configuration default exclude pattern, ie img/@src
Since:
 

INCLUDE_NAME_DEFAULT

public static final java.lang.String INCLUDE_NAME_DEFAULT
Configuration default exclude pattern, ie .*\/@href|.*\/@action|frame/@src
Since:
 
Constructor Detail

EncodeURLTransformer

public EncodeURLTransformer()
Method Detail

setup

public void setup(SourceResolver resolver,
                  java.util.Map objectModel,
                  java.lang.String source,
                  org.apache.avalon.framework.parameters.Parameters parameters)
           throws ProcessingException,
                  org.xml.sax.SAXException,
                  java.io.IOException
Setup the transformer.

Setup include, and exclude patterns from the parameters

Parameters:
resolver - source resolver
objectModel - sitemap objects
parameters - request parameters

configure

public void configure(org.apache.avalon.framework.configuration.Configuration configuration)
               throws org.apache.avalon.framework.configuration.ConfigurationException
BEGIN SitemapComponent methods
Specified by:
configure in interface org.apache.avalon.framework.configuration.Configurable
Parameters:
configuration - Description of Parameter
Throws:
org.apache.avalon.framework.configuration.ConfigurationException - Description of Exception
Since:
 

recycle

public void recycle()
Description of the Method
Overrides:
recycle in class AbstractXMLProducer
Since:
 

generateKey

public long generateKey()
Generate the unique key. This key must be unique inside the space of this component.
Returns:
The generated key hashes the src

generateValidity

public CacheValidity generateValidity()
Generate the validity object.
Returns:
The generated validity object or null if the component is currently not cacheable.

startElement

public void startElement(java.lang.String uri,
                         java.lang.String name,
                         java.lang.String raw,
                         org.xml.sax.Attributes attributes)
                  throws org.xml.sax.SAXException
Start parsing an element
Overrides:
startElement in class AbstractXMLPipe
Parameters:
uri - of the element
name - of the element
raw - name of the element
attributes - list
Throws:
org.xml.sax.SAXException - Description of Exception
Since:
 


Copyright © 1999-2002 Apache Software Foundation. All Rights Reserved.