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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionCreate a newReportand intialize it to match the settings applied to this factory.createReportOutput(MediaType mediaType) Create a newReportOutputthat matches the specifiedMediaType, or null if that type cannot be generated.Return the Base URL as set bysetBaseURL(org.faceless.publisher.type.URL2)intReturn the cache size as set bysetCacheSize(int)Return the CallbackHandler, as set bysetCallbackHandler(javax.security.auth.callback.CallbackHandler)Return theDocumentBuilderFactory, as set bysetDocumentBuilderFactory(javax.xml.parsers.DocumentBuilderFactory)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 anyReportobjects 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 anyReportobjects created by this factory.Return the Provider set bysetProvider(java.security.Provider)Return theSecureRandomobject as set bysetRandom(java.security.SecureRandom)Return theReferrerPolicyas set bysetReferrerPolicy(org.faceless.publisher.type.ReferrerPolicy)<T extends ReportFactoryExtension>
TgetReportFactoryExtension(Class<T> clazz) Return the firstReportFactoryExtensionin the list returned bygetReportFactoryExtensions()that is the specified class, or null if there is no matchReturn the list ofReportFactoryExtensionobjects added to this Factory to extend functionality.<E> EgetResource(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 ofResourceLoaderobjects 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 ofURLConnectionFactoryobjects which will be used to load any resources loaded by Reports created by this factory.Return the modifiable list ofURLConnectionProcessorobjects 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 anyReportobjects created by this factory.Return the modifiable List of URLs to "user" styleshets, which is used to initialise the same value on anyReportobjects created by this factory.static StringReturn the BFO Publisher version number, which is set within the JarReturn the XPathFactory, as set bysetXPathFactory(javax.xml.xpath.XPathFactory)static booleanReturn true if BFO Publisher is currently licensed, false if it's running the trial versionnewXMLReader(MediaType mediaType, Map<String, Object> env) Return a newXMLReaderobject for the specified content type.voidsetBaseURL(URL2 uri) Set the Base URL to resolve any relative URLs passed directly into theReportclass - specifically this is theReport.load(java.lang.Object)method anduseranduser-agentstylesheet methods.voidsetCacheSize(int size) Set the number of Resources that can be help in theresource cache.voidsetCallbackHandler(CallbackHandler handler) Set theCallbackHandlerwhich will be used as the default by any Reports created by this ReportFactory.voidSet theDocumentBuilderFactoryto be used by all Reports generated by this ReportFactory.voidsetEgressFilter(EgressFilter filter) Set theEgressFilterwhich is used to initialise the same value on anyReportobjects created by this factory.voidsetExecutorService(ExecutorService executor) Set theExecutorServiceto be used for any tasks run in separate threads during the parsing process, such as retrieval of network resources.static voidsetLicenseKey(String key) Set the license key for use with BFO PublishervoidsetProvider(Provider provider) Set theProviderto be used for any signature or encryption operations created by this factory.voidsetRandom(SecureRandom random) Set theSecureRandomobject to be used for any random numbers required during parsing - this is used mainly for network requests for resources.voidsetReferrerPolicy(ReferrerPolicy referrerPolicy) Set theReferrerPolicywhich is used to initialise the same value on anyReportobjects created by this factory.voidsetSAXParserFactory(SAXParserFactory factory) Set theSAXParserFactoryto be used by all Reports generated by this ReportFactory.voidSet theSAXTransformerFactoryto be used by all Reports generated by this ReportFactory The factory will have flags set on it that reflect the current environment, so any flags that need to be set manually on the factory should be set after this method is called.voidsetXPathFactory(XPathFactory factory) Set theXPathFactoryto 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 theExecutorServiceto be used for any tasks run in separate threads during the parsing process, such as retrieval of network resources. The default will return aCachedThreadPoolwhich 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 theReportclass - specifically this is theReport.load(java.lang.Object)method anduseranduser-agentstylesheet 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 theSecureRandomobject as set bysetRandom(java.security.SecureRandom)- Returns:
- the SecureRandom object
-
setRandom
Set theSecureRandomobject 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- theSecureRandomto 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 theCallbackHandlerwhich 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 regularNameCallbackandPasswordCallbackfor access to HTTP resources protected by Basic, Digest orAWS4authentication, for access to KeyStores or (if configured) IMAP Mail Servers. It may also includeOAuth2Callbackcallbacks if OAuth2 authentication is configured for access to HTTP or IMAP resources- Parameters:
handler- the handler, which may be null- See Also:
-
setReferrerPolicy
Set theReferrerPolicywhich is used to initialise the same value on anyReportobjects created by this factory.- Parameters:
referrerPolicy- the policy, or null to use the default- See Also:
-
getReferrerPolicy
Return theReferrerPolicyas set bysetReferrerPolicy(org.faceless.publisher.type.ReferrerPolicy)- Returns:
- the policy
-
getURLConnectionFactories
Return the modifiable list ofURLConnectionFactoryobjects 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
URLConnectionFactoryobjects
-
getResourceLoaders
Return the modifiable list ofResourceLoaderobjects 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
ResourceLoaderobjects
-
getURLConnectionProcessors
Return the modifiable list ofURLConnectionProcessorobjects 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 ofReportFactoryExtensionobjects 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
ReportFactoryExtensionobjects
-
getReportFactoryExtension
Return the firstReportFactoryExtensionin the list returned bygetReportFactoryExtensions()that is the specified class, or null if there is no match- Since:
- 1.3
-
getSAXParserFactory
Return theSAXParserFactory, as set bysetSAXParserFactory(javax.xml.parsers.SAXParserFactory)- Returns:
- the SAXParserFactory used to create SAX parsers.
- See Also:
-
getDocumentBuilderFactory
Return theDocumentBuilderFactory, as set bysetDocumentBuilderFactory(javax.xml.parsers.DocumentBuilderFactory)- Returns:
- the DocumentBuilderFactory used to create DocumentBuilders.
- See Also:
-
getSAXTransformerFactory
Return theSAXTransformerFactory, as set bysetSAXTransformerFactory(javax.xml.transform.sax.SAXTransformerFactory)- Returns:
- the SAXTransformerFactory used to create SAX parsers, or null if none is available
- See Also:
-
getXPathFactory
Return the XPathFactory, as set bysetXPathFactory(javax.xml.xpath.XPathFactory)- Returns:
- the XPathFactory, or null if none is available
- See Also:
-
setSAXParserFactory
Set theSAXParserFactoryto be used by all Reports generated by this ReportFactory. The factory will have flags set on it that reflect the current environment, so any flags that need to be set manually on the factory should be set after this method is called.- Parameters:
factory- the SAXParserFactory to use (must not be null)
-
setDocumentBuilderFactory
Set theDocumentBuilderFactoryto be used by all Reports generated by this ReportFactory. The factory will have flags set on it that reflect the current environment, so any flags that need to be set manually on the factory should be set after this method is called.- Parameters:
factory- the DocumentBuilder to use (must not be null)
-
setSAXTransformerFactory
Set theSAXTransformerFactoryto be used by all Reports generated by this ReportFactory The factory will have flags set on it that reflect the current environment, so any flags that need to be set manually on the factory should be set after this method is called.- Parameters:
factory- the SAXTransformerFactory to use (must not be null)
-
setXPathFactory
Set theXPathFactoryto be used by all Reports generated by this ReportFactory. The factory will have flags set on it that reflect the current environment, so any flags that need to be set manually on the factory should be set after this method is called. XPath is currently only used by theXIncludeExtension- Parameters:
factory- the XPathFactory to use (must not be null)
-
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 benullresourceClass- 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 theEgressFilterwhich is used to initialise the same value on anyReportobjects created by this factory. by this factory. The default value isEgressFilter.DEFAULTwhich works essentialy as it does for browsers - documents loaded from "http" URLs cannot access the file-system, for example.- Parameters:
filter- theEgressFilterto use, or null to use the default.
-
getEgressFilter
Return theEgressFilter, as set bysetEgressFilter(org.faceless.publisher.type.EgressFilter)- Returns:
- the EgressFilter
-
getUserStylesheets
Return the modifiable List of URLs to "user" styleshets, which is used to initialise the same value on anyReportobjects 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 anyReportobjects 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 anyReportobjects created by this factory.- See Also:
-
setProvider
Set theProviderto 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 anyReportobjects created by this factory.- See Also:
-
createReport
Create a newReportand intialize it to match the settings applied to this factory.- Returns:
- a new
Report
-
createReportOutput
Create a newReportOutputthat matches the specifiedMediaType, or null if that type cannot be generated.- Parameters:
mediaType- theMediaTypeto target.- Returns:
- a new
ReportOutputwhich matches the supplierMediaType, or null if no matching output is known
-
newXMLReader
Return a newXMLReaderobject 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
-