org.xwiki.rendering.macro
Interface Macro<P>

Type Parameters:
P - the type of the macro parameters bean
All Superinterfaces:
Comparable<Macro<?>>
All Known Subinterfaces:
WikiMacro
All Known Implementing Classes:
AbstractBoxMacro, AbstractContainerMacro, AbstractJSR223ScriptMacro, AbstractMacro, AbstractMessageMacro, AbstractNoParameterMacro, AbstractScriptMacro, CacheMacro, ChartMacro, CodeMacro, CommentMacro, ContainerMacro, ContentMacro, ContextMacro, CTSDataMacro, DashboardMacro, DefaultBoxMacro, DefaultScriptMacro, DefaultWikiMacro, DisplayMacro, ErrorMessageMacro, FootnoteMacro, FormulaMacro, GalleryMacro, GroovyMacro, HTMLMacro, IdMacro, IncludeMacro, InfoMessageMacro, JIRAMacro, OfficeMacro, PhpMacro, PutFootnotesMacro, PythonMacro, RssMacro, RubyMacro, SuccessMessageMacro, TocMacro, TranslationMacro, UserAvatarMacro, VelocityMacro, WarningMessageMacro

@ComponentRole
public interface Macro<P>
extends Comparable<Macro<?>>

Represents a Macro, ie a mechanism to generate Rendering Blocks, that we use as a way to either generate dynamic content or simply as a way to reuse Blocks in content.

Since:
1.5M2

Method Summary
 List<Block> execute(P parameters, String content, MacroTransformationContext context)
          Executes the macro.
 MacroDescriptor getDescriptor()
           
 int getPriority()
          The priority of execution relative to the other Macros.
 boolean supportsInlineMode()
           
 
Methods inherited from interface java.lang.Comparable
compareTo
 

Method Detail

getPriority

int getPriority()
The priority of execution relative to the other Macros. The lowest values have the highest priorities and execute first. For example a Macro with a priority of 100 will execute before one with a priority of 500.

Returns:
the execution priority

getDescriptor

MacroDescriptor getDescriptor()
Returns:
the macro descriptor

supportsInlineMode

boolean supportsInlineMode()
Returns:
true if the macro can be inserted in some existing content such as a paragraph, a list item etc. For example if I have == hello {{velocity}}world{{/velocity}} then the Velocity macro must support the inline mode and not generate a paragraph.

execute

List<Block> execute(P parameters,
                    String content,
                    MacroTransformationContext context)
                    throws MacroExecutionException
Executes the macro.

Parameters:
parameters - the macro parameters in the form of a bean defined by the Macro implementation
content - the content of the macro
context - the context of the macros transformation process
Returns:
the result of the macro execution as a list of Block elements
Throws:
MacroExecutionException - error when executing the macro