com.atlassian.renderer
Class RenderContext

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

public class RenderContext
extends java.lang.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(java.lang.Object key, java.lang.Object value)
           
 java.lang.String addRenderedContent(java.lang.Object content)
          Convenience method so people don't have to keep retrieving the renderedcontentstore
 boolean equals(java.lang.Object o)
           
 java.lang.String getAttachmentsPath()
           
 java.lang.String getBaseUrl()
          Retrieve the confluence instances base url, useful when generating absolute references.
 java.lang.String getCharacterEncoding()
           
 EmbeddedResourceRenderer getEmbeddedResourceRenderer()
          Retrieve the embedded resource renderer for this rendering run.
 java.util.List getExternalReferences()
           
 java.lang.String getImagePath()
          Get the URL path to the image directory for this rendering.
 LinkRenderer getLinkRenderer()
          Retrieve the link renderer for this rendering run
 java.lang.String getOutputType()
          Returns the output type that is configured for the PageContext
 java.lang.Object getParam(java.lang.Object key)
           
 java.util.Map getParams()
           
 RenderedContentStore getRenderedContentStore()
          Get this rendering's RenderedContentStore
 RenderMode getRenderMode()
          Get the current render mode.
 java.lang.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(java.lang.String attachmentsPath)
           
 void setBaseUrl(java.lang.String baseUrl)
           
 void setCharacterEncoding(java.lang.String characterEncoding)
           
 void setEmbeddedResourceRenderer(EmbeddedResourceRenderer renderer)
          Set the embedded resource renderer for this rendering run.
 void setImagePath(java.lang.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(java.lang.String outputType)
           
 void setRenderingForWysiwyg(boolean renderingForWysiwyg)
           
 void setSiteRoot(java.lang.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 java.lang.String addRenderedContent(java.lang.Object content)
Convenience method so people don't have to keep retrieving the renderedcontentstore

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

getImagePath

public java.lang.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(java.lang.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(java.lang.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 java.lang.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.

Parameters:
renderer -

getEmbeddedResourceRenderer

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

Returns:

getAttachmentsPath

public java.lang.String getAttachmentsPath()

setAttachmentsPath

public void setAttachmentsPath(java.lang.String attachmentsPath)

equals

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

hashCode

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

setBaseUrl

public void setBaseUrl(java.lang.String baseUrl)

getBaseUrl

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

Returns:

isRenderingForWysiwyg

public boolean isRenderingForWysiwyg()

setRenderingForWysiwyg

public void setRenderingForWysiwyg(boolean renderingForWysiwyg)

addExternalReference

public void addExternalReference(Link link)

getExternalReferences

public java.util.List getExternalReferences()

getCharacterEncoding

public java.lang.String getCharacterEncoding()

setCharacterEncoding

public void setCharacterEncoding(java.lang.String characterEncoding)

getParams

public java.util.Map getParams()

addParam

public void addParam(java.lang.Object key,
                     java.lang.Object value)

getParam

public java.lang.Object getParam(java.lang.Object key)

getOutputType

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

Returns:
The current output type
See Also:
RenderContextOutputType

setOutputType

public void setOutputType(java.lang.String outputType)


Copyright © 2008 Atlassian Pty Ltd. All Rights Reserved.