|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.atlassian.confluence.content.render.xhtml.storage.DefaultContentTransformerFactory
public class DefaultContentTransformerFactory
Default implementation of the ContentTransformerFactory, typically used by macro developers to obtain
and optionally modify MacroDefinition objects in page of macro body content.
For following code obtains a reference to the last macro on a page with a given name.
public MacroDefinition getMacroDefinition(ContentEntityObject contentEntityObject, final String macroName)
{
final AtomicReference atomicMacroDefinition = new AtomicReference();
Transformer transformer = contentTransformerFactory.getTransformer(new XhtmlContent.MacroDefinitionUpdater()
{
public MacroDefinition update(MacroDefinition macroDefinition)
{
if (macroName.equals(macroDefinition.getName()))
{
atomicMacroDefinition.set(macroDefinition);
}
return macroDefinition;
}
});
String page = contentEntityObject.getBodyAsString();
Reader reader = new StringReader(page);
PageContext pageContext = contentEntityObject.toPageContext();
ConversionContext conversionContext = new DefaultConversionContext(pageContext);
try
{
transformer.transform(reader, conversionContext);
}
catch (XhtmlException e)
{
e.printStackTrace();
}
return atomicMacroDefinition.get();
}
| Constructor Summary | |
|---|---|
DefaultContentTransformerFactory(Unmarshaller<MacroDefinition> macroDefinitionUnmarshaller,
Marshaller<MacroDefinition> macroDefinitionMarshaller,
XmlEventReaderFactory xmlEventReaderFactory,
XMLOutputFactory xmlOutputFactory,
com.atlassian.event.api.EventPublisher eventPublisher)
|
|
| Method Summary | |
|---|---|
Transformer |
getTransformer(MacroDefinitionHandler macroDefinitionHandler)
Returns a Transformer. |
Transformer |
getTransformer(MacroDefinitionReplacer macroDefinitionReplacer)
Returns a Transformer. |
Transformer |
getTransformer(MacroDefinitionUpdater macroDefinitionUpdater)
Returns a Transformer. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public DefaultContentTransformerFactory(Unmarshaller<MacroDefinition> macroDefinitionUnmarshaller,
Marshaller<MacroDefinition> macroDefinitionMarshaller,
XmlEventReaderFactory xmlEventReaderFactory,
XMLOutputFactory xmlOutputFactory,
com.atlassian.event.api.EventPublisher eventPublisher)
| Method Detail |
|---|
public Transformer getTransformer(MacroDefinitionUpdater macroDefinitionUpdater)
MacroDefinition objects which will be passed to the macroDefinitionUpdater and the resulting
MacroDefinition will then be written back to the same content format.
getTransformer in interface ContentTransformerFactorymacroDefinitionUpdater - that will be called each time a macro is found in the content.
public Transformer getTransformer(MacroDefinitionReplacer macroDefinitionReplacer)
ContentTransformerFactory
getTransformer in interface ContentTransformerFactorymacroDefinitionReplacer - that will be called each time a macro is found in the content.
public Transformer getTransformer(MacroDefinitionHandler macroDefinitionHandler)
ContentTransformerFactory
getTransformer in interface ContentTransformerFactorymacroDefinitionHandler - that will be called each time a macro is found in the content.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||