org.xwiki.rendering.macro
Class AbstractMacro<P>

java.lang.Object
  extended by org.xwiki.rendering.macro.AbstractMacro<P>
Type Parameters:
P - the type of the macro parameters bean
All Implemented Interfaces:
Comparable<Macro<?>>, org.xwiki.component.phase.Initializable, Macro<P>
Direct Known Subclasses:
AbstractNoParameterMacro

public abstract class AbstractMacro<P>
extends Object
implements Macro<P>, org.xwiki.component.phase.Initializable

Helper to implement Macro, providing some default implementation. We recommend Macro writers to extend this class.

Since:
1.5M2
Version:
$Id: 0ea95024be7020b35a9ddfc34dff8c1a88d8a0f5 $

Field Summary
protected  org.xwiki.properties.BeanManager beanManager
          The BeanManager component.
static String DEFAULT_CATEGORY_CONTENT
          "Content" default macro category.
static String DEFAULT_CATEGORY_DEVELOPMENT
          "Development" default macro category.
static String DEFAULT_CATEGORY_FORMATTING
          "Formatting" default macro category.
static String DEFAULT_CATEGORY_NAVIGATION
          "Navigation" default macro category.
 
Constructor Summary
AbstractMacro(String name)
          Creates a new Macro instance.
AbstractMacro(String name, String description)
          Creates a new Macro instance.
AbstractMacro(String name, String description, Class<?> parametersBeanClass)
          Creates a new Macro instance.
AbstractMacro(String name, String description, ContentDescriptor contentDescriptor)
          Creates a new Macro instance.
AbstractMacro(String name, String description, ContentDescriptor contentDescriptor, Class<?> parametersBeanClass)
          Creates a new Macro instance.
 
Method Summary
 int compareTo(Macro<?> macro)
          
 MacroDescriptor getDescriptor()
          
 int getPriority()
          The priority of execution relative to the other Macros.
 void initialize()
          
protected  void setDefaultCategory(String defaultCategory)
          Allows sub classes to set the default macro category.
protected  void setDescriptor(MacroDescriptor descriptor)
          Allows macro classes extending other macro classes to override the macro descriptor with their own.
 void setPriority(int priority)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.xwiki.rendering.macro.Macro
execute, supportsInlineMode
 

Field Detail

DEFAULT_CATEGORY_FORMATTING

public static final String DEFAULT_CATEGORY_FORMATTING
"Formatting" default macro category.

See Also:
Constant Field Values

DEFAULT_CATEGORY_DEVELOPMENT

public static final String DEFAULT_CATEGORY_DEVELOPMENT
"Development" default macro category.

See Also:
Constant Field Values

DEFAULT_CATEGORY_CONTENT

public static final String DEFAULT_CATEGORY_CONTENT
"Content" default macro category.

See Also:
Constant Field Values

DEFAULT_CATEGORY_NAVIGATION

public static final String DEFAULT_CATEGORY_NAVIGATION
"Navigation" default macro category.

See Also:
Constant Field Values

beanManager

@Inject
protected org.xwiki.properties.BeanManager beanManager
The BeanManager component.

Constructor Detail

AbstractMacro

public AbstractMacro(String name)
Creates a new Macro instance.

Parameters:
name - the name of the macro (eg "Table Of Contents" for the TOC macro)
Since:
2.0M3

AbstractMacro

public AbstractMacro(String name,
                     String description)
Creates a new Macro instance.

Parameters:
name - the name of the macro (eg "Table Of Contents" for the TOC macro)
description - a string describing this macro.
Since:
2.0M3

AbstractMacro

public AbstractMacro(String name,
                     String description,
                     ContentDescriptor contentDescriptor)
Creates a new Macro instance.

Parameters:
name - the name of the macro (eg "Table Of Contents" for the TOC macro)
description - a string describing this macro.
contentDescriptor - ContentDescriptor for this macro.
Since:
2.0M3

AbstractMacro

public AbstractMacro(String name,
                     String description,
                     Class<?> parametersBeanClass)
Creates a new Macro instance.

Parameters:
name - the name of the macro (eg "Table Of Contents" for the TOC macro)
description - a string describing this macro.
parametersBeanClass - class of the parameters bean of this macro.
Since:
2.0M3

AbstractMacro

public AbstractMacro(String name,
                     String description,
                     ContentDescriptor contentDescriptor,
                     Class<?> parametersBeanClass)
Creates a new Macro instance.

Parameters:
name - the name of the macro (eg "Table Of Contents" for the TOC macro)
description - string describing this macro.
contentDescriptor - the ContentDescriptor describing the content of this macro.
parametersBeanClass - class of the parameters bean.
Since:
2.0M3
Method Detail

initialize

public void initialize()
                throws org.xwiki.component.phase.InitializationException

Specified by:
initialize in interface org.xwiki.component.phase.Initializable
Throws:
org.xwiki.component.phase.InitializationException

getPriority

public 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.

Specified by:
getPriority in interface Macro<P>
Returns:
the execution priority
See Also:
Macro.getPriority()

setPriority

public void setPriority(int priority)
Parameters:
priority - the macro priority to use (lower means execute before others)

getDescriptor

public MacroDescriptor getDescriptor()

Specified by:
getDescriptor in interface Macro<P>
Returns:
the macro descriptor
See Also:
Macro.getDescriptor()

compareTo

public int compareTo(Macro<?> macro)

Specified by:
compareTo in interface Comparable<Macro<?>>
See Also:
Comparable.compareTo(java.lang.Object)

setDescriptor

protected void setDescriptor(MacroDescriptor descriptor)
Allows macro classes extending other macro classes to override the macro descriptor with their own.

Parameters:
descriptor - the overriding descriptor to set

setDefaultCategory

protected void setDefaultCategory(String defaultCategory)
Allows sub classes to set the default macro category. This method only has an effect if the internal MacroDescriptor is of type AbstractMacroDescriptor.

Parameters:
defaultCategory - the default macro category to be set.


Copyright © 2004-2011 XWiki. All Rights Reserved.