Package org.apache.fop.apps
Class FopFactory
- java.lang.Object
-
- org.apache.fop.apps.FopFactory
-
- All Implemented Interfaces:
org.apache.xmlgraphics.image.loader.ImageContext
public final class FopFactory extends java.lang.Object implements org.apache.xmlgraphics.image.loader.ImageContext
Factory class which instantiates new Fop and FOUserAgent instances. This class also holds environmental information and configuration used by FOP. Information that may potentially be different for each renderingq run can be found and managed in the FOUserAgent.
-
-
Field Summary
Fields Modifier and Type Field Description private ColorSpaceCache
colorSpaceCache
private FopFactoryConfig
config
private ContentHandlerFactoryRegistry
contentHandlerFactoryRegistry
The registry for ContentHandlerFactory instanceprivate ElementMappingRegistry
elementMappingRegistry
The registry for ElementMapping instancesprivate HyphenationTreeCache
hyphenationTreeCache
private java.util.Map<java.lang.String,java.lang.String>
hyphPatNames
Map of configured names of hyphenation pattern file names: ll_CC => nameprivate ImageHandlerRegistry
imageHandlers
Registry for image handlersprivate static org.apache.commons.logging.Log
log
logger instanceprivate java.util.Map<java.lang.String,RendererConfig>
rendererConfig
private RendererFactory
rendererFactory
Factory for Renderers and FOEventHandlersprivate InternalResourceResolver
resolver
private XMLHandlerRegistry
xmlHandlers
Registry for XML handlers
-
Constructor Summary
Constructors Modifier Constructor Description private
FopFactory(FopFactoryConfig config)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addElementMapping(ElementMapping elementMapping)
Add the element mapping with the given class name.ColorSpaceCache
getColorSpaceCache()
Returns the color space cache for this instance.ContentHandlerFactoryRegistry
getContentHandlerFactoryRegistry()
ElementMappingRegistry
getElementMappingRegistry()
(package private) org.apache.xmlgraphics.image.loader.impl.AbstractImageSessionContext.FallbackResolver
getFallbackResolver()
FontManager
getFontManager()
java.util.Map<java.lang.String,java.lang.String>
getHyphenationPatternNames()
InternalResourceResolver
getHyphenationResourceResolver()
HyphenationTreeCache
getHyphenationTreeCache()
java.util.Set<java.lang.String>
getIgnoredNamespace()
ImageHandlerRegistry
getImageHandlerRegistry()
org.apache.xmlgraphics.image.loader.ImageManager
getImageManager()
LayoutManagerMaker
getLayoutManagerMakerOverride()
java.lang.String
getPageHeight()
java.lang.String
getPageWidth()
(package private) RendererConfig
getRendererConfig(FOUserAgent userAgent, Configuration cfg, RendererConfig.RendererConfigParser configCreator)
Returns the renderer configuration object for a specific renderer given the parser and configuration to read.RendererFactory
getRendererFactory()
float
getSourcePixelUnitToMillimeter()
Returns the conversion factor from pixel units to millimeters.float
getSourceResolution()
float
getTargetPixelUnitToMillimeter()
Returns the conversion factor from pixel units to millimeters.float
getTargetResolution()
Configuration
getUserConfig()
Get the user configuration.XMLHandlerRegistry
getXMLHandlerRegistry()
(package private) boolean
isAccessibilityEnabled()
Returns whether accessibility is enabled.boolean
isBreakIndentInheritanceOnReferenceAreaBoundary()
(package private) boolean
isComplexScriptFeaturesEnabled()
(package private) boolean
isKeepEmptyTags()
boolean
isNamespaceIgnored(java.lang.String namespaceURI)
(package private) boolean
isTableBorderOverpaint()
Fop
newFop(java.lang.String outputFormat)
Returns a newFop
instance.Fop
newFop(java.lang.String outputFormat, java.io.OutputStream stream)
Returns a newFop
instance.Fop
newFop(java.lang.String outputFormat, FOUserAgent userAgent)
Returns a newFop
instance.Fop
newFop(java.lang.String outputFormat, FOUserAgent userAgent, java.io.OutputStream stream)
Returns a newFop
instance.Fop
newFop(FOUserAgent userAgent)
Returns a newFop
instance.FOUserAgent
newFOUserAgent()
Returns a new FOUserAgent instance.static FopFactory
newInstance(java.io.File fopConf)
Returns a new FopFactory instance that is configured using theFopFactoryConfig
object that is created when the fopConf is parsed.static FopFactory
newInstance(java.net.URI baseURI)
Returns a new FopFactory instance that is configured only by the default configuration parameters.static FopFactory
newInstance(java.net.URI baseURI, java.io.InputStream confStream)
Returns a new FopFactory instance that is configured using theFopFactoryConfig
object that is created when the fopConf is parsed.static FopFactory
newInstance(FopFactoryConfig config)
FOP has the ability, for some FO's, to continue processing even if the input XSL violates that FO's content model.boolean
validateStrictly()
boolean
validateUserConfigStrictly()
-
-
-
Field Detail
-
log
private static org.apache.commons.logging.Log log
logger instance
-
rendererFactory
private final RendererFactory rendererFactory
Factory for Renderers and FOEventHandlers
-
xmlHandlers
private final XMLHandlerRegistry xmlHandlers
Registry for XML handlers
-
imageHandlers
private final ImageHandlerRegistry imageHandlers
Registry for image handlers
-
elementMappingRegistry
private final ElementMappingRegistry elementMappingRegistry
The registry for ElementMapping instances
-
contentHandlerFactoryRegistry
private final ContentHandlerFactoryRegistry contentHandlerFactoryRegistry
The registry for ContentHandlerFactory instance
-
colorSpaceCache
private final ColorSpaceCache colorSpaceCache
-
config
private final FopFactoryConfig config
-
resolver
private final InternalResourceResolver resolver
-
rendererConfig
private final java.util.Map<java.lang.String,RendererConfig> rendererConfig
-
hyphenationTreeCache
private HyphenationTreeCache hyphenationTreeCache
-
hyphPatNames
private java.util.Map<java.lang.String,java.lang.String> hyphPatNames
Map of configured names of hyphenation pattern file names: ll_CC => name
-
-
Constructor Detail
-
FopFactory
private FopFactory(FopFactoryConfig config)
-
-
Method Detail
-
newInstance
public static FopFactory newInstance(FopFactoryConfig config)
FOP has the ability, for some FO's, to continue processing even if the input XSL violates that FO's content model. This is the default behavior for FOP. However, this flag, if set, provides the user the ability for FOP to halt on all content model violations if desired. Returns a new FopFactory instance that is configured using theFopFactoryConfig
object.- Parameters:
config
- the fop configuration- Returns:
- the requested FopFactory instance.
-
newInstance
public static FopFactory newInstance(java.io.File fopConf) throws org.xml.sax.SAXException, java.io.IOException
Returns a new FopFactory instance that is configured using theFopFactoryConfig
object that is created when the fopConf is parsed.- Parameters:
fopConf
- the fop conf configuration file to parse- Returns:
- the requested FopFactory instance.
- Throws:
java.io.IOException
org.xml.sax.SAXException
-
newInstance
public static FopFactory newInstance(java.net.URI baseURI)
Returns a new FopFactory instance that is configured only by the default configuration parameters.- Parameters:
baseURI
- the base URI to resolve resource URIs against- Returns:
- the requested FopFactory instance.
-
newInstance
public static FopFactory newInstance(java.net.URI baseURI, java.io.InputStream confStream) throws org.xml.sax.SAXException, java.io.IOException
Returns a new FopFactory instance that is configured using theFopFactoryConfig
object that is created when the fopConf is parsed.- Parameters:
baseURI
- the base URI to resolve resource URIs againstconfStream
- the fop conf configuration stream to parse- Returns:
- the requested FopFactory instance.
- Throws:
org.xml.sax.SAXException
java.io.IOException
-
newFOUserAgent
public FOUserAgent newFOUserAgent()
Returns a new FOUserAgent instance. Use the FOUserAgent to configure special values that are particular to a rendering run. Don't reuse instances over multiple rendering runs but instead create a new one each time and reuse the FopFactory.- Returns:
- the newly created FOUserAgent instance initialized with default values
-
isComplexScriptFeaturesEnabled
boolean isComplexScriptFeaturesEnabled()
-
newFop
public Fop newFop(java.lang.String outputFormat) throws FOPException
Returns a newFop
instance. FOP will be configured with a default user agent instance.MIME types are used to select the output format (ex. "application/pdf" for PDF). You can use the constants defined in
MimeConstants
.- Parameters:
outputFormat
- the MIME type of the output format to use (ex. "application/pdf").- Returns:
- the new Fop instance
- Throws:
FOPException
- when the constructor fails
-
newFop
public Fop newFop(java.lang.String outputFormat, FOUserAgent userAgent) throws FOPException
Returns a newFop
instance. Use this factory method if you want to configure this very rendering run, i.e. if you want to set some metadata like the title and author of the document you want to render. In that case, create a newFOUserAgent
instance usingnewFOUserAgent()
.MIME types are used to select the output format (ex. "application/pdf" for PDF). You can use the constants defined in
MimeConstants
.- Parameters:
outputFormat
- the MIME type of the output format to use (ex. "application/pdf").userAgent
- the user agent that will be used to control the rendering run- Returns:
- the new Fop instance
- Throws:
FOPException
- when the constructor fails
-
isTableBorderOverpaint
boolean isTableBorderOverpaint()
-
newFop
public Fop newFop(java.lang.String outputFormat, java.io.OutputStream stream) throws FOPException
Returns a newFop
instance. FOP will be configured with a default user agent instance. Use this factory method if your output type requires an output stream.MIME types are used to select the output format (ex. "application/pdf" for PDF). You can use the constants defined in
MimeConstants
.- Parameters:
outputFormat
- the MIME type of the output format to use (ex. "application/pdf").stream
- the output stream- Returns:
- the new Fop instance
- Throws:
FOPException
- when the constructor fails
-
newFop
public Fop newFop(java.lang.String outputFormat, FOUserAgent userAgent, java.io.OutputStream stream) throws FOPException
Returns a newFop
instance. Use this factory method if your output type requires an output stream and you want to configure this very rendering run, i.e. if you want to set some metadata like the title and author of the document you want to render. In that case, create a newFOUserAgent
instance usingnewFOUserAgent()
.MIME types are used to select the output format (ex. "application/pdf" for PDF). You can use the constants defined in
MimeConstants
.- Parameters:
outputFormat
- the MIME type of the output format to use (ex. "application/pdf").userAgent
- the user agent that will be used to control the rendering runstream
- the output stream- Returns:
- the new Fop instance
- Throws:
FOPException
- when the constructor fails
-
newFop
public Fop newFop(FOUserAgent userAgent) throws FOPException
Returns a newFop
instance. Use this factory method if you want to supply your ownRenderer
orFOEventHandler
instance instead of the default ones created internally by FOP.- Parameters:
userAgent
- the user agent that will be used to control the rendering run- Returns:
- the new Fop instance
- Throws:
FOPException
- when the constructor fails
-
getRendererFactory
public RendererFactory getRendererFactory()
- Returns:
- the RendererFactory
-
getXMLHandlerRegistry
public XMLHandlerRegistry getXMLHandlerRegistry()
- Returns:
- the XML handler registry
-
getImageHandlerRegistry
public ImageHandlerRegistry getImageHandlerRegistry()
- Returns:
- the image handler registry
-
getElementMappingRegistry
public ElementMappingRegistry getElementMappingRegistry()
- Returns:
- the element mapping registry
-
getContentHandlerFactoryRegistry
public ContentHandlerFactoryRegistry getContentHandlerFactoryRegistry()
- Returns:
- the content handler factory registry
-
getRendererConfig
RendererConfig getRendererConfig(FOUserAgent userAgent, Configuration cfg, RendererConfig.RendererConfigParser configCreator) throws FOPException
Returns the renderer configuration object for a specific renderer given the parser and configuration to read. The renderer config is cached such that theConfiguration
is only parsed once per renderer, per FopFactory instance.- Parameters:
userAgent
- the user agentcfg
- the configuration to be parsedconfigCreator
- the parser that creates the config object- Returns:
- the config object
- Throws:
FOPException
- when an error occurs while creating the configuration object
-
addElementMapping
public void addElementMapping(ElementMapping elementMapping)
Add the element mapping with the given class name.- Parameters:
elementMapping
- the class name representing the element mapping.
-
isAccessibilityEnabled
boolean isAccessibilityEnabled()
Returns whether accessibility is enabled.- Returns:
- true if accessibility is enabled
-
isKeepEmptyTags
boolean isKeepEmptyTags()
-
getImageManager
public org.apache.xmlgraphics.image.loader.ImageManager getImageManager()
- See Also:
FopFactoryConfig.getImageManager()
-
getLayoutManagerMakerOverride
public LayoutManagerMaker getLayoutManagerMakerOverride()
-
getHyphenationPatternNames
public java.util.Map<java.lang.String,java.lang.String> getHyphenationPatternNames()
-
validateStrictly
public boolean validateStrictly()
- See Also:
FopFactoryConfig.validateStrictly()
-
isBreakIndentInheritanceOnReferenceAreaBoundary
public boolean isBreakIndentInheritanceOnReferenceAreaBoundary()
-
getSourceResolution
public float getSourceResolution()
- Specified by:
getSourceResolution
in interfaceorg.apache.xmlgraphics.image.loader.ImageContext
- See Also:
FopFactoryConfig.getSourceResolution()
-
getTargetResolution
public float getTargetResolution()
- See Also:
FopFactoryConfig.getTargetResolution()
-
getHyphenationResourceResolver
public InternalResourceResolver getHyphenationResourceResolver()
-
getSourcePixelUnitToMillimeter
public float getSourcePixelUnitToMillimeter()
Returns the conversion factor from pixel units to millimeters. This depends on the desired source resolution.- Returns:
- float conversion factor
- See Also:
getSourceResolution()
-
getTargetPixelUnitToMillimeter
public float getTargetPixelUnitToMillimeter()
Returns the conversion factor from pixel units to millimeters. This depends on the desired target resolution.- Returns:
- float conversion factor
- See Also:
getTargetResolution()
-
getPageHeight
public java.lang.String getPageHeight()
- See Also:
FopFactoryConfig.getPageHeight()
-
getPageWidth
public java.lang.String getPageWidth()
- See Also:
FopFactoryConfig.getPageWidth()
-
isNamespaceIgnored
public boolean isNamespaceIgnored(java.lang.String namespaceURI)
-
getIgnoredNamespace
public java.util.Set<java.lang.String> getIgnoredNamespace()
- See Also:
FopFactoryConfig.getIgnoredNamespaces()
-
getUserConfig
public Configuration getUserConfig()
Get the user configuration.- Returns:
- the user configuration
-
validateUserConfigStrictly
public boolean validateUserConfigStrictly()
-
getFontManager
public FontManager getFontManager()
- See Also:
FopFactoryConfig.getFontManager()
-
getFallbackResolver
org.apache.xmlgraphics.image.loader.impl.AbstractImageSessionContext.FallbackResolver getFallbackResolver()
- See Also:
FopFactoryConfig.getFallbackResolver()
-
getColorSpaceCache
public ColorSpaceCache getColorSpaceCache()
Returns the color space cache for this instance.Note: this method should not be considered as part of FOP's external API.
- Returns:
- the color space cache
-
getHyphenationTreeCache
public HyphenationTreeCache getHyphenationTreeCache()
-
-