public class RendererFactory
extends java.lang.Object
new
keyword.
In general this factory is initalized by the jfo-config.xml. That file contains a list of renderers this factory tries to find and to initialize. If a configured renderer is not found or can't be created (e.g. a class of a used third party library is not available), a warning message is logged at startup. Nevertheless, configurations of unavailable renderers are hold but renderers (and prototypes) are not available.
Renderers are managed as follows: The factory holds a map of configurations
to renderer-prototypes (or null of the prototype couldn't be created). If
a renderer is requested by getRenderer()
, getRenderers()
or newCompositeRenderer()
the factory searches a matching
renderer prototype with the hightest priority and copy of the prototype
is returned. This means, that changing a configuration (at runtime) and not
the prototype has no effect. If you change a configuration at runtime and
you need to apply these changes to the corresponding prototype (or requested
renderer), you have to reconfigure (Renderer.reconfigure()) the prototype
(or renderer).
However, the need of changing the configuration at runtime is really rare.
Constructor and Description |
---|
RendererFactory() |
Modifier and Type | Method and Description |
---|---|
void |
configure(de.vc.config.Configuration config)
Configures this renderer factory with a <renderer>
XML tree from JFO configuration.
|
java.util.List<Renderer> |
getAvailableRenderers()
Returns a list of all available renderers.
|
de.vc.config.Configuration[] |
getConfigurations()
Gets all configurations.
|
de.vc.config.Configuration |
getFactoryConfiguration()
Gets the configuration of this factory that includes all configuration
of renderers.
|
Renderer |
getPrototype(de.vc.config.Configuration c)
Gets the prototype of a given configuration from the configuration to
prototype map.
|
Renderer[] |
getPrototypes()
Gets all available prototypes.
|
Renderer[] |
getPrototypes(OutputFormat format)
Gets all prototypes that can render into the given ouput format.
|
Renderer |
getRenderer(OutputFormat format)
Finds the best renderer (clone of the prototype) with the highest priority
that can render a document into output format format.
|
Renderer[] |
getRenderers(OutputFormat format)
Gets all renderers (clone of the prototypes) that can render into the given
ouput format.
|
OutputFormat[] |
getSupportedOutputFormats()
Gets all output formats which are supported by any registered renderer.
|
static RendererFactory |
instance()
Gets the default renderer factory that is equipped through JFOs
configuration.
|
CompositeRenderer |
newCompositeRenderer()
Creates a composite renderer that contains all available renderes.
|
Renderer |
newRenderer(de.vc.config.Configuration c)
Creates a new renderer specified by a configuration object.
|
void |
register(java.lang.Class<Renderer> rendererClass,
de.vc.config.Configuration config)
Registers a renderer class with its configuration.
|
void |
register(java.lang.String rendererClass,
de.vc.config.Configuration config)
Registers a renderer class with a specific configuration.
|
void |
registerDefaultRenderers()
Registers following renderers at this factory:
de.vc.jfo.renderer.PlainRenderer
de.vc.jfo.renderer.XMLTreeViewer
de.vc.jfo.renderer.SimpleHTMLRenderer
|
void |
unregisterAll()
Unregisters all renderers (Prototypes).
|
public static RendererFactory instance()
JFOConfig.getDefaultRendererFactory()
public void registerDefaultRenderers()
PlainRenderer
,
SimpleHTMLRenderer
,
XMLTreeViewer
public java.util.List<Renderer> getAvailableRenderers()
de.vc.jfo.renderer.Renderer
public CompositeRenderer newCompositeRenderer()
public Renderer getRenderer(OutputFormat format)
format
- Desired output format.null
if no renderer supporting format is available.public void register(java.lang.Class<Renderer> rendererClass, de.vc.config.Configuration config)
de.vc.jfo.renderer.Renderer and must have a parameterless constructor (which is invoked
for creation).
rendererClass
- Renderer class.config
- Configuration.public void register(java.lang.String rendererClass, de.vc.config.Configuration config)
de.vc.jfo.renderer.Renderer and must have
a parameterless constructor.
rendererClass
- Renderer class.config
- Configuration.public void unregisterAll()
public void configure(de.vc.config.Configuration config) throws de.vc.config.ConfigurationException
config
- Configurationde.vc.config.ConfigurationException
public de.vc.config.Configuration getFactoryConfiguration()
public de.vc.config.Configuration[] getConfigurations()
public Renderer[] getRenderers(OutputFormat format)
format
- OutputFormatpublic OutputFormat[] getSupportedOutputFormats()
public Renderer getPrototype(de.vc.config.Configuration c)
c
- Configurationpublic Renderer[] getPrototypes(OutputFormat format)
format
- OutputFormatpublic Renderer[] getPrototypes()
public Renderer newRenderer(de.vc.config.Configuration c)
c
- Configuration© 2003-2011 by Sascha Schmidt (vision-cloud.de). All Rights Reserved.