net.windward.xmlreport
Class ProcessHtml

java.lang.Object
  |
  +--net.windward.xmlreport.ProcessReport
        |
        +--net.windward.xmlreport.ProcessHtml
All Implemented Interfaces:
ProcessHtmlAPI, ProcessReportAPI, ProcessReportAPIBase

public class ProcessHtml
extends ProcessReport
implements ProcessHtmlAPI

This class is the main program that takes a template stream and a datasource and merges them to create an html report stream. The way to use this is to construct a ProcessRtf object, set any options, then call process.
Images are separate files for html. So this object has a list of HtmlImage objects, one for each image in the report document. (Note: in the case of an image inside a while/end, it does not create multiple image files for each iteration. The same file is used each time the image is rendered in the report). These HtmlImage objects can either be streams that get the image as it is rendered, or they can be file names of the images that are already written to the hard disk.
So you can pass in these objects beforehand giving the filename, and optionally a stream to write the image to. And after the report is processed, the same objects will now have the filenames (if they were not set before the call) and the streams will hold the image file data (if set).
The calling method must close all streams after calling process. process will flush the output (report) stream before returning.

Version:
2.0 2 January 2004

Fields inherited from class net.windward.xmlreport.ProcessReport
TEMPLATE_TYPE_DOCX, TEMPLATE_TYPE_RTF, TEMPLATE_TYPE_UNKNOWN, TEMPLATE_TYPE_WORD_11, TEMPLATE_TYPE_XLSX
 
Fields inherited from interface net.windward.xmlreport.ProcessHtmlAPI
CSS_EXISTS, CSS_INCLUDE, CSS_NO, CSS_SEPARATE, DHTML, HTML_2, HTML_4_1, IE5, IE5_5, IE6, NN4, NN6_1, OP5, XHTML
 
Fields inherited from interface net.windward.xmlreport.ProcessReportAPI
CHARSET_DEFAULT, CHARSET_RTF, CHARSET_UNICODE, LOCALE_DEFAULT, LOCALE_SYSTEM, TYP_DOCX, TYP_EXCEL_ML, TYP_HTML, TYP_PDF, TYP_RTF, TYP_TXT, TYP_WORD_ML, TYP_XLS, TYP_XLSX
 
Constructor Summary
ProcessHtml(java.io.InputStream rtfTemplate)
          Create a ProcessHtml object with the passed in template.
ProcessHtml(java.io.InputStream xmlData, java.io.InputStream rtfTemplate, java.io.OutputStream report)
          Create a ProcessReport object with the passed in template & data streams, writing it to the passed in report stream.
ProcessHtml(java.io.InputStream rtfTemplate, java.io.OutputStream report)
          Create a ProcessHtml object with the passed in template, writing it to the passed in report stream.
 
Method Summary
 void addImageName(HtmlImage img)
          Set a single image name.
 void addImageNames(java.util.ArrayList imgs)
          Set several image names.
 ProcessReportAPIBase duplicate(java.io.OutputStream out)
          Creates and returns a copy of this object.
 ProcessHtmlAPI duplicate(java.io.OutputStream out, java.io.OutputStream cssStream)
          Creates and returns a copy of this object.
 java.lang.String getCssFilename()
          Returns the css filename.
 java.io.OutputStream getCssStream()
          Returns the css stream.
 int getCssType()
          Returns if the css information will be written to a separate file, as part of the html file, or skipped (because the file already exists).
 java.lang.String getFilePath()
          Get the path that all images will be saved to on the disk.
 java.lang.String getFilePrefix()
          Get the prefix that will be part of the filename of all images saved to disk and listed in the html file.
 java.lang.String getHtmlPath()
          Get the path that all images will be prefixed with in the html file.
 java.util.ArrayList getImageNames()
          Get the image names/streams for the images in a report.
 int getReportType()
          Get the report format of the output stream.
 int getSpec()
          Gets the spec that the produced report must run under.
 boolean isFullFile()
          The report can be generated as either a complete html file, or as just the body.
 boolean isIE()
          Returns true if the spec is set to a version of Internet Explorer.
 boolean isNetscape()
          Returns true if the spec is set to a version of Netscape.
 boolean isOpera()
          Returns true if the spec is set to a version of Opera
 void process()
          Create a report from the input (xml & rtf) streams, writing it to the output (report) stream.
 void setCss(int cssMethod, java.io.OutputStream cssStream, java.lang.String cssFileName)
          Sets if the css information will be written to a separate file, as part of the html file, or skipped (because the file already exists).
 void setFullFile(boolean fullDoc)
          The report can be generated as either a complete html file, or as just the body.
 void setImagePath(java.lang.String file, java.lang.String html, java.lang.String prefix)
          Set a path that all images will be saved to.
 void setSpec(int spec)
          Sets the spec that the produced report must run under.
 
