org.apache.lenya.cms.cocoon.transformation
Class AbstractLinkTransformer

java.lang.Object
  extended by org.apache.avalon.framework.logger.AbstractLogEnabled
      extended by org.apache.cocoon.xml.AbstractXMLProducer
          extended by org.apache.cocoon.xml.AbstractXMLPipe
              extended by org.apache.cocoon.transformation.AbstractTransformer
                  extended by org.apache.cocoon.transformation.AbstractSAXTransformer
                      extended by org.apache.lenya.cms.cocoon.transformation.AbstractLinkTransformer
All Implemented Interfaces:
org.apache.avalon.excalibur.pool.Poolable, org.apache.avalon.excalibur.pool.Recyclable, org.apache.avalon.framework.activity.Disposable, org.apache.avalon.framework.component.Component, org.apache.avalon.framework.configuration.Configurable, org.apache.avalon.framework.logger.LogEnabled, org.apache.avalon.framework.service.Serviceable, org.apache.cocoon.sitemap.SitemapModelComponent, org.apache.cocoon.transformation.Transformer, org.apache.cocoon.xml.XMLPipe, org.apache.cocoon.xml.XMLProducer, org.apache.excalibur.xml.sax.XMLConsumer, org.xml.sax.ContentHandler, org.xml.sax.ext.LexicalHandler
Direct Known Subclasses:
IncomingProxyTransformer, ProxyTransformer, UrlToUuidTransformer, UuidToUrlTransformer

public abstract class AbstractLinkTransformer
extends org.apache.cocoon.transformation.AbstractSAXTransformer

This transformer processes all links which are configured using <transform/> elements:

   <map:transformer ... >
     <transform namespace="http://www.w3.org/1999/xhtml" element="a" attribute="href"/>
     <transform namespace="..." ... />
   </map:transformer>
 


Nested Class Summary
static class AbstractLinkTransformer.AttributeConfiguration
          Declaration of an attribute which should be transformed.
 
Field Summary
protected  boolean ignoreLinkElement
           
protected  java.lang.String indent
           
 
Fields inherited from class org.apache.cocoon.transformation.AbstractSAXTransformer
context, defaultNamespaceURI, EMPTY_ATTRIBUTES, emptyAttributes, ignoreEmptyCharacters, ignoreEventsCount, ignoreHooksCount, ignoreWhitespaces, manager, namespaceURI, objectModel, parameters, recorderStack, request, resolver, response, source, stack
 
Fields inherited from class org.apache.cocoon.xml.AbstractXMLProducer
contentHandler, EMPTY_CONTENT_HANDLER, lexicalHandler, xmlConsumer
 
Fields inherited from interface org.apache.cocoon.transformation.Transformer
ROLE
 
Constructor Summary
AbstractLinkTransformer()
           
 
Method Summary
 void configure(org.apache.avalon.framework.configuration.Configuration config)
           
 void endElement(java.lang.String uri, java.lang.String name, java.lang.String qname)
           
protected  boolean existsMatchingConfiguration(java.lang.String namespace, java.lang.String localName)
           
protected  java.lang.String getCacheKey(java.lang.String namespace, java.lang.String localName)
           
protected abstract  LinkRewriter getLinkRewriter()
           
protected  java.util.Set getMatchingConfigurations(java.lang.String namespace, java.lang.String localName, org.xml.sax.Attributes attrs)
           
protected  void handleLink(java.lang.String linkUrl, AbstractLinkTransformer.AttributeConfiguration config, org.xml.sax.helpers.AttributesImpl newAttrs)
          Handle a link in the source SAX stream.
protected  void setAttribute(org.xml.sax.helpers.AttributesImpl attr, java.lang.String name, java.lang.String value)
          Sets the value of a certain attribute.
 void startElement(java.lang.String uri, java.lang.String name, java.lang.String qname, org.xml.sax.Attributes attrs)
           
 
