com.atlassian.renderer
Class RenderContext

java.lang.Object
  extended by com.atlassian.renderer.RenderContext
All Implemented Interfaces:
RenderContextOutputType

public class RenderContext
extends Object
implements RenderContextOutputType

Encapsulates the context in which some piece of content is being rendered. The RenderContext is initialised by the renderer, and passed through every RendererComponent.

Components may manipulate the RenderContext - for example to change the render mode before passing the context to some sub-component, but all components must ensure that they return the context to its original state before passing control back to the Renderer.

The RenderContext also holds a reference to the RenderedContentStore that is to be used throughout the rendering process.

See Also:
RenderedContentStore

Field Summary
 
Fields inherited from interface com.atlassian.renderer.RenderContextOutputType
DISPLAY, EMAIL, FEED, HTML_EXPORT, PDF, PREVIEW, WORD
 
Constructor Summary
  RenderContext()
          Construct a new render context in a default state.
protected RenderContext(RenderedContentStore store)
          The Confluence PageContext needs this so that sub-rendered pages can inherit the RenderedContentStore of their parents.
 
Method Summary
 void addExternalReference(Link link)
           
 void addParam(Object key, Object value)
           
 String addRenderedContent(Object content)
          Convenience method so people don't have to keep retrieving the renderedcontentstore.
 String addRenderedContent(Object content, RenderedContentStore.TokenType type)
          Convenience method so people don't have to keep retrieving the renderedcontentstore, but can still report whether their content is a block or inline fragment.
 boolean equals(Object o)
           
 String getAttachmentsPath()
           
 String getBaseUrl()
          Retrieve the confluence instances base url, useful when generating absolute references.
 String getCharacterEncoding()
           
 EmbeddedResourceRenderer getEmbeddedResourceRenderer()
          Retrieve the embedded resource renderer for this rendering run.
 List<Link> getExternalReferences()
           
 String getImagePath()
          Get the URL path to the image directory for this rendering.
 LinkRenderer getLinkRenderer()
          Retrieve the link renderer for this rendering run
 String getOutputType()
          Returns the output type that is configured for the PageContext
 Object getParam(Object key)
           
 Map<Object,Object> getParams()
           
 RenderedContentStore getRenderedContentStore()
          Get this rendering's RenderedContentStore
 RenderMode getRenderMode()
          Get the current render mode.
 String getSiteRoot()
          Get the root URL of the site on which the rendering is occurring
 int hashCode()
           
 boolean isRenderingForWysiwyg()
           
 RenderMode popRenderMode()
          Return to the render mode that was current before pushRenderMode(com.atlassian.renderer.v2.RenderMode) was last called
 void pushRenderMode(RenderMode renderMode)
          Push a new RenderMode onto the stack.
 void setAttachmentsPath(String attachmentsPath)
           
 void setBaseUrl(String baseUrl)
           
 void setCharacterEncoding(String characterEncoding)
           
 void setEmbeddedResourceRenderer(EmbeddedResourceRenderer renderer)
          Set the embedded resource renderer for this rendering run.
 void setImagePath(String imagePath)
          Set the URL path to the image directory for this rendering.
 void setLinkRenderer(LinkRenderer linkRenderer)
          Set the link renderer for this rendering run (exports might need different link rendering behaviour, for example);
 void setOutputType(String outputType)
           
 void setRenderingForWysiwyg(boolean renderingForWysiwyg)
           
 void setSiteRoot(String siteRoot)
          Set the root URL of the site on which the rendering is occurring.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RenderContext

public RenderContext()
Construct a new render context in a default state.


RenderContext

protected RenderContext(RenderedContentStore store)
The Confluence PageContext needs this so that sub-rendered pages can inherit the RenderedContentStore of their parents.

Method Detail

getRenderMode

public RenderMode getRenderMode()
Get the current render mode. The renderer uses this mode to determine which components should be run against the wiki text.

Returns:
the current RenderMode

pushRenderMode

public void pushRenderMode(RenderMode renderMode)
Push a new RenderMode onto the stack. This will become the new current render mode as returned by getRenderMode(). If you call this method, you must also call popRenderMode() once you have completed the operation that requires the new mode.