Methods inherited from class net.windward.xmlreport.ProcessReport
addBean, close, dispose, getBaseDirectory, getCharset, getChartProvider, getCompany, getImportingProvider, getInfo, getKeywords, getLocale, getNumPages, getReport, getSubject, getTitle, getVersion, getVersionMajor, getVersionMinor, getVersionRelease, init, isDebugMode, processComplete, processData, processSetup, processSetup, setBaseDirectory, setCharset, setChartProvider, setDebugMode, setKeywords, setLocale, setSubject, setTitle, statLine
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface net.windward.xmlreport.ProcessReportAPI
setChartProvider
 
Methods inherited from interface net.windward.xmlreport.ProcessReportAPIBase
addBean, close, getBaseDirectory, getCharset, getInfo, getKeywords, getLocale, getNumPages, getReport, getSubject, getTitle, isDebugMode, processComplete, processData, processSetup, processSetup, setBaseDirectory, setCharset, setDebugMode, setKeywords, setLocale, setSubject, setTitle
 

Constructor Detail

ProcessHtml

public ProcessHtml(java.io.InputStream rtfTemplate)
            throws LicenseException,
                   SetupException
Create a ProcessHtml object with the passed in template. Objects created with this constructor must call processSetup, processData, and processComplete. Objects created with this constructor cannot call process. The report will be in the html format.
Parameters:
rtfTemplate - The report template, as a rtf document.
Throws:
LicenseException - thrown if the license licenseKey check fails. The message will list the license check that failed.

ProcessHtml

public ProcessHtml(java.io.InputStream rtfTemplate,
                   java.io.OutputStream report)
            throws LicenseException,
                   SetupException
Create a ProcessHtml object with the passed in template, writing it to the passed in report stream. Objects created with this constructor must call processSetup, processData, and processComplete. Objects created with this constructor cannot call process. The report will be in the html format.
Parameters:
rtfTemplate - The report template, as a rtf document.
report - The stream to write the report to.
Throws:
LicenseException - thrown if the license licenseKey check fails. The message will list the license check that failed.

ProcessHtml

public ProcessHtml(java.io.InputStream xmlData,
                   java.io.InputStream rtfTemplate,
                   java.io.OutputStream report)
            throws java.lang.IllegalArgumentException,
                   DataSourceException,
                   LicenseException,
                   SetupException
Create a ProcessReport object with the passed in template & data streams, writing it to the passed in report stream. The report will be in the html format.
Parameters:
xmlData - The xml data that will be placed into the report where there are xml elements.
rtfTemplate - The report template, as a rtf document.
report - The stream to write the report to.
Throws:
java.lang.IllegalArgumentException - Thrown if an illegal spec value is passed in.
DataSourceException - thrown if there is a problem with the datasource.
LicenseException - thrown if the license licenseKey check fails. The message will list the license check that failed.
Method Detail

duplicate

public ProcessReportAPIBase duplicate(java.io.OutputStream out)
                               throws AlreadyProcessedException,
                                      LicenseException,
                                      SetupException
Creates and returns a copy of this object. You may call this before or after calling processData(). You may then call processData() on the created object. You must call this after calling processSetup() and before calling processComplete(). While this mostly does a deep copy, it does not do a deep copy of bean objects or image data. This will always return a ProcessHtml object.
Specified by:
duplicate in interface ProcessReportAPIBase
Parameters:
out - The stream to write the report to. If null will create a ByteArrayOutputStream.
Throws:
AlreadyProcessedException - thrown if call the process steps out of order or call ones other than data twice.
LicenseException - thrown if the license licenseKey check fails. The message will list the license check that failed.

duplicate

public ProcessHtmlAPI duplicate(java.io.OutputStream out,
                                java.io.OutputStream cssStream)
                         throws AlreadyProcessedException,
                                LicenseException,
                                SetupException
