Package org.apache.wiki.render

# Class DefaultRenderingManager

java.lang.Object
org.apache.wiki.render.DefaultRenderingManager

All Implemented Interfaces:
  `EventListener`, `org.apache.wiki.api.engine.Initializable`, `org.apache.wiki.api.engine.RenderApi`, `org.apache.wiki.event.WikiEventListener`, `InternalModule`, `RenderingManager`

public class DefaultRenderingManager extends Object implements RenderingManager
This class provides a facade towards the differing rendering routines. You should use the routines in this manager instead of the ones in Engine, if you don't want the different side effects to occur - such as WikiFilters.

This class also delegates to a rendering cache, i.e. documents are stored between calls. You may control the cache by tweaking the ehcache configuration file.

Since:
  2.4

## Field Summary

### Fields inherited from interface org.apache.wiki.render.RenderingManager

`PROP_BEAUTIFYTITLE, PROP_PARSER, PROP_RENDERER, PROP_WYSIWYG_RENDERER`

## Constructor Summary

Constructors
Constructor
Description
`DefaultRenderingManager()`

## Method Summary

Modifier and Type
Method
Description
`void`
`actionPerformed(org.apache.wiki.event.WikiEvent event)`
`String`
`beautifyTitle(String title)`
Beautifies the title of the page by appending spaces in suitable places, if the user has so decreed in the properties when constructing this Engine.
`String`
`beautifyTitleNoBreak(String title)`
Beautifies the title of the page by appending non-breaking spaces in suitable places.
`String`
`getHTML(String pagename, int version)`
Returns the converted HTML of the page's specific version.
`String`
`getHTML(org.apache.wiki.api.core.Context context, org.apache.wiki.api.core.Page page)`
Returns the converted HTML of the page using a different context than the default context.
`String`
`getHTML(org.apache.wiki.api.core.Context context, WikiDocument doc)`
Simply renders a WikiDocument to a String.
`MarkupParser`
`getParser(org.apache.wiki.api.core.Context context, String pagedata)`
Returns the wiki Parser
`WikiDocument`
`getRenderedDocument(org.apache.wiki.api.core.Context context, String pagedata)`
Returns a cached document, if one is found.
`WikiRenderer`
`getRenderer(org.apache.wiki.api.core.Context context, WikiDocument doc)`
Returns a WikiRenderer instance, initialized with the given context and doc.
`WikiRenderer`
`getWysiwygRenderer(org.apache.wiki.api.core.Context context, WikiDocument doc)`
Returns a WikiRenderer instance meant for WYSIWYG editing, initialized with the given context and doc.
`void`
`initialize(org.apache.wiki.api.core.Engine engine, Properties properties)`
Checks for cache size settings, initializes the document cache.
`String`
`textToHTML(org.apache.wiki.api.core.Context context, String pagedata)`
`String`
`textToHTML(org.apache.wiki.api.core.Context context, String pagedata, StringTransmutator localLinkHook, StringTransmutator extLinkHook, StringTransmutator attLinkHook, boolean parseAccessRules, boolean justParse)`
Helper method for doing the HTML translation.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Methods inherited from interface org.apache.wiki.render.RenderingManager

`getHTML, getHTML, textToHTML, textToHTML`

## Constructor Details

### DefaultRenderingManager

public DefaultRenderingManager()

## Method Details

### initialize

public void initialize(org.apache.wiki.api.core.Engine engine, Properties properties) throws org.apache.wiki.api.exceptions.WikiException
Checks for cache size settings, initializes the document cache. Looks for alternative WikiRenderers, initializes one, or the default XHTMLRenderer, for use.

Specified by:
  `initialize` in interface `org.apache.wiki.api.engine.Initializable`
Throws:
  `org.apache.wiki.api.exceptions.WikiException`

### beautifyTitle

public String beautifyTitle(String title)
Beautifies the title of the page by appending spaces in suitable places, if the user has so decreed in the properties when constructing this Engine. However, attachment names are only beautified by the name.

Specified by:
  `beautifyTitle` in interface `RenderingManager`
Parameters:
  `title` - The title to beautify
Returns:
  A beautified title (or, if beautification is off, returns the title without modification)

### beautifyTitleNoBreak

public String beautifyTitleNoBreak(String title)
Beautifies the title of the page by appending non-breaking spaces in suitable places. This is really suitable only for HTML output, as it uses the &nbsp; -character.

Specified by:
  `beautifyTitleNoBreak` in interface `RenderingManager`
Parameters:
  `title` - The title to beautify
