com.atlassian.confluence.xhtml.api
Class MacroDefinition

java.lang.Object
  extended by com.atlassian.confluence.xhtml.api.MacroDefinition

public class MacroDefinition
extends Object

An object that encapsulates the state for a macro.


Field Summary
static String STORAGE_VERSION_1
           
static String STORAGE_VERSION_2
           
 
Constructor Summary
MacroDefinition()
           
MacroDefinition(MacroDefinition macroDefinition)
          Copy constructor.
MacroDefinition(String name, MacroBody body, Map<String,String> parameters, Map<String,Object> typedParameters, String storageVersion)
          Construct a macro definition.
MacroDefinition(String name, MacroBody body, String defaultParameterValue, Map<String,String> parameters)
          Deprecated. since 5.2. Call MacroDefinition(String, MacroBody, Map, Map, String) instead and pass parsed parameter values.
 
Method Summary
 boolean equals(Object o)
           
 MacroBody getBody()
           
 Streamable getBodyStream()
           
 String getBodyText()
           
 String getDefaultParameterValue()
          Equivalent to getParameter(java.lang.String) or getTypedParameter(java.lang.String, java.lang.Class) with ""
 String getName()
           
 String getParameter(String name)
           
 Map<String,String> getParameters()
           
 Streamable getStorageBodyStream()
           
 String getStorageVersion()
           
 Streamable getTransformedBodyStream()
           
<T> T
getTypedParameter(String name, Class<T> type)
           
 Map<String,Object> getTypedParameters()
           
 boolean hasBody()
           
 int hashCode()
           
 boolean isValid()
           
 String macroHash()
           
 void setBody(MacroBody body)
           
 void setDefaultParameterValue(String defaultParameterValue)
           
 void setName(String name)
           
 void setParameter(String name, String value)
           
 void setParameters(Map<String,String> parameters)
           
 void setStorageVersion(String storageVersion)
           
 void setTypedParameter(String name, Object value)
           
 void setTypedParameters(Map<String,Object> typedParameters)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

STORAGE_VERSION_1

public static final String STORAGE_VERSION_1
See Also:
Constant Field Values

STORAGE_VERSION_2

public static final String STORAGE_VERSION_2
See Also:
Constant Field Values
Constructor Detail

MacroDefinition

public MacroDefinition()

MacroDefinition

public MacroDefinition(MacroDefinition macroDefinition)
Copy constructor.

Parameters:
macroDefinition - copy the state of this macro definition into this new instance

MacroDefinition

@Deprecated
public MacroDefinition(String name,
                                  MacroBody body,
                                  String defaultParameterValue,
                                  Map<String,String> parameters)
Deprecated. since 5.2. Call MacroDefinition(String, MacroBody, Map, Map, String) instead and pass parsed parameter values.

Construct a macro definition.

Parameters:
name - the name of the macro
body - the macro body. Should be set to null if the macro does not have a body. Also see PlainTextMacroBody and RichTextMacroBody.
defaultParameterValue - the default macro parameter value. This value is not assigned an actual parameter name.
parameters - the macro parameters

MacroDefinition

public MacroDefinition(String name,
                       MacroBody body,
                       Map<String,String> parameters,
                       Map<String,Object> typedParameters,
                       String storageVersion)
Construct a macro definition.

Parameters:
name - the name of the macro
body - the macro body. Should be set to null if the macro does not have a body. Also see PlainTextMacroBody and RichTextMacroBody.
parameters - the macro parameters
typedParameters - the macro parameters that are pre-parsed into their associated types
Since:
5.2
Method Detail

getName

public String getName()

getDefaultParameterValue

public String getDefaultParameterValue()
Equivalent to getParameter(java.lang.String) or getTypedParameter(java.lang.String, java.lang.Class) with ""

Returns:
the value of the default parameter, or null if there isn't one.

getBodyText

public String getBodyText()
Returns:
the body as a string. Can be empty. May be transformed, if that is the required format.
See Also:
getStorageBodyStream(), getTransformedBodyStream(), RequiresFormat

getBodyStream

public Streamable getBodyStream()
Returns:
the body as a stream. Can be empty. May be transformed, if that is the required format.
See Also:
getStorageBodyStream(), getTransformedBodyStream(), RequiresFormat

getStorageBodyStream

public Streamable getStorageBodyStream()

getTransformedBodyStream

public Streamable getTransformedBodyStream()

getBody

public MacroBody getBody()

hasBody

public boolean hasBody()

getParameters

public Map<String,String> getParameters()

getTypedParameters

public Map<String,Object> getTypedParameters()

getParameter

public String getParameter(String name)

getTypedParameter

public <T> T getTypedParameter(String name,
                               Class<T> type)

setName

public void setName(String name)

setDefaultParameterValue

public void setDefaultParameterValue(String defaultParameterValue)

setBody

public void setBody(MacroBody body)

setParameters

public void setParameters(Map<String,String> parameters)

setTypedParameters

public void setTypedParameters(Map<String,Object> typedParameters)

setParameter

public void setParameter(String name,
                         String value)

setTypedParameter

public void setTypedParameter(String name,
                              Object value)

getStorageVersion

public String getStorageVersion()

setStorageVersion

public void setStorageVersion(String storageVersion)

isValid

public boolean isValid()
Returns:
true if there is at least a name on this MacroDefinition.

toString

public String toString()
Overrides:
toString in class Object

equals

public boolean equals(Object o)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

macroHash

public String macroHash()
Returns:
the hash of this macro definition, for use when rendering macros for remote add-ons, or when looking up macros through the ContentMacroService.
Since:
5.6


Copyright © 2003–2015 Atlassian. All rights reserved.