com.atlassian.renderer
Class RenderedContentStore

java.lang.Object
  extended by com.atlassian.renderer.RenderedContentStore

public class RenderedContentStore
extends Object

Hides content from the renderer so that it will not be processed any further.

The RenderedContentStore associates blocks of rendered content (or Renderable objects that can later be transformed into rendered content) with tokens. These tokens can then be substituted for the content blocks during the rendering process. At the end of the chain of renderers, all tokens are replaced once more with their associated content blocks.

Using this technique, it is possible to 'hide' content from the renderer, making it unnecessary to perform nasty hacks to prevent the output of macros or renderer components from being broken by subsequent rendering steps.


Nested Class Summary
static class RenderedContentStore.TokenType
           
 
Field Summary
static String BLOCK_TOKEN
          An unlikely-to-appear-in-real-text token, for use in block-replacement
static String INLINE_TOKEN
          An unlikely-to-appear-in-real-text token, for use in inline content replacement
static String MAP_KEY
          The key under which the store is placed in the render context
 
Constructor Summary
RenderedContentStore()
           
 
Method Summary
 String addBlock(Object content)
          Put some content block into the store.
 String addContent(Object content, RenderedContentStore.TokenType type)
          Add content to the store.
 String addInline(Object content)
          Put some inline content into the store.
 boolean equals(Object o)
           
 Object get(String token)
          Get some content back, given the entire token that was returned from a previous 'add'
static RenderedContentStore getFromRenderContext(RenderContext renderContext)
          Retrieve the store from the render context.
 int hashCode()
           
static String stripTokens(String text)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BLOCK_TOKEN

public static final String BLOCK_TOKEN
An unlikely-to-appear-in-real-text token, for use in block-replacement

See Also:
Constant Field Values

INLINE_TOKEN

public static final String INLINE_TOKEN
An unlikely-to-appear-in-real-text token, for use in inline content replacement

See Also:
Constant Field Values

MAP_KEY

public static final String MAP_KEY
The key under which the store is placed in the render context

See Also:
Constant Field Values
Constructor Detail

RenderedContentStore

public RenderedContentStore()
Method Detail

getFromRenderContext

public static RenderedContentStore getFromRenderContext(RenderContext renderContext)
Retrieve the store from the render context. If the store is not in the context, it is created.

Parameters:
renderContext - the render context to retrieve the store from
Returns:
the active store for this context

addContent

public String addContent(Object content,
                         RenderedContentStore.TokenType type)
Add content to the store. Returns a token that can be placed in the page to be looked up later.

Parameters:
content - the content to add to the store
type - whether the content is RenderedContentStore.TokenType.INLINE or RenderedContentStore.TokenType.BLOCK. The token returned will reflect this type.
Returns:
a token that the ContentReplaceFilter will be able to use to locate the content at a later date.

addBlock

public String addBlock(Object content)
Put some content block into the store. Returns a token that can be placed in the page to be looked up later. The renderer knows not to draw things like paragraphs around another block.

Parameters:
content - the content to add to the store
Returns:
a token that the ContentReplaceFilter will be able to use to locate the content at a later date.

addInline

public String addInline(Object content)
Put some inline content into the store. Returns a token that can be placed in the page to be looked up later. Inline elements will be surrounded by paragraphs and have newlines inserted between them as necessary.

Parameters:
content - the content to add to the store
Returns:
a token that the ContentReplaceFilter will be able to use to locate the content at a later date.

get

public Object get(String token)
Get some content back, given the entire token that was returned from a previous 'add'

Parameters:
token - a token that was returned from a previous add
Returns:
the appropriate content, or null if the content could not be found for that token.

equals

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

hashCode

public int hashCode()
Overrides:
hashCode in class Object

stripTokens

public static String stripTokens(String text)


Copyright © 2009 Atlassian Pty Ltd. All Rights Reserved.