Creates and returns a copy of this object. You may call this before or after calling processData(). You may then call processData() on the created object. You must call this after calling processSetup() and before calling processComplete(). While this mostly does a deep copy, it does not do a deep copy of bean objects or image data. This will always return a ProcessHtml object.
Specified by:
duplicate in interface ProcessHtmlAPI
Parameters:
out - The stream to write the report to. If null will create a ByteArrayOutputStream.
cssStream - The css stream to write to. Can be null.
Throws:
AlreadyProcessedException - thrown if call the process steps out of order or call ones other than data twice.
LicenseException - thrown if the license licenseKey check fails. The message will list the license check that failed.

process

public void process()
             throws LicenseException,
                    java.io.IOException,
                    net.windward.format.TemplateParseException,
                    java.lang.IllegalArgumentException,
                    TagException,
                    AlreadyProcessedException,
                    DataSourceException,
                    BeanProviderException
Create a report from the input (xml & rtf) streams, writing it to the output (report) stream. This should only be called once for a given ProcessReport object!
Specified by:
process in interface ProcessReportAPIBase
Overrides:
process in class ProcessReport
Throws:
java.io.IOException - thrown if have problems accessing the xml, template, or report streams.
LicenseException - thrown if called too often for the license type.
java.lang.IllegalArgumentException - thrown if come across an unknown element type or an illegal reportType value is used.
TagException - thrown if there is an unmatched if/while - end. Not thrown in debug mode.
AlreadyProcessedException - thrown if call process multiple times on an object.

isIE

public boolean isIE()
Returns true if the spec is set to a version of Internet Explorer.
Returns:
true if building for IE, false otherwise.

isNetscape

public boolean isNetscape()
Returns true if the spec is set to a version of Netscape.
Returns:
true if building for Netscape, false otherwise.

isOpera

public boolean isOpera()
Returns true if the spec is set to a version of Opera
Returns:
true if building for Opera, false otherwise.

getReportType

public int getReportType()
Get the report format of the output stream.
Specified by:
getReportType in interface ProcessHtmlAPI
Returns:
The type (format) of the output report. Will be TYP_HTML.

addImageName

public void addImageName(HtmlImage img)
Set a single image name. If there are no images, this is it. If there are already images, this adds this name to the end of the list. This method can only be called before processing a report.
Specified by:
addImageName in interface ProcessHtmlAPI
Parameters:
img - The image to add to the list of images for this file.
Throws:
java.lang.IllegalArgumentException - Thrown if addImageName(s) already called

addImageNames

public void addImageNames(java.util.ArrayList imgs)
Set several image names. If there are no images, this is it. If there are already images, this adds these to the end of the list. This method can only be called before processing a report.
Specified by:
addImageNames in interface ProcessHtmlAPI
Parameters:
imgs - The images to add to the list of images for this file.
Throws:
java.lang.IllegalArgumentException - Thrown if addImageName(s) already called

setImagePath

public void setImagePath(java.lang.String file,
                         java.lang.String html,
                         java.lang.String prefix)
Set a path that all images will be saved to. All images will be written to the disk as they are read from the template. If this is called, you may not also call addImageName. You can however after processing call getImageNames and the filenames will be in there (but not the streams).
The path can be just a series of folders like "c:/dir1/dir2/" or it can include the begining of the filename like "c:/dir1/dir2/tmp". The first will create the file "c:/dir1/dir2/00001.jpg" while the second will create the file "c:/dir1/dir2/tmp00001.jpg".
Note: file and prefix should not end with a /
Note: as Windward Reports has no idea when the created file is no longer needed, it will not delete any files created.
Note: The path seperator should be /, not \ (to work on unix and windows).
Specified by:
setImagePath in interface ProcessHtmlAPI
Parameters:
file - The path of the file on the disk relative to the default directory of your program.
html - The path of the file relative to the default directory of the client browser.
prefix - The prefix to use when creating the filename. This can be null.
Throws:
java.lang.IllegalArgumentException - Thrown if addImageName(s) already called

getFilePath

public java.lang.String getFilePath()
Get the path that all images will be saved to on the disk. The path can be just a series of folders like "c:/dir1/dir2/" or it can include the begining of the filename like "c:/dir1/dir2/tmp". The first should be used to create the file "c:/dir1/dir2/00001.jpg" while the second to create the file "c:/dir1/dir2/tmp00001.jpg".
Note: as Windward Reports has no idea when the created file is no longer needed, it will not delete any files created.
Specified by:
getFilePath in interface ProcessHtmlAPI

getHtmlPath

