org.apache.cocoon.portal.transformation
Class NewEventLinkTransformer

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.cocoon.portal.transformation.AbstractCopletTransformer
                          extended by org.apache.cocoon.portal.transformation.NewEventLinkTransformer
All Implemented Interfaces:
Poolable, Recyclable, Disposable, Component, Configurable, LogEnabled, Serviceable, SitemapModelComponent, Transformer, XMLPipe, XMLProducer, XMLConsumer, ContentHandler, LexicalHandler

public class NewEventLinkTransformer
extends AbstractCopletTransformer

This transformer is used to replace links (URIs) from elements like <a href="URI"> or <form action="URI"> with portal event uris. Therefore the transformer searches for <eventlink> elements replaces the URI form the attribute which is specified within an attribute called "attribute" and renames the element as specified within an attribute called "element". Example:

 <root xmlns:ev="http://apache.org/cocoon/portal/eventlink/1.0">
   <ev:eventlink href="http://eventlinkexample" element="a" attribute="href">linktext</ev:eventlink>
 </root>
will be replaced with something like:

 <root>
   <a href="portal?cocoon-portal-event=8">linktext</a>
 </root>
The transformer will create two CopletLinkEvents and insert corresponding links to them to the XML instead of "http://eventlinkexample". If such a link is pressed the corresponding CopletLinkEvent is sent to the Subscribers to be handled.
Please see also the documentation of superclass AbstractCopletTransformer for how the coplet instance data are acquired.

Version:
CVS $Id: NewEventLinkTransformer.html 1304258 2012-03-23 10:09:27Z ilgrosso $
Author:
Gernot Koller

Field Summary
static String ATTRIBUTE_ATTR
          An attribute's name of EVENT_ELEMENT.
static String ELEMENT_ATTR
          An attribute's name of EVENT_ELEMENT.
static String EVENT_ELEM
          The XML element name to listen for.
static String NAMESPACE_URI
          The namespace URI to listen for.
 
Fields inherited from class org.apache.cocoon.portal.transformation.AbstractCopletTransformer
COPLET_ID_PARAM, portalService
 
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
NewEventLinkTransformer()
           
 
Method Summary
 void endTransformingElement(String uri, String name, String raw)
          Start processing elements of our namespace.
 void startTransformingElement(String uri, String name, String raw, Attributes attributes)
          Start processing elements of our namespace.
 
Methods inherited from class org.apache.cocoon.portal.transformation.AbstractCopletTransformer
dispose, getCopletInstanceData, getCopletInstanceData, getPortalService, service
 
Methods inherited from class org.apache.cocoon.transformation.AbstractSAXTransformer
addRecorder, characters, comment, configure, endCDATA, endDocument, endDTD, endElement, endEntity, endParametersRecording, endParametersRecording, endPrefixMapping, endRecording, endSAXRecording, endSerializedXMLRecording, endTextRecording, findPrefixMapping, getMutableAttributes, ignorableWhitespace, processingInstruction, recycle, removeRecorder, sendEndElementEvent, sendEndElementEventNS, sendEndPrefixMapping, sendEvents, sendParametersEvents, sendStartElementEvent, sendStartElementEvent, sendStartElementEventNS, sendStartElementEventNS, sendStartPrefixMapping, sendTextEvent, setDocumentLocator, setup, setupTransforming, skippedEntity, startCDATA, startDocument, startDTD, startElement, startEntity, startParametersRecording, startPrefixMapping, startRecording, startSAXRecording, startSerializedXMLRecording, startTextRecording
 
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

NAMESPACE_URI

public static final String NAMESPACE_URI
The namespace URI to listen for.

See Also:
Constant Field Values

EVENT_ELEM

public static final String EVENT_ELEM
The XML element name to listen for.

See Also:
Constant Field Values

ATTRIBUTE_ATTR

public static final String ATTRIBUTE_ATTR
An attribute's name of EVENT_ELEMENT.

See Also:
Constant Field Values

ELEMENT_ATTR

public static final String ELEMENT_ATTR
An attribute's name of EVENT_ELEMENT.

See Also:
Constant Field Values
Constructor Detail

NewEventLinkTransformer

public NewEventLinkTransformer()
See Also:
Object.Object()
Method Detail

startTransformingElement

public void startTransformingElement(String uri,
                                     String name,
                                     String raw,
                                     Attributes attributes)
                              throws SAXException
Description copied from class: AbstractSAXTransformer
Start processing elements of our namespace. This hook is invoked for each sax event with our namespace.

Overrides:
startTransformingElement in class AbstractSAXTransformer
Parameters:
uri - The namespace of the element.
name - The local name of the element.
raw - The qualified name of the element.
attributes - The attributes of the element.
Throws:
SAXException - when the eventlink element does not contain the necessary attributes "element" and "attribute", retrieving the LinkURI from the LinkService fails, or an unknown element within the namespaces in encountered.
See Also:
AbstractSAXTransformer.startTransformingElement(String, String, String, Attributes)

endTransformingElement

public void endTransformingElement(String uri,
                                   String name,
                                   String raw)
                            throws SAXException
Description copied from class: AbstractSAXTransformer
Start processing elements of our namespace. This hook is invoked for each sax event with our namespace.

Overrides:
endTransformingElement in class AbstractSAXTransformer
Parameters:
uri - The namespace of the element.
name - The local name of the element.
raw - The qualified name of the element.
Throws:
SAXException
See Also:
AbstractSAXTransformer.endTransformingElement(String, String, String)


Copyright © 1999-2010 The Apache Software Foundation. All Rights Reserved.