Parameters:
renderMode - the new current render mode

popRenderMode

public RenderMode popRenderMode()
Return to the render mode that was current before pushRenderMode(com.atlassian.renderer.v2.RenderMode) was last called

Returns:
the render mode that was just popped off the stack

getRenderedContentStore

public RenderedContentStore getRenderedContentStore()
Get this rendering's RenderedContentStore

Returns:
this rendering's RenderedContentStore

addRenderedContent

public String addRenderedContent(Object content)
Convenience method so people don't have to keep retrieving the renderedcontentstore. Replaces content with a block token.

Parameters:
content - the content to store
Returns:
the token replacement

addRenderedContent

public String addRenderedContent(Object content,
                                 RenderedContentStore.TokenType type)
Convenience method so people don't have to keep retrieving the renderedcontentstore, but can still report whether their content is a block or inline fragment.

Parameters:
content - the content to store
type - should be RenderedContentStore.TokenType.INLINE if the content is an inline fragment of markup, or RenderedContentStore.TokenType.BLOCK if it is a block level fragment such as a paragraph. element such as a paragraph.
Returns:
the token replacement

getImagePath

public String getImagePath()
Get the URL path to the image directory for this rendering. The path to images may be different depending on the context of the rendering: for example, an HTML export will have images in a different place to the online website.

Returns:
the URL path to the root of the image directory. Do not add a trailing "/".

setImagePath

public void setImagePath(String imagePath)
Set the URL path to the image directory for this rendering. The path to images may be different depending on the context of the rendering: for example, an HTML export will have images in a different place to the online website.

Parameters:
imagePath - the URL path to the root of the image directory. No trailing "/".

setSiteRoot

public void setSiteRoot(String siteRoot)
Set the root URL of the site on which the rendering is occurring.

Parameters:
siteRoot - the root URL of the site on which the rendering is occurring

getSiteRoot

public String getSiteRoot()
Get the root URL of the site on which the rendering is occurring

Returns:
siteRoot the root URL of the site on which the rendering is occurring

setLinkRenderer

public void setLinkRenderer(LinkRenderer linkRenderer)
Set the link renderer for this rendering run (exports might need different link rendering behaviour, for example);

Parameters:
linkRenderer - the link renderer to use for this run

getLinkRenderer

public LinkRenderer getLinkRenderer()
Retrieve the link renderer for this rendering run

Returns:
linkRenderer the link renderer to use for this run

setEmbeddedResourceRenderer

public void setEmbeddedResourceRenderer(EmbeddedResourceRenderer renderer)
Set the embedded resource renderer for this rendering run.


getEmbeddedResourceRenderer

public EmbeddedResourceRenderer getEmbeddedResourceRenderer()
Retrieve the embedded resource renderer for this rendering run.


getAttachmentsPath

public String getAttachmentsPath()

setAttachmentsPath

public void setAttachmentsPath(String attachmentsPath)

equals

public boolean equals(Object o)
Overrides:
equals in class Object
See Also:
Object.equals(java.lang.Object)

hashCode

public int hashCode()
Overrides:
hashCode in class Object
See Also:
Object.hashCode()

setBaseUrl

public void setBaseUrl(String baseUrl)

getBaseUrl

public String getBaseUrl()
Retrieve the confluence instances base url, useful when generating absolute references.


isRenderingForWysiwyg

public boolean isRenderingForWysiwyg()

setRenderingForWysiwyg

public void setRenderingForWysiwyg(boolean renderingForWysiwyg)

addExternalReference

public void addExternalReference(Link link)

getExternalReferences

public List<Link> getExternalReferences()

getCharacterEncoding

public String getCharacterEncoding()

setCharacterEncoding

public void setCharacterEncoding(String characterEncoding)

getParams

public Map<Object,Object> getParams()

addParam

public void addParam(Object key,
                     Object value)

getParam

public Object getParam(Object key)

getOutputType

public String getOutputType()
Returns the output type that is configured for the PageContext

Returns:
The current output type
See Also:
RenderContextOutputType

setOutputType

public void setOutputType(String outputType)


Copyright © 2009 Atlassian Pty Ltd. All Rights Reserved.