Class ElementTransformingFragmentTransformer

  extended by com.atlassian.confluence.content.render.xhtml.transformers.ElementTransformingFragmentTransformer
All Implemented Interfaces:

public class ElementTransformingFragmentTransformer
extends java.lang.Object
implements FragmentTransformer

A FragmentTransformer that can be configured to transform individual Elements it reads.

Typically you would configure ElementTransformers directly on the DefaultFragmentTransformer to transform individual elements but this FragmentTransformer can be used when you want to reduce the scope of the ElementTransform to just a Fragment of the full XML document being read.

This FragmentTransformer makes use of the ConversionContext to store a flag which ensures that this transformer instance will only apply once per ConversionContext. (There is no point in transforming elements multiple times and it could lead to infinite loops if we didn't consume the triggering event. If we do consume the triggering event then the mainFragmentTransformer will fail because it will encounter the closing event without having seen the opening event.)

Rather than having multiple ElementTransformingFragmentTransformer in the pipeline it would be preferable to have only a single one if possible but instead with multiple ElementTransformers configured.

Constructor Summary
ElementTransformingFragmentTransformer(java.util.List<ElementTransformer> elementTransformers, java.util.Set<javax.xml.namespace.QName> handledNames)
Method Summary
 boolean handles( startElementEvent, ConversionContext conversionContext)
 Streamable transform( reader, FragmentTransformer mainFragmentTransformer, ConversionContext conversionContext)
          Wraps the supplied reader in an ElementTransformingXmlEventReader and then applies the mainFragmentTransformer.
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail


public ElementTransformingFragmentTransformer(java.util.List<ElementTransformer> elementTransformers,
                                              java.util.Set<javax.xml.namespace.QName> handledNames)
Method Detail


public boolean handles( startElementEvent,
                       ConversionContext conversionContext)
Specified by:
handles in interface FragmentTransformer
true for any StartElement QName that is returned by the configured Set of ElementTransformer.


public Streamable transform( reader,
                            FragmentTransformer mainFragmentTransformer,
                            ConversionContext conversionContext)
                     throws XhtmlException
Wraps the supplied reader in an ElementTransformingXmlEventReader and then applies the mainFragmentTransformer.

Specified by:
transform in interface FragmentTransformer

Copyright © 2003-2014 Atlassian. All Rights Reserved.