com.atlassian.renderer.v2.macro
Class ResourceAwareMacroDecorator

java.lang.Object
  extended by com.atlassian.renderer.v2.macro.BaseMacro
      extended by com.atlassian.renderer.v2.macro.ResourceAwareMacroDecorator
All Implemented Interfaces:
Macro, ResourceAware

public class ResourceAwareMacroDecorator
extends BaseMacro
implements ResourceAware


Field Summary
 
Fields inherited from interface com.atlassian.renderer.v2.macro.Macro
RAW_PARAMS_KEY
 
Constructor Summary
ResourceAwareMacroDecorator(Macro macro)
           
 
Method Summary
 String execute(Map parameters, String body, RenderContext renderContext)
          Execute the macro.
 RenderMode getBodyRenderMode()
          If the macro has a body, return the mode in which the body of the macro should be rendered.
 Macro getMacro()
           
 String getResourcePath()
           
 boolean hasBody()
          Determine if the macro is a one-shot macro, or one that takes a body.
 boolean isInline()
          Determine if the macro is an "inline" element in the resulting HTML.
 void setResourcePath(String resourcePath)
           
 boolean suppressMacroRenderingDuringWysiwyg()
          Suppress the rendering of the macro -- the macro's body may still be rendered (depending on the render mode of the macro), but the HTML the macro adds will not be created.
 boolean suppressSurroundingTagDuringWysiwygRendering()
          Suppress surrounding div/span during Wysiwyg rendering.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ResourceAwareMacroDecorator

public ResourceAwareMacroDecorator(Macro macro)
Method Detail

getResourcePath

public String getResourcePath()
Specified by:
getResourcePath in interface ResourceAware

setResourcePath

public void setResourcePath(String resourcePath)
Specified by:
setResourcePath in interface ResourceAware

isInline

public boolean isInline()
Description copied from interface: Macro
Determine if the macro is an "inline" element in the resulting HTML. Inline elements will have paragraphs drawn around them, or be incorporated into paragraphs they are included in. As a rule of thumb, if your macro produces a paragraph, table or div (or so on), you should return false. If it produces a span, replacement text or text decoration, return true.

Most macros will want to return false here.

Specified by:
isInline in interface Macro
Returns:
true if the macro output is included inline within the surrounding HTML, false if it forms its own HTML block.

hasBody

public boolean hasBody()
Description copied from interface: Macro
Determine if the macro is a one-shot macro, or one that takes a body. If this method returns false, the renderer will NOT look for an end-tag for the macro. If the method returns true, the renderer will look for an end-tag, but if the end-tag is not found then the macro will be processed with an empty body.

Specified by:
hasBody in interface Macro

getBodyRenderMode

public RenderMode getBodyRenderMode()
Description copied from interface: Macro
If the macro has a body, return the mode in which the body of the macro should be rendered. The body of the macro will be rendered before the macro is executed!

If this method returns null, it causes the macro processor to treat the macro as one that returns wiki-text rather than HTML. The body of the macro will be passed in un-rendered, and the macro's output will be inserted back into the page for further normal processing by the wiki-engine.

Specified by:
getBodyRenderMode in interface Macro
Returns:
the RenderMode in which the body of this macro should be rendered, or null if the macro is substituting wiki-text

execute

public String execute(Map parameters,
                      String body,
                      RenderContext renderContext)
               throws MacroException
Description copied from interface: Macro
Execute the macro. Macros should write any output to the writer (it will be rendered in the RenderMode returned in Macro.getBodyRenderMode()).

Macros are expected to output HTML. The output of macros will not be subjected to any further processing by the wiki-engine. If your macro produces wiki-text, you are responsible for rendering that text to HTML yourself using a SubRenderer or WikiStyleRenderer. If your macro returns pure wiki-text, you can force further processing in the normal chain by returning null from Macro.getBodyRenderMode()

Specified by:
execute in interface Macro
Parameters:
parameters - the parameters included in the macro
body - the content of the body of the macro
renderContext - the rendering context in which the macro was executed
Returns:
the output of the macro
Throws:
MacroException - if the macro fails in some unremarkable way. If the macro fails in a way that is important to the server maintainer (i.e. something is badly wrong), throw a RuntimeException instead.

getMacro

public Macro getMacro()

suppressSurroundingTagDuringWysiwygRendering

public boolean suppressSurroundingTagDuringWysiwygRendering()
Description copied from interface: Macro
Suppress surrounding div/span during Wysiwyg rendering. This should return true if the macro provides it's own Wysiwyg processing HTML.

Specified by:
suppressSurroundingTagDuringWysiwygRendering in interface Macro
Overrides:
suppressSurroundingTagDuringWysiwygRendering in class BaseMacro

suppressMacroRenderingDuringWysiwyg

public boolean suppressMacroRenderingDuringWysiwyg()
Description copied from interface: Macro
Suppress the rendering of the macro -- the macro's body may still be rendered (depending on the render mode of the macro), but the HTML the macro adds will not be created.

Specified by:
suppressMacroRenderingDuringWysiwyg in interface Macro
Overrides:
suppressMacroRenderingDuringWysiwyg in class BaseMacro
Returns:

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2009 Atlassian Pty Ltd. All Rights Reserved.