Package org.xwiki.rendering.macro
Class AbstractMacro<P>
- java.lang.Object
-
- 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: f033175abc3f9c205ec22241a760271b7e88dc64 $
-
-
Field Summary
Fields Modifier and Type Field Description protected org.xwiki.properties.BeanManagerbeanManagerTheBeanManagercomponent.static StringDEFAULT_CATEGORY_CONTENT"Content" default macro category.static StringDEFAULT_CATEGORY_DEPRECATED"Deprecated" default macro category.static StringDEFAULT_CATEGORY_DEVELOPMENT"Development" default macro category.static StringDEFAULT_CATEGORY_FORMATTING"Formatting" default macro category.static StringDEFAULT_CATEGORY_INTERNAL"Internal" default macro category.static StringDEFAULT_CATEGORY_LAYOUT"Layout" default macro category.static StringDEFAULT_CATEGORY_NAVIGATION"Navigation" default macro category.
-
Constructor Summary
Constructors Constructor Description AbstractMacro(String name)Creates a newMacroinstance.AbstractMacro(String name, String description)Creates a newMacroinstance.AbstractMacro(String name, String description, Class<?> parametersBeanClass)Creates a newMacroinstance.AbstractMacro(String name, String description, ContentDescriptor contentDescriptor)Creates a newMacroinstance.AbstractMacro(String name, String description, ContentDescriptor contentDescriptor, Class<?> parametersBeanClass)Creates a newMacroinstance.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description intcompareTo(Macro<?> macro)MacroDescriptorgetDescriptor()protected MetaDatagetNonGeneratedContentMetaData()Helper to get the proper metadata for non generated content (i.e.protected MetaDatagetNonGeneratedContentMetaData(String parameterName)Helper to get the proper metadata for non generated content (i.e.static MetaDatagetNonGeneratedContentMetaData(Map<String,ParameterDescriptor> parameterDescriptorMap, String name)Helper to get the proper metadata for non generated content (i.e.static MetaDatagetNonGeneratedContentMetaData(ContentDescriptor contentDescriptor)Helper to get the proper metadata for non generated content (i.e.intgetPriority()The priority of execution relative to the other Macros.voidinitialize()protected voidsetDefaultCategories(Set<String> defaultCategories)Allows sub-classes to set default macro categories.protected voidsetDescriptor(MacroDescriptor descriptor)Allows macro classes extending other macro classes to override the macro descriptor with their own.voidsetPriority(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
-
DEFAULT_CATEGORY_INTERNAL
public static final String DEFAULT_CATEGORY_INTERNAL
"Internal" default macro category.- See Also:
- Constant Field Values
-
DEFAULT_CATEGORY_DEPRECATED
@Unstable public static final String DEFAULT_CATEGORY_DEPRECATED
"Deprecated" default macro category.- Since:
- 14.8RC1
- See Also:
- Constant Field Values
-
DEFAULT_CATEGORY_LAYOUT
public static final String DEFAULT_CATEGORY_LAYOUT
"Layout" default macro category.- See Also:
- Constant Field Values
-
beanManager
@Inject protected org.xwiki.properties.BeanManager beanManager
TheBeanManagercomponent.
-
-
Constructor Detail
-
AbstractMacro
public AbstractMacro(String name)
Creates a newMacroinstance.- 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 newMacroinstance.- 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 newMacroinstance.- Parameters:
name- the name of the macro (eg "Table Of Contents" for the TOC macro)description- a string describing this macro.contentDescriptor-ContentDescriptorfor this macro.- Since:
- 2.0M3
-
AbstractMacro
public AbstractMacro(String name, String description, Class<?> parametersBeanClass)
Creates a newMacroinstance.- 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 newMacroinstance.- Parameters:
name- the name of the macro (eg "Table Of Contents" for the TOC macro)description- string describing this macro.contentDescriptor- theContentDescriptordescribing 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:
initializein interfaceorg.xwiki.component.phase.Initializable- Throws:
org.xwiki.component.phase.InitializationException
-
getPriority
public int getPriority()
Description copied from interface:MacroThe 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:
getPriorityin interfaceMacro<P>- Returns:
- the execution priority
-
setPriority
public void setPriority(int priority)
- Parameters:
priority- the macro priority to use (lower means execute before others)
-
getDescriptor
public MacroDescriptor getDescriptor()
- Specified by:
getDescriptorin interfaceMacro<P>- Returns:
- the macro descriptor
-
compareTo
public int compareTo(Macro<?> macro)
- Specified by:
compareToin interfaceComparable<P>
-
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
-
setDefaultCategories
@Unstable protected void setDefaultCategories(Set<String> defaultCategories)
Allows sub-classes to set default macro categories. This method only has an effect of the internalMacroDescriptoris of typeAbstractMacroDescriptor.- Parameters:
defaultCategories- the default macro categories to set- Since:
- 14.6RC1
-
getNonGeneratedContentMetaData
public static MetaData getNonGeneratedContentMetaData(ContentDescriptor contentDescriptor)
Helper to get the proper metadata for non generated content (i.e. content that has not gone through a Transformation). This content can be used for inline editing.- Parameters:
contentDescriptor- theContentDescriptorfrom which to get the type for the metadata.- Returns:
- the new metadata with the content type for the content represented as a string (e.g.
java.util.List<org.xwiki.rendering.block.Block>for content of typeList<Block> - Since:
- 11.4RC1
-
getNonGeneratedContentMetaData
protected MetaData getNonGeneratedContentMetaData()
Helper to get the proper metadata for non generated content (i.e. content that has not gone through a Transformation). This content can be used for inline editing.- Returns:
- the new metadata with the content type for the content represented as a string (e.g.
java.util.List<org.xwiki.rendering.block.Block>for content of typeList<Block> - Since:
- 10.10
-
getNonGeneratedContentMetaData
public static MetaData getNonGeneratedContentMetaData(Map<String,ParameterDescriptor> parameterDescriptorMap, String name)
Helper to get the proper metadata for non generated content (i.e. content that has not gone through a Transformation) for a specific parameter. This content can be used for inline editing.- Parameters:
parameterDescriptorMap- the descriptor map of the parametersname- the name of the parameter for which to get the metadata- Returns:
- the new metadata with the content type for the content represented as a string (e.g.
java.util.List<org.xwiki.rendering.block.Block>for content of typeList<Block> - Since:
- 11.4RC1
-
getNonGeneratedContentMetaData
protected MetaData getNonGeneratedContentMetaData(String parameterName)
Helper to get the proper metadata for non generated content (i.e. content that has not gone through a Transformation) for a specific parameter. This content can be used for inline editing.- Parameters:
parameterName- the name of the parameter as defined in the macro- Returns:
- the new metadata with the content type for the content represented as a string (e.g.
java.util.List<org.xwiki.rendering.block.Block>for content of typeList<Block> - Since:
- 11.1RC1
-
-