Package org.faceless.publisher
Class ReportFactory
java.lang.Object
org.faceless.publisher.ReportFactory
A ReportFactory is used to create Report objects.
A single instance of the factory may be used in multiple threads to create multiple Reports, in which case they will all share the same cache of external resources such as stylesheetlist, images and fonts.
Or, different instances of this factory may be created which are entirely independent.
The factory can be used to create a Report from a File or URL, or a new Report object can be returned which can be parsed externally
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionCreate a newReport
and intialize it to match the settings applied to this factory.createReportOutput
(MediaType mediaType) Create a newReportOutput
that matches the specifiedMediaType
, or null if that type cannot be generated.Return the Base URL as set bysetBaseURL(org.faceless.publisher.type.URL2)
int
Return the cache size as set bysetCacheSize(int)
Return the CallbackHandler, as set bysetCallbackHandler(javax.security.auth.callback.CallbackHandler)
Return theEgressFilter
, as set bysetEgressFilter(org.faceless.publisher.type.EgressFilter)
Return the modifiable Map of environment properties which is used to initialise the same value on anyReport
objects created by this factory.Return the ExecutorService as set bysetExecutorService(java.util.concurrent.ExecutorService)
Return the modifiable List of processing-instructions which is used to initialise the same value on anyReport
objects created by this factory.Return the Provider set bysetProvider(java.security.Provider)
Return theSecureRandom
object as set bysetRandom(java.security.SecureRandom)
Return theReferrerPolicy
as set bysetReferrerPolicy(org.faceless.publisher.type.ReferrerPolicy)
<T extends ReportFactoryExtension>
TgetReportFactoryExtension
(Class<T> clazz) Return the firstReportFactoryExtension
in the list returned bygetReportFactoryExtensions()
that is the specified class, or null if there is no matchReturn the list ofReportFactoryExtension
objects added to this Factory to extend functionality.<E> E
getResource
(URL2 uri, MediaType mediaType, Class<E> resourceClass) Load a resource, exactly as it would be loaded by a Report create from this factory.Return the cache used by this ReportFactory to cache objects like fonts, images etc. across multiple Reports.Return the modifiable list ofResourceLoader
objects which will be used to load any resources loaded by Reports created by this factory.Return theSAXParserFactory
, as set bysetSAXParserFactory(javax.xml.parsers.SAXParserFactory)
Return theSAXTransformerFactory
, as set bysetSAXTransformerFactory(javax.xml.transform.sax.SAXTransformerFactory)
Return the modifiable list ofURLConnectionFactory
objects which will be used to load any resources loaded by Reports created by this factory.Return the modifiable list ofURLConnectionProcessor
objects which will be used to load any resources loaded by Reports created by this factory.Return the modifiable List of URLs to "user-agent" styleshets, which is used to initialise the same value on anyReport
objects created by this factory.Return the modifiable List of URLs to "user" styleshets, which is used to initialise the same value on anyReport
objects created by this factory.static String
Return the BFO Publisher version number, which is set within the JarReturn the XPathFactory, as set bysetXPathFactory(javax.xml.xpath.XPathFactory)
static boolean
Return true if BFO Publisher is currently licensed, false if it's running the trial versionnewXMLReader
(MediaType mediaType, Map<String, Object> env) Return a newXMLReader
object for the specified content type.void
setBaseURL
(URL2 uri) Set the Base URL to resolve any relative URLs passed directly into theReport
class - specifically this is theReport.load(java.lang.Object)
method anduser
anduser-agent
stylesheet methods.void
setCacheSize
(int size) Set the number of Resources that can be help in theresource cache
.void
setCallbackHandler
(CallbackHandler handler) Set theCallbackHandler
which will be used as the default by any Reports created by this ReportFactory.void
setEgressFilter
(EgressFilter filter) Set theEgressFilter
which is used to initialise the same value on anyReport
objects created by this factory.void
setExecutorService
(ExecutorService executor) Set theExecutorService
to be used for any tasks run in separate threads during the parsing process, such as retrieval of network resources.static void
setLicenseKey
(String key) Set the license key for use with BFO Publishervoid
setProvider
(Provider provider) Set theProvider
to be used for any signature or encryption operations created by this factory.void
setRandom
(SecureRandom random) Set theSecureRandom
object to be used for any random numbers required during parsing - this is used mainly for network requests for resources.void
setReferrerPolicy
(ReferrerPolicy referrerPolicy) Set theReferrerPolicy
which is used to initialise the same value on anyReport
objects created by this factory.void
setSAXParserFactory
(SAXParserFactory factory) Set theSAXParserFactory
to be used by all Reports generated by this ReportFactoryvoid
Set theSAXTransformerFactory
to be used by all Reports generated by this ReportFactoryvoid
setXPathFactory
(XPathFactory factory) Set theXPathFactory
to be used by all Reports generated by this ReportFactory.
-
Constructor Details
-
ReportFactory
public ReportFactory()Create a new ReportFactory
-
-
Method Details
-
getVersion
Return the BFO Publisher version number, which is set within the Jar -
setCacheSize
public void setCacheSize(int size) Set the number of Resources that can be help in theresource cache
. The default is 200. -
getCacheSize
public int getCacheSize()Return the cache size as set bysetCacheSize(int)
- Returns:
- the cache-size
-
getResourceCache
Return the cache used by this ReportFactory to cache objects like fonts, images etc. across multiple Reports. The returned object will be used across multiple threads, so any access to it should be synchronized.- Returns:
- the cache.
-
getExecutorService
Return the ExecutorService as set bysetExecutorService(java.util.concurrent.ExecutorService)
- Returns:
- the ExecutorService
-
setExecutorService
Set theExecutorService
to be used for any tasks run in separate threads during the parsing process, such as retrieval of network resources. The default will return aCachedThreadPool
which creates threads that begin with "bfopub-". This is normally the bext choice, so should not need to be overridden- Parameters:
executor
- the ExecutorService to use for background threads, or null to use the default
-
setBaseURL
Set the Base URL to resolve any relative URLs passed directly into theReport
class - specifically this is theReport.load(java.lang.Object)
method anduser
anduser-agent
stylesheet methods. Relative URLs encounted during parsing are resolved against the document base URL (which may have been be derived from this)- Parameters:
uri
- the base URL to use, or null to leave them relative. The default value is null
-
getBaseURL
Return the Base URL as set bysetBaseURL(org.faceless.publisher.type.URL2)
- Returns:
- the Base URL
-
getRandom
Return theSecureRandom
object as set bysetRandom(java.security.SecureRandom)
- Returns:
- the SecureRandom object
-
setRandom
Set theSecureRandom
object to be used for any random numbers required during parsing - this is used mainly for network requests for resources. The default is the native non-blocking PRNG random generator, which is normally the best choice.- Parameters:
random
- theSecureRandom
to use, or null to use the default.
-
getCallbackHandler
Return the CallbackHandler, as set bysetCallbackHandler(javax.security.auth.callback.CallbackHandler)
- Returns:
- the CallbackHandler to use, which may be null
- See Also:
-
setCallbackHandler
Set theCallbackHandler
which will be used as the default by any Reports created by this ReportFactory. The default isnull
. The exact callbacks will depend on the type of authorization required but may include regularNameCallback
andPasswordCallback
for access to HTTP resources protected by Basic, Digest orAWS4
authentication, for access to KeyStores or (if configured) IMAP Mail Servers. It may also includeOAuth2Callback
callbacks if OAuth2 authentication is configured for access to HTTP or IMAP resources- Parameters:
handler
- the handler, which may be null- See Also:
-
getURLConnectionFactories
Return the modifiable list ofURLConnectionFactory
objects which will be used to load any resources loaded by Reports created by this factory. The list may be modified to add custom loaders. Null or duplicate entries will be ignored.- Returns:
- the list of
URLConnectionFactory
objects
-
getResourceLoaders
Return the modifiable list ofResourceLoader
objects which will be used to load any resources loaded by Reports created by this factory. The list may be modified to add custom loaders. Null or duplicate entries will be ignored. This method is unlikely to be useful for end users- Returns:
- the list of
ResourceLoader
objects
-
getURLConnectionProcessors
Return the modifiable list ofURLConnectionProcessor
objects which will be used to load any resources loaded by Reports created by this factory. The list may be modified to add custom processors. Null or duplicate entries will be ignored. -
getReportFactoryExtensions
Return the list ofReportFactoryExtension
objects added to this Factory to extend functionality. The returned list can be modified; but cannot have null or duplicate values added (doing so will throw an exception). Adding to or removing an item from the list will automatically call theReportFactoryExtension.register(org.faceless.publisher.ReportFactory)
orReportFactoryExtension.unregister(org.faceless.publisher.ReportFactory)
method on the extension.- Returns:
- the list of
ReportFactoryExtension
objects
-
getReportFactoryExtension
Return the firstReportFactoryExtension
in the list returned bygetReportFactoryExtensions()
that is the specified class, or null if there is no match- Since:
- 1.3
-
setSAXParserFactory
Set theSAXParserFactory
to be used by all Reports generated by this ReportFactory- Parameters:
factory
- the SAXParserFactory to use, or null to use the shared default
-
getSAXParserFactory
Return theSAXParserFactory
, as set bysetSAXParserFactory(javax.xml.parsers.SAXParserFactory)
- Returns:
- the SAXParserFactory used to create SAX parsers, which may be the shared default
- See Also:
-
setSAXTransformerFactory
Set theSAXTransformerFactory
to be used by all Reports generated by this ReportFactory- Parameters:
factory
- the SAXTransformerFactory to use, or null to use the shared default
-
getSAXTransformerFactory
Return theSAXTransformerFactory
, as set bysetSAXTransformerFactory(javax.xml.transform.sax.SAXTransformerFactory)
- Returns:
- the SAXTransformerFactory used to create SAX parsers, which may be the shared default
- See Also:
-
setXPathFactory
Set theXPathFactory
to be used by all Reports generated by this ReportFactory. XPath is currently only used by theXIncludeExtension
- Parameters:
factory
- the XPathFactory to use, or null to use the shared default
-
getXPathFactory
Return the XPathFactory, as set bysetXPathFactory(javax.xml.xpath.XPathFactory)
- Returns:
- the XPathFactory
- See Also:
-
getResource
Load a resource, exactly as it would be loaded by a Report create from this factory. This can be used to load any resources required for pre-processing, for example XSLT stylesheets.- Parameters:
uri
- the URL to load from (required)mediaType
- the mediaType to load from, which will be used if the type is not specified. May benull
resourceClass
- the type of object that will be returned from this method (required)- Returns:
- the resource, which will be of type E, or null if it could not be loaded
-
setEgressFilter
Set theEgressFilter
which is used to initialise the same value on anyReport
objects created by this factory. by this factory. The default value isEgressFilter.DEFAULT
which works essentialy as it does for browsers - documents loaded from "http" URLs cannot access the file-system, for example.- Parameters:
filter
- theEgressFilter
to use, or null to use the default.
-
getEgressFilter
Return theEgressFilter
, as set bysetEgressFilter(org.faceless.publisher.type.EgressFilter)
- Returns:
- the EgressFilter
-
setReferrerPolicy
Set theReferrerPolicy
which is used to initialise the same value on anyReport
objects created by this factory.- Parameters:
referrerPolicy
- the policy, or null to use the default- See Also:
-
getReferrerPolicy
Return theReferrerPolicy
as set bysetReferrerPolicy(org.faceless.publisher.type.ReferrerPolicy)
- Returns:
- the policy
-
getUserStylesheets
Return the modifiable List of URLs to "user" styleshets, which is used to initialise the same value on anyReport
objects created by this factory.- Returns:
- the list of stylesheet URLs
- See Also:
-
getUserAgentStylesheets
Return the modifiable List of URLs to "user-agent" styleshets, which is used to initialise the same value on anyReport
objects created by this factory.- Returns:
- the list of stylesheet URLs
- See Also:
-
getProcessingInstructions
Return the modifiable List of processing-instructions which is used to initialise the same value on anyReport
objects created by this factory.- See Also:
-
setProvider
Set theProvider
to be used for any signature or encryption operations created by this factory. If set to a not-null value, the Provider will be asked first for any resource, but if it is unable to provide one the default provider will be used as a fallback.- Parameters:
provider
- the Provider to use for anything cryptographic, or null to use the default
-
getProvider
Return the Provider set bysetProvider(java.security.Provider)
- Returns:
- the Provider
-
getEnvironment
Return the modifiable Map of environment properties which is used to initialise the same value on anyReport
objects created by this factory.- See Also:
-
createReport
Create a newReport
and intialize it to match the settings applied to this factory.- Returns:
- a new
Report
-
createReportOutput
Create a newReportOutput
that matches the specifiedMediaType
, or null if that type cannot be generated.- Parameters:
mediaType
- theMediaType
to target.- Returns:
- a new
ReportOutput
which matches the supplierMediaType
, or null if no matching output is known
-
newXMLReader
Return a newXMLReader
object for the specified content type. Calling this method is preferred over callingSAXParserFactory.newInstance().newSAXParser()
, as a) different factories will be used depending on the content-type, and b) the parser will be initialized to use the shared cache, XInclude handling and other features that would otherwise have to be configured manually.- Parameters:
mediaType
- the mediaType we want to create an XMLReader forenv
- any environment variables that may influence this (may be null)
-
setLicenseKey
Set the license key for use with BFO Publisher- Parameters:
key
- the key
-
isLicensed
public static boolean isLicensed()Return true if BFO Publisher is currently licensed, false if it's running the trial version
-