Package org.apache.fop.render
Class RendererFactory
- java.lang.Object
-
- org.apache.fop.render.RendererFactory
-
public class RendererFactory extends java.lang.Object
Factory for FOEventHandlers and Renderers.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Map
documentHandlerMakerMapping
private java.util.Map
eventHandlerMakerMapping
private static org.apache.commons.logging.Log
log
the loggerprivate java.util.Map
rendererMakerMapping
private boolean
rendererPreferred
-
Constructor Summary
Constructors Constructor Description RendererFactory(boolean rendererPreferred)
Main constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addDocumentHandlerMaker(java.lang.String className)
Add a new document handler maker.void
addDocumentHandlerMaker(AbstractIFDocumentHandlerMaker maker)
Add a new document handler maker.void
addFOEventHandlerMaker(java.lang.String className)
Add a new FOEventHandlerMaker.void
addFOEventHandlerMaker(AbstractFOEventHandlerMaker maker)
Add a new FOEventHandlerMaker.void
addRendererMaker(java.lang.String className)
Add a new RendererMaker.void
addRendererMaker(AbstractRendererMaker maker)
Add a new RendererMaker.IFDocumentHandler
createDocumentHandler(FOUserAgent userAgent, java.lang.String outputFormat)
Creates aIFDocumentHandler
object based on the desired output format.FOEventHandler
createFOEventHandler(FOUserAgent userAgent, java.lang.String outputFormat, java.io.OutputStream out)
Creates FOEventHandler instances based on the desired output.Renderer
createRenderer(FOUserAgent userAgent, java.lang.String outputFormat)
Creates a Renderer object based on render-type desiredprivate Renderer
createRendererForDocumentHandler(IFDocumentHandler documentHandler)
private void
discoverDocumentHandlers()
DiscoversIFDocumentHandler
implementations through the classpath and dynamically registers them.private void
discoverFOEventHandlers()
Discovers FOEventHandler implementations through the classpath and dynamically registers them.private void
discoverRenderers()
Discovers Renderer implementations through the classpath and dynamically registers them.private AbstractIFDocumentHandlerMaker
getDocumentHandlerMaker(java.lang.String mime)
Returns a RendererMaker which handles the given MIME type.AbstractFOEventHandlerMaker
getFOEventHandlerMaker(java.lang.String mime)
Returns a FOEventHandlerMaker which handles the given MIME type.AbstractRendererMaker
getRendererMaker(java.lang.String mime)
Returns a RendererMaker which handles the given MIME type.boolean
isRendererPreferred()
Indicates whether aRenderer
is preferred over aIFDocumentHandler
if both are available for the same MIME type.java.lang.String[]
listSupportedMimeTypes()
private Renderer
tryIFDocumentHandlerMaker(FOUserAgent userAgent, java.lang.String outputFormat)
private Renderer
tryRendererMaker(FOUserAgent userAgent, java.lang.String outputFormat)
-
-
-
Field Detail
-
log
private static org.apache.commons.logging.Log log
the logger
-
rendererMakerMapping
private java.util.Map rendererMakerMapping
-
eventHandlerMakerMapping
private java.util.Map eventHandlerMakerMapping
-
documentHandlerMakerMapping
private java.util.Map documentHandlerMakerMapping
-
rendererPreferred
private final boolean rendererPreferred
-
-
Constructor Detail
-
RendererFactory
public RendererFactory(boolean rendererPreferred)
Main constructor.- Parameters:
rendererPreferred
- Controls whether aRenderer
is preferred over aIFDocumentHandler
if both are available for the same MIME type. True to prefer theRenderer
, false to prefer theIFDocumentHandler
.
-
-
Method Detail
-
isRendererPreferred
public boolean isRendererPreferred()
Indicates whether aRenderer
is preferred over aIFDocumentHandler
if both are available for the same MIME type.- Returns:
- true if the
Renderer
is preferred, false if theIFDocumentHandler
is preferred.
-
addRendererMaker
public void addRendererMaker(AbstractRendererMaker maker)
Add a new RendererMaker. If another maker has already been registered for a particular MIME type, this call overwrites the existing one.- Parameters:
maker
- the RendererMaker
-
addFOEventHandlerMaker
public void addFOEventHandlerMaker(AbstractFOEventHandlerMaker maker)
Add a new FOEventHandlerMaker. If another maker has already been registered for a particular MIME type, this call overwrites the existing one.- Parameters:
maker
- the FOEventHandlerMaker
-
addDocumentHandlerMaker
public void addDocumentHandlerMaker(AbstractIFDocumentHandlerMaker maker)
Add a new document handler maker. If another maker has already been registered for a particular MIME type, this call overwrites the existing one.- Parameters:
maker
- the intermediate format document handler maker
-
addRendererMaker
public void addRendererMaker(java.lang.String className)
Add a new RendererMaker. If another maker has already been registered for a particular MIME type, this call overwrites the existing one.- Parameters:
className
- the fully qualified class name of the RendererMaker
-
addFOEventHandlerMaker
public void addFOEventHandlerMaker(java.lang.String className)
Add a new FOEventHandlerMaker. If another maker has already been registered for a particular MIME type, this call overwrites the existing one.- Parameters:
className
- the fully qualified class name of the FOEventHandlerMaker
-
addDocumentHandlerMaker
public void addDocumentHandlerMaker(java.lang.String className)
Add a new document handler maker. If another maker has already been registered for a particular MIME type, this call overwrites the existing one.- Parameters:
className
- the fully qualified class name of the document handler maker
-
getRendererMaker
public AbstractRendererMaker getRendererMaker(java.lang.String mime)
Returns a RendererMaker which handles the given MIME type.- Parameters:
mime
- the requested output format- Returns:
- the requested RendererMaker or null if none is available
-
getFOEventHandlerMaker
public AbstractFOEventHandlerMaker getFOEventHandlerMaker(java.lang.String mime)
Returns a FOEventHandlerMaker which handles the given MIME type.- Parameters:
mime
- the requested output format- Returns:
- the requested FOEventHandlerMaker or null if none is available
-
getDocumentHandlerMaker
private AbstractIFDocumentHandlerMaker getDocumentHandlerMaker(java.lang.String mime)
Returns a RendererMaker which handles the given MIME type.- Parameters:
mime
- the requested output format- Returns:
- the requested RendererMaker or null if none is available
-
createRenderer
public Renderer createRenderer(FOUserAgent userAgent, java.lang.String outputFormat) throws FOPException
Creates a Renderer object based on render-type desired- Parameters:
userAgent
- the user agent for access to configurationoutputFormat
- the MIME type of the output format to use (ex. "application/pdf").- Returns:
- the new Renderer instance
- Throws:
FOPException
- if the renderer cannot be properly constructed
-
tryIFDocumentHandlerMaker
private Renderer tryIFDocumentHandlerMaker(FOUserAgent userAgent, java.lang.String outputFormat) throws FOPException
- Throws:
FOPException
-
tryRendererMaker
private Renderer tryRendererMaker(FOUserAgent userAgent, java.lang.String outputFormat) throws FOPException
- Throws:
FOPException
-
createRendererForDocumentHandler
private Renderer createRendererForDocumentHandler(IFDocumentHandler documentHandler)
-
createFOEventHandler
public FOEventHandler createFOEventHandler(FOUserAgent userAgent, java.lang.String outputFormat, java.io.OutputStream out) throws FOPException
Creates FOEventHandler instances based on the desired output.- Parameters:
userAgent
- the user agent for access to configurationoutputFormat
- the MIME type of the output format to use (ex. "application/pdf").out
- the OutputStream where the output is written to (if applicable)- Returns:
- the newly constructed FOEventHandler
- Throws:
FOPException
- if the FOEventHandler cannot be properly constructed
-
createDocumentHandler
public IFDocumentHandler createDocumentHandler(FOUserAgent userAgent, java.lang.String outputFormat) throws FOPException
Creates aIFDocumentHandler
object based on the desired output format.- Parameters:
userAgent
- the user agent for access to configurationoutputFormat
- the MIME type of the output format to use (ex. "application/pdf").- Returns:
- the new
IFDocumentHandler
instance - Throws:
FOPException
- if the document handler cannot be properly constructed
-
listSupportedMimeTypes
public java.lang.String[] listSupportedMimeTypes()
- Returns:
- an array of all supported MIME types
-
discoverRenderers
private void discoverRenderers()
Discovers Renderer implementations through the classpath and dynamically registers them.
-
discoverFOEventHandlers
private void discoverFOEventHandlers()
Discovers FOEventHandler implementations through the classpath and dynamically registers them.
-
discoverDocumentHandlers
private void discoverDocumentHandlers()
DiscoversIFDocumentHandler
implementations through the classpath and dynamically registers them.
-
-