Class Report
Represents a single Report, as created by ReportFactory.createReport()
.
At it's simplest the process of creating a Report looks like this:
ReportFactory factory = ReportFactory.getInstance();
// configure factory as appropriate
Report report = factory.createReport();
report.setReportOutput(output); // where do you want to send the report?
// other report configurations as required
report.load(...);
report.parse();
The various "load" methods can be used to parse the Report from a File or URL,
both of which will first configure the report with appropriate settings for that
content type (by adding styleshets, setting properties etc). Alternatively,
load(InputSource)
can be used if you want to configure the Report manually.
After the "load" method, the parse()
method is called to read from the
input and write the generated Report to the specified ReportOutput.
ContentHandler
, XMLReader
and InputSourec
can all be retrieved from this object if
the parse is to be run externally.-
Method Summary
Modifier and TypeMethodDescriptionvoid
addReportEventListener
(ReportEventListener listener) Add a listener for one or more events fired on the Report during the parse.void
fireReportEvent
(ReportEvent event) Fire a ReportEvent.Return the CallbackHandler, as set bysetCallbackHandler(javax.security.auth.callback.CallbackHandler)
Return the ContentHandler which will be used to parse.Return the egress filter set bysetEgressFilter(org.faceless.publisher.type.EgressFilter)
Get a map of environment properties that will be set on this Report.Return the InputSource which was set by theload(java.lang.Object)
methodReturn the Media-Type as set bysetMediaType()
, or as determined automatically by the parser.Return the list of processing instructions to be inserted before the start element of the document.Return the ReportFactory this Report was created fromReturn the ReportOutput, as set bysetReportOutput(org.faceless.publisher.output.ReportOutput)
getResource
(URL2 uri) Retrieve a Resource as it would be seen by this Report.getURL()
Return the URL as set bysetURL(org.faceless.publisher.type.URL2)
Return the list of URLConnectionFactory object which will be used by this Report before the standard ones set on theReportFactory.getURLConnectionFactories()
are checked.Return the list of "user-agent" Stylesheets to add to this Report.Return the list of "user" Stylesheets to add to this Report.Return the XMLReader that will be used by theparse()
method.void
Load the input from the specified object.void
parse()
Parse the content loaded withload(java.lang.Object)
.void
removeReportEventListener
(ReportEventListener listener) Remove a previously added listenervoid
setCallbackHandler
(CallbackHandler handler) Set theCallbackHandler
which will be used for authentication by this Reports.void
setContentHandler
(ContentHandler handler) Override the ContentHandler that will be used to parse.void
setEgressFilter
(EgressFilter filter) Set the EgressFilter to use for resources loaded by this Document.void
setMediaType
(MediaType mediaType) Set the Media-Type of the content.void
setReferrerPolicy
(ReferrerPolicy referrerPolicy) Set the "Referrer Policy" for the document.void
setReportOutput
(ReportOutput output) Set the ReportOutput to render the Report tovoid
Set the URL which this Report will be loaded from inload(java.lang.Object)
.void
setXMLReader
(SAXParser saxParser) Set the XMLReader to use when parsing the input set byload(java.lang.Object)
.void
setXMLReader
(XMLReader xmlReader) Set the XMLReader to use when parsing the input set byload(java.lang.Object)
.
-
Method Details
-
getReportFactory
Return the ReportFactory this Report was created from -
setReportOutput
Set the ReportOutput to render the Report to -
getReportOutput
Return the ReportOutput, as set bysetReportOutput(org.faceless.publisher.output.ReportOutput)
-
setReferrerPolicy
Set the "Referrer Policy" for the document. SeeReferrerPolicy
for details. -
getEnvironment
Get a map of environment properties that will be set on this Report. The map can be modified.- See Also:
-
addReportEventListener
public void addReportEventListener(ReportEventListener listener) Add a listener for one or more events fired on the Report during the parse. Listeners should have one or more methods that are annotated with theReportEventListener
annotation. -
removeReportEventListener
public void removeReportEventListener(ReportEventListener listener) Remove a previously added listener -
fireReportEvent
public void fireReportEvent(ReportEvent event) Fire a ReportEvent. This is called internally by the parse process, but may be called directly as well. -
getUserAgentStylesheets
Return the list of "user-agent" Stylesheets to add to this Report. The list can be modified- See Also:
-
getUserStylesheets
Return the list of "user" Stylesheets to add to this Report. The list can be modified- See Also:
-
getProcessingInstructions
Return the list of processing instructions to be inserted before the start element of the document. This list may be modified. -
getURLConnectionFactories
Return the list of URLConnectionFactory object which will be used by this Report before the standard ones set on theReportFactory.getURLConnectionFactories()
are checked. The list is initially empty, but can be modified to add a loader for resources specific to this Report - for example, to load from a particularZip file
, or to include login information specific to this report. The first item this list will be checked first. -
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 for authentication by this Reports. 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:
-
setMediaType
Set the Media-Type of the content. This value will be overriden by theContent-Type
header retrieved from the URL if set (which will only apply for HTTP and HTTPS).- Parameters:
mediaType
- the MediaType
-
getMediaType
Return the Media-Type as set bysetMediaType()
, or as determined automatically by the parser. May be WILDCARD but will never be null.- Returns:
- the MediaType
-
setURL
Set the URL which this Report will be loaded from inload(java.lang.Object)
. This doesn't do anything except make a note of the URL; no connection to the URL is made, and the URL itself is not used unless the object passed toload(java.lang.Object)
has no inherent URL of its own. For example, calling this beforeload(InputStream)
will cause any relative URLs within the InputStream to be resolved against this one. But calling this beforeload(URL2)
will have no effect, as the URL2 passed to load() will take precedence.- Parameters:
uri
- the URL
-
getURL
Return the URL as set bysetURL(org.faceless.publisher.type.URL2)
- Returns:
- the uri
-
setXMLReader
Set the XMLReader to use when parsing the input set byload(java.lang.Object)
. If null, the default is used.- Parameters:
xmlReader
- the XMLReader
-
setXMLReader
Set the XMLReader to use when parsing the input set byload(java.lang.Object)
. Simply callssetXMLReader(saxparser.getXMLReader())
- Parameters:
saxParser
- the SAXParser to retrieve the XMLReader from- Throws:
SAXException
-
getXMLReader
Return the XMLReader that will be used by theparse()
method. If this was set bysetXMLReader(org.xml.sax.XMLReader)
it will use that value, otherwise it will callReportFactory.newXMLReader(org.faceless.publisher.type.MediaType, java.util.Map<java.lang.String, java.lang.Object>)
- Returns:
- the XMLReader
- Throws:
SAXException
ParserConfigurationException
-
setContentHandler
Override the ContentHandler that will be used to parse. This method should be used only to set a filter on the existing ContentHandler if required; replacing the existing ContentHandler completely will result in the Report not being generated.
Note that if the supplied handler also impements
DTDHandler
,ErrorHandler
, orEntityResolver
, those interfaces will be applied before parsing.- Parameters:
handler
- the ContentHandler to receive the parsing events
-
getContentHandler
Return the ContentHandler which will be used to parse. This is set internally to the entry-point for the parsing process, although it can be overridden withsetContentHandler(org.xml.sax.ContentHandler)
- Returns:
- the contentHandler
-
load
Load the input from the specified object. Example object that can be passed in to this method include.
InputSource
URL
URI
URLConnection
URL2
InputStream
Reader
- byte[]
File
Path
CharSequence
/String
(will be parsed as a File if it exists, URL if possible or a UTF-8 byte stream otherwise)javax.mail.internet.MimeMessage
If the supplied object is an
InputSource
it will be processed directly. Otherwise the object will be converted to a URLConnection, and if headers are available the MediaType will be determined from the "Content-Type" header if set, falling back to thesetMediaType(org.faceless.publisher.type.MediaType)
if that is set and finally the type sniffed from the file contents and/or filename. An appropriateReportConfiguration
will then be applied to this Report, and the configuration should then load an appropriate InputSource.- Parameters:
o
- the object to load- Throws:
IOException
- if an exception is received when loading the source documentIllegalArgumentException
- if the object cannot be parsed
-
getInputSource
Return the InputSource which was set by theload(java.lang.Object)
method -
setEgressFilter
Set the EgressFilter to use for resources loaded by this Document. If not set when the theload(java.lang.Object)
method is called, it will automatically set the filter to aEgressFilter.DEFAULT
based on the System ID of the InputSource, which should be set (if possible) to the absolute URL of the source document.- Parameters:
filter
- the egress filter to use, or null to use the default.
-
getEgressFilter
Return the egress filter set bysetEgressFilter(org.faceless.publisher.type.EgressFilter)
-
parse
Parse the content loaded withload(java.lang.Object)
. This will set the ContentHandler (and, if applicable, DTDHandler, EntityResolver and ErrorHandler) on the XMLReader returned bygetXMLReader()
, then callxmlreader.parse(getInputSource())
. Call this method after load(). -
getResource
Retrieve a Resource as it would be seen by this Report. Can be used to extract the generated index by passing in "about:index", a generated stylesheet (eg "fonts:C:/Windows/Fonts") or any external resource to verify it's loading properly.- Parameters:
uri
- the URL of the Document to retrieve: typically "about:index";- Returns:
- an InputSource, or
null
if none exists.
-