Package org.apache.wiki.parser
Class PluginContent
- java.lang.Object
-
- org.jdom2.Content
-
- org.jdom2.Text
-
- org.apache.wiki.parser.PluginContent
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Cloneable
,PluginElement
,org.jdom2.NamespaceAware
public class PluginContent extends org.jdom2.Text implements PluginElement
Stores the contents of a plugin in a WikiDocument DOM tree. If the Context.VAR_WYSIWYG_EDITOR_MODE is set to Boolean.TRUE in the context, then the plugin is rendered as WikiMarkup. This allows an HTML editor to work without rendering the plugin each time as well. If Context.VAR_EXECUTE_PLUGINS is set to Boolean.FALSE, then the plugin is not executed.- Since:
- 2.4
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description PluginContent(java.lang.String pluginName, java.util.Map<java.lang.String,java.lang.String> parameters)
Creates a new DOM element with the given plugin name and a map of parameters.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
executeParse(Context context)
Executes the executeParse() method.java.lang.String
getParameter(java.lang.String name)
Returns a parameter value from the parameter map.java.util.Map<java.lang.String,java.lang.String>
getParameters()
Returns the parameter map given in the constructor.java.lang.String
getPluginName()
Returns the name of the plugin invoked by the DOM element.java.lang.String
getText()
The main invocation for the plugin.java.lang.String
getValue()
Returns the rendered plugin.java.lang.String
invoke(Context context)
Performs plugin invocation and return its contents.static PluginContent
parsePluginLine(Context context, java.lang.String commandline, int pos)
Parses a plugin invocation and returns a DOM element.-
Methods inherited from class org.jdom2.Text
append, append, clone, detach, getParent, getTextNormalize, getTextTrim, normalizeString, setParent, setText, toString
-
-
-
-
Constructor Detail
-
PluginContent
public PluginContent(java.lang.String pluginName, java.util.Map<java.lang.String,java.lang.String> parameters)
Creates a new DOM element with the given plugin name and a map of parameters.- Parameters:
pluginName
- The FQN of a plugin.parameters
- A Map of parameters.
-
-
Method Detail
-
getPluginName
public java.lang.String getPluginName()
Returns the name of the plugin invoked by the DOM element.- Specified by:
getPluginName
in interfacePluginElement
- Returns:
- Name of the plugin
-
getParameter
public java.lang.String getParameter(java.lang.String name)
Returns a parameter value from the parameter map.- Specified by:
getParameter
in interfacePluginElement
- Parameters:
name
- the name of the parameter.- Returns:
- The value from the map, or null, if no such parameter exists.
-
getParameters
public java.util.Map<java.lang.String,java.lang.String> getParameters()
Returns the parameter map given in the constructor.- Specified by:
getParameters
in interfacePluginElement
- Returns:
- The parameter map.
-
getValue
public java.lang.String getValue()
Returns the rendered plugin. Only calls getText().- Specified by:
getValue
in interfacePluginElement
- Overrides:
getValue
in classorg.jdom2.Text
- Returns:
- HTML
-
getText
public java.lang.String getText()
The main invocation for the plugin. When the getText() is called, it invokes the plugin and returns its contents. If there is no Document yet, only returns the plugin name itself.- Specified by:
getText
in interfacePluginElement
- Overrides:
getText
in classorg.jdom2.Text
- Returns:
- The plugin rendered according to the options set in the WikiContext.
-
invoke
public java.lang.String invoke(Context context)
Performs plugin invocation and return its contents.- Specified by:
invoke
in interfacePluginElement
- Parameters:
context
- WikiContext in which the plugin is executed. Must NOT be null.- Returns:
- plugin contents.
-
executeParse
public void executeParse(Context context) throws PluginException
Executes the executeParse() method.- Specified by:
executeParse
in interfacePluginElement
- Parameters:
context
- The WikiContext- Throws:
PluginException
- If something goes wrong.
-
parsePluginLine
public static PluginContent parsePluginLine(Context context, java.lang.String commandline, int pos) throws PluginException
Parses a plugin invocation and returns a DOM element.- Parameters:
context
- The WikiContextcommandline
- The line to parsepos
- The position in the stream parsing.- Returns:
- A DOM element
- Throws:
PluginException
- If plugin invocation is faulty- Since:
- 2.10.0
-
-