Returns:
  A beautified title.

### getParser

public MarkupParser getParser(org.apache.wiki.api.core.Context context, String pagedata)
Returns the wiki Parser

Specified by:
  `getParser` in interface `RenderingManager`
  `pagedata` - the page data
Returns:
  A MarkupParser instance.

### getRenderedDocument

public WikiDocument getRenderedDocument(org.apache.wiki.api.core.Context context, String pagedata)
Returns a cached document, if one is found.

Specified by:
  `getRenderedDocument` in interface `RenderingManager`
Parameters:
  `context` - the wiki context
  `pagedata` - the page data
Returns:
  the rendered wiki document

### getHTML

public String getHTML(org.apache.wiki.api.core.Context context, WikiDocument doc) throws IOException
Simply renders a WikiDocument to a String. This version does not get the document from the cache - in fact, it does not cache the document at all. This is very useful, if you have something that you want to render outside the caching routines. Because the cache is based on full pages, and the cache keys are based on names, use this routine if you're rendering anything for yourself.

Specified by:
  `getHTML` in interface `RenderingManager`
Parameters:
  `context` - The WikiContext to render in
  `doc` - A proper WikiDocument
Returns:
  Rendered HTML.
Throws:
  `IOException` - If the WikiDocument is poorly formed.

### getHTML

public String getHTML(org.apache.wiki.api.core.Context context, org.apache.wiki.api.core.Page page)
Returns the converted HTML of the page using a different context than the default context.

Specified by:
  `getHTML` in interface `RenderingManager`
Parameters:
  `context` - A WikiContext in which you wish to render this page in.
  `page` - WikiPage reference.
Returns:
  HTML-rendered version of the page.

### getHTML

public String getHTML(String pagename, int version)
Returns the converted HTML of the page's specific version. The version must be a positive integer, otherwise the current version is returned.

Specified by:
  `getHTML` in interface `RenderingManager`
Parameters:
  `pagename` - WikiName of the page to convert.
  `version` - Version number to fetch
Returns:
  HTML-rendered page text.

### textToHTML

public String textToHTML(org.apache.wiki.api.core.Context context, String pagedata)

Specified by:
  `textToHTML` in interface `org.apache.wiki.api.engine.RenderApi`

### textToHTML

public String textToHTML(org.apache.wiki.api.core.Context context, String pagedata, StringTransmutator localLinkHook, StringTransmutator extLinkHook, StringTransmutator attLinkHook, boolean parseAccessRules, boolean justParse)
Helper method for doing the HTML translation.

Specified by:
  `textToHTML` in interface `RenderingManager`
Parameters:
  `context` - The WikiContext in which to do the conversion
  `pagedata` - The data to render
  `localLinkHook` - Is called whenever a wiki link is found
  `extLinkHook` - Is called whenever an external link is found
  `parseAccessRules` - Parse the access rules if we encounter them
  `justParse` - Just parses the pagedata, does not actually render. In this case, this methods an empty string.
Returns:
  HTML-rendered page text.

### getRenderer

public WikiRenderer getRenderer(org.apache.wiki.api.core.Context context, WikiDocument doc)
Returns a WikiRenderer instance, initialized with the given context and doc. The object is an XHTMLRenderer, unless overridden in jspwiki.properties with PROP_RENDERER.

Specified by:
  `getRenderer` in interface `RenderingManager`
Parameters:
  `context` - The WikiContext
  `doc` - The document to render
Returns:
  A WikiRenderer for this document, or null, if no such renderer could be instantiated.

### getWysiwygRenderer

public WikiRenderer getWysiwygRenderer(org.apache.wiki.api.core.Context context, WikiDocument doc)
Returns a WikiRenderer instance meant for WYSIWYG editing, initialized with the given context and doc. The object is an WysiwygEditingRenderer, unless overridden in jspwiki.properties with PROP_WYSIWYG_RENDERER.

Specified by:
  `getWysiwygRenderer` in interface `RenderingManager`
Parameters:
  `context` - The WikiContext
  `doc` - The document to render
Returns:
  A WikiRenderer instance meant for WYSIWYG editing, for this document, or null, if no such renderer could be instantiated.

### actionPerformed

public void actionPerformed(org.apache.wiki.event.WikiEvent event)

Flushes the document cache in response to a POST_SAVE_BEGIN event.

Specified by:
  `actionPerformed` in interface `org.apache.wiki.event.WikiEventListener`
See Also:
  - `WikiEventListener.actionPerformed(WikiEvent)`