org.xwiki.rendering.internal.macro.toc
Class TocMacro

java.lang.Object
  extended by org.xwiki.rendering.macro.AbstractMacro<TocMacroParameters>
      extended by org.xwiki.rendering.internal.macro.toc.TocMacro
All Implemented Interfaces:
Comparable<Macro<?>>, Initializable, Macro<TocMacroParameters>

@Component
@Named(value="toc")
@Singleton
public class TocMacro
extends AbstractMacro<TocMacroParameters>

Generate a Table Of Contents based on the document sections.

Since:
1.5M2

Field Summary
 
Fields inherited from class org.xwiki.rendering.macro.AbstractMacro
beanManager, DEFAULT_CATEGORY_CONTENT, DEFAULT_CATEGORY_DEVELOPMENT, DEFAULT_CATEGORY_FORMATTING, DEFAULT_CATEGORY_NAVIGATION
 
Constructor Summary
TocMacro()
          Create and initialize the descriptor of the macro.
 
Method Summary
 List<Block> execute(TocMacroParameters parameters, String content, MacroTransformationContext context)
          Executes the macro.
 void initialize()
          Method called by the Component Manager when the component is created for the first time (i.e.
 boolean supportsInlineMode()
           
 
Methods inherited from class org.xwiki.rendering.macro.AbstractMacro
compareTo, getDescriptor, getPriority, setDefaultCategory, setDescriptor, setPriority
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TocMacro

public TocMacro()
Create and initialize the descriptor of the macro.

Method Detail

initialize

public void initialize()
                throws InitializationException
Description copied from interface: Initializable
Method called by the Component Manager when the component is created for the first time (i.e. when it's looked up for the first time or if the component is specified as being loaded on startup). If the component instantiation strategy is singleton then this method is called only once during the lifecycle of the Component Manager. Otherwise the component is created at each lookup and thus this method is called at each lookup too.

Specified by:
initialize in interface Initializable
Overrides:
initialize in class AbstractMacro<TocMacroParameters>
Throws:
InitializationException - if an error happens during a component's initialization

supportsInlineMode

public 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

public List<Block> execute(TocMacroParameters parameters,
                           String content,
                           MacroTransformationContext context)
                    throws MacroExecutionException
Description copied from interface: Macro
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