public java.lang.String getHtmlPath()
Get the path that all images will be prefixed with in the html file. The path can be just a series of folders like "c:/dir1/dir2/" or it can include the begining of the filename like "c:/dir1/dir2/tmp". The first should be used to include the file "c:/dir1/dir2/00001.jpg" while the second to include the file "c:/dir1/dir2/tmp00001.jpg".
Specified by:
getHtmlPath in interface ProcessHtmlAPI

getFilePrefix

public java.lang.String getFilePrefix()
Get the prefix that will be part of the filename of all images saved to disk and listed in the html file. In this case the file will be "c:/dir1/dir2/tmp00001.jpg" where tmp is the prefix.
Specified by:
getFilePrefix in interface ProcessHtmlAPI

getImageNames

public java.util.ArrayList getImageNames()
Get the image names/streams for the images in a report. This method can only be called after processing a report. This will have an entry for every image in the template. However, if Windward Reports is naming the files and/or creating the OutputStream then images that are not needed in the final report will have a filename of "" and an OutputStream size of 0.
Specified by:
getImageNames in interface ProcessHtmlAPI
Returns:
The images for this report.

setFullFile

public void setFullFile(boolean fullDoc)
The report can be generated as either a complete html file, or as just the body. If it is set to full file, the report will have everything from <html> to </html>. If not set, it will be a body, and can be included with additional html as just part of the body of a final html file. In this case the returned stream must be placed inside a <body>...</body>. Default is true.
Specified by:
setFullFile in interface ProcessHtmlAPI
Parameters:
fullDoc - Set to true to return a complete html file, false otherwise.

isFullFile

public boolean isFullFile()
The report can be generated as either a complete html file, or as just the body. If it is set to full file, the report will have everything from <html> to </html>. If not set, it will be a body, and can be included with additional html as just part of the body of a final html file. In this case the returned stream must be placed inside a <body>...</body>. Default is true.
Specified by:
isFullFile in interface ProcessHtmlAPI
Returns:
true if will return a complete html file, false otherwise.

setCss

public void setCss(int cssMethod,
                   java.io.OutputStream cssStream,
                   java.lang.String cssFileName)
            throws java.lang.IllegalArgumentException
Sets if the css information will be written to a separate file, as part of the html file, or skipped (because the file already exists). Default is CSS_NO.
Specified by:
setCss in interface ProcessHtmlAPI
Parameters:
cssMethod - Must be one of the values CSS_NO, CSS_INCLUDE, CSS_SEPARATE, or CSS_EXISTS.
cssStream - The stream to write the css file to. This can (and must) only be set if cssMethod is CSS_SEPARATE. This file will always be the same every time a given template is run so it can be generated the first time and just reused without being regenerated after that.
cssFileName - The name of the file when cssMethod is CSS_SEPARATE or CSS_EXISTS. This is only needed if the report will write the full file. Set to "" or null for other methods.
Throws:
java.lang.IllegalArgumentException - Thrown if an illegal reportType value is passed in.

getCssType

public int getCssType()
Returns if the css information will be written to a separate file, as part of the html file, or skipped (because the file already exists). Default is CSS_NO.
Specified by:
getCssType in interface ProcessHtmlAPI
Returns:
Will be one of the values CSS_NO, CSS_INCLUDE, CSS_SEPARATE, or CSS_EXISTS.

getCssFilename

public java.lang.String getCssFilename()
Returns the css filename. Null if there is no separate css file.
Specified by:
getCssFilename in interface ProcessHtmlAPI
Returns:
The css filename.

getCssStream

public java.io.OutputStream getCssStream()
Returns the css stream. Null if not CSS_SEPARATE.
Specified by:
getCssStream in interface ProcessHtmlAPI
Returns:
The css stream.

setSpec

public void setSpec(int spec)
             throws java.lang.IllegalArgumentException
Sets the spec that the produced report must run under. The produced report will not use any html tags that are not supported by the set spec. Default is HTML_4_1.
Specified by:
setSpec in interface ProcessHtmlAPI
Parameters:
spec - Must be one of the spec final int's from this class: HTML*, NN*, IE*, ...
Throws:
java.lang.IllegalArgumentException - Thrown if an illegal spec value is passed in.

getSpec

public int getSpec()
Gets the spec that the produced report must run under. The produced report will not use any html tags that are not supported by this spec. Default is HTML_4_1.
Specified by:
getSpec in interface ProcessHtmlAPI
Returns:
Will be one of the spec final int's from this class: HTML*, NN*, IE*, ...


Copyright © 2002 - 2008 Windward Reports - All Rights Reserved. java reporting software