Methods inherited from class org.apache.cocoon.transformation.AbstractSAXTransformer
addRecorder, characters, comment, dispose, endCDATA, endDocument, endDTD, endEntity, endParametersRecording, endParametersRecording, endPrefixMapping, endRecording, endSAXRecording, endSerializedXMLRecording, endTextRecording, endTransformingElement, findPrefixMapping, getMutableAttributes, ignorableWhitespace, processingInstruction, recycle, removeRecorder, sendEndElementEvent, sendEndElementEventNS, sendEndPrefixMapping, sendEvents, sendParametersEvents, sendStartElementEvent, sendStartElementEvent, sendStartElementEventNS, sendStartElementEventNS, sendStartPrefixMapping, sendTextEvent, service, setDocumentLocator, setup, setupTransforming, skippedEntity, startCDATA, startDocument, startDTD, startEntity, startParametersRecording, startPrefixMapping, startRecording, startSAXRecording, startSerializedXMLRecording, startTextRecording, startTransformingElement
 
Methods inherited from class org.apache.cocoon.xml.AbstractXMLProducer
setConsumer, setContentHandler, setLexicalHandler
 
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, 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.apache.cocoon.xml.XMLProducer
setConsumer
 

Field Detail

indent

protected java.lang.String indent

ignoreLinkElement

protected boolean ignoreLinkElement
Constructor Detail

AbstractLinkTransformer

public AbstractLinkTransformer()
Method Detail

configure

public void configure(org.apache.avalon.framework.configuration.Configuration config)
               throws org.apache.avalon.framework.configuration.ConfigurationException
Specified by:
configure in interface org.apache.avalon.framework.configuration.Configurable
Overrides:
configure in class org.apache.cocoon.transformation.AbstractSAXTransformer
Throws:
org.apache.avalon.framework.configuration.ConfigurationException

getMatchingConfigurations

protected java.util.Set getMatchingConfigurations(java.lang.String namespace,
                                                  java.lang.String localName,
                                                  org.xml.sax.Attributes attrs)
Parameters:
namespace - The namespace URI.
localName - The local name.
attrs - The attributes.
Returns:
A set of AbstractLinkTransformer.AttributeConfiguration objects.

existsMatchingConfiguration

protected boolean existsMatchingConfiguration(java.lang.String namespace,
                                              java.lang.String localName)

getCacheKey

protected java.lang.String getCacheKey(java.lang.String namespace,
                                       java.lang.String localName)

startElement

public void startElement(java.lang.String uri,
                         java.lang.String name,
                         java.lang.String qname,
                         org.xml.sax.Attributes attrs)
                  throws org.xml.sax.SAXException
Specified by:
startElement in interface org.xml.sax.ContentHandler
Overrides:
startElement in class org.apache.cocoon.transformation.AbstractSAXTransformer
Throws:
org.xml.sax.SAXException
See Also:
ContentHandler.startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes)

handleLink

protected void handleLink(java.lang.String linkUrl,
                          AbstractLinkTransformer.AttributeConfiguration config,
                          org.xml.sax.helpers.AttributesImpl newAttrs)
                   throws java.lang.Exception
Handle a link in the source SAX stream.

Parameters:
linkUrl - The link URL.
config - The attribute configuration which matched the link.
newAttrs - The new attributes which will be added to the result element.
Throws:
java.lang.Exception - if an error occurs.

endElement

public void endElement(java.lang.String uri,
                       java.lang.String name,
                       java.lang.String qname)
                throws org.xml.sax.SAXException
Specified by:
endElement in interface org.xml.sax.ContentHandler
Overrides:
endElement in class org.apache.cocoon.transformation.AbstractSAXTransformer
Throws:
org.xml.sax.SAXException
See Also:
ContentHandler.endElement(java.lang.String, java.lang.String, java.lang.String)

setAttribute

protected void setAttribute(org.xml.sax.helpers.AttributesImpl attr,
                            java.lang.String name,
                            java.lang.String value)
Sets the value of a certain attribute.

Parameters:
attr - The attributes.
name - The attribute name.
value - The value.
Throws:
java.lang.IllegalArgumentException - if the href attribute is not contained in this attributes.

getLinkRewriter

protected abstract LinkRewriter getLinkRewriter()
Returns:
The link rewriter used by this transformer.


Copyright $ Apache Software Foundation. All Rights Reserved.