Class DefaultFragmentTransformer
- java.lang.Object
-
- com.atlassian.confluence.content.render.xhtml.transformers.DefaultFragmentTransformer
-
- All Implemented Interfaces:
MigrationAware
,FragmentTransformer
public class DefaultFragmentTransformer extends Object implements FragmentTransformer, MigrationAware
This can be thought of as the top-level Transformer since it includes the behaviour of writing out any events that have no specific handling configured.
There are two ways of causing transformation:
- Configure a List of
ElementTransformer
which will transform individual elements read. - Configure a List of
FragmentTransformer
which will take well formed fragments of XML and transform them.
Note that in both
FragmentTransformer
andElementTransformer
the order of the configured transformers is the order they are applied. AllElementTransformer
are applied beforeFragmentTransformer
.If you prefer to scope the application of
ElementTransformer
to a particular fragment of XML then instead of configuring them here in the DefaultFragmentTransformer you should instead use anElementTransformingFragmentTransformer
which will scope the Element transformations to a particular fragment of XML.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.atlassian.confluence.content.render.xhtml.migration.MigrationAware
MigrationAware.MigrationPerformedPredicate
-
-
Constructor Summary
Constructors Constructor Description DefaultFragmentTransformer(List<? extends FragmentTransformer> fragmentTransformers, XmlOutputFactory xmlFragmentOutputFactory, XmlEventReaderFactory xmlEventReaderFactory, FragmentTransformationErrorHandler fragmentTransformationErrorHandler, @Nullable com.atlassian.event.api.EventPublisher eventPublisher)
DefaultFragmentTransformer(List<ElementTransformer> elementTransformers, List<? extends FragmentTransformer> fragmentTransformers, XmlOutputFactory xmlFragmentOutputFactory, XmlEventReaderFactory xmlEventReaderFactory, FragmentTransformationErrorHandler fragmentTransformationErrorHandler, @Nullable com.atlassian.event.api.EventPublisher eventPublisher)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static DefaultFragmentTransformer
createMigrationAwareFragmentTransformer(List<? extends FragmentTransformer> fragmentTransformers, XmlOutputFactory xmlFragmentOutputFactory, XmlEventReaderFactory xmlEventReaderFactory, FragmentTransformationErrorHandler fragmentTransformationErrorHandler, com.atlassian.event.api.EventPublisher eventPublisher)
boolean
handles(StartElement startElementEvent, ConversionContext conversionContext)
This fragment converter handles every XHTML element that is not handled by any other converter.Streamable
transform(XMLEventReader reader, FragmentTransformer defaultFragmentTransformer, ConversionContext conversionContext)
Transform the XML read from the supplied reader, making use of any configured FragmentTransformers as appropriate.boolean
wasMigrationPerformed(ConversionContext conversionContext)
Given aConversionContext
that was previously used to perform a migration, determine if that context contains information that indicates whether a "migration" was performed.
-
-
-
Constructor Detail
-
DefaultFragmentTransformer
public DefaultFragmentTransformer(List<? extends FragmentTransformer> fragmentTransformers, XmlOutputFactory xmlFragmentOutputFactory, XmlEventReaderFactory xmlEventReaderFactory, FragmentTransformationErrorHandler fragmentTransformationErrorHandler, @Nullable com.atlassian.event.api.EventPublisher eventPublisher)
-
DefaultFragmentTransformer
public DefaultFragmentTransformer(List<ElementTransformer> elementTransformers, List<? extends FragmentTransformer> fragmentTransformers, XmlOutputFactory xmlFragmentOutputFactory, XmlEventReaderFactory xmlEventReaderFactory, FragmentTransformationErrorHandler fragmentTransformationErrorHandler, @Nullable com.atlassian.event.api.EventPublisher eventPublisher)
-
-
Method Detail
-
createMigrationAwareFragmentTransformer
public static DefaultFragmentTransformer createMigrationAwareFragmentTransformer(List<? extends FragmentTransformer> fragmentTransformers, XmlOutputFactory xmlFragmentOutputFactory, XmlEventReaderFactory xmlEventReaderFactory, FragmentTransformationErrorHandler fragmentTransformationErrorHandler, com.atlassian.event.api.EventPublisher eventPublisher)
- Returns:
- a
MigrationAware
FragmentTransformer
which guarantees that every delegateFragmentTransformer
is alsoMigrationAware
.
-
transform
public Streamable transform(XMLEventReader reader, FragmentTransformer defaultFragmentTransformer, ConversionContext conversionContext) throws XhtmlException
Transform the XML read from the supplied reader, making use of any configured FragmentTransformers as appropriate.- Specified by:
transform
in interfaceFragmentTransformer
- Throws:
XhtmlException
-
handles
public boolean handles(StartElement startElementEvent, ConversionContext conversionContext)
This fragment converter handles every XHTML element that is not handled by any other converter.- Specified by:
handles
in interfaceFragmentTransformer
-
wasMigrationPerformed
public boolean wasMigrationPerformed(ConversionContext conversionContext)
Description copied from interface:MigrationAware
Given aConversionContext
that was previously used to perform a migration, determine if that context contains information that indicates whether a "migration" was performed. What constitutes a migration is implementation-dependent.- Specified by:
wasMigrationPerformed
in interfaceMigrationAware
- Parameters:
conversionContext
- the context used for the migration- Returns:
- true if any of the
MigrationAware
FragmentTransformer
s think a migration was performed, false otherwise.
-
-