com.jrefinery.report.io
Class ReportGenerator

java.lang.Object
  extended byorg.jfree.xml.ParserFrontend
      extended bycom.jrefinery.report.io.ReportGenerator

public class ReportGenerator
extends org.jfree.xml.ParserFrontend

The reportgenerator initializes the parser and provides an interface the the default parser. To create a report from an URL, use ReportGenerator.getInstance().parseReport (URL myURl, URL contentBase);

Author:
Thomas Morgner

Constructor Summary
protected ReportGenerator()
          Creates a new report generator.
 
Method Summary
static ReportGenerator getInstance()
          Returns a single shared instance of the ReportGenerator.
 void initFromSystem()
          Tries to initilialize the generator by reading the system property "com.jrefinery.report.dtd".
 JFreeReport parseReport(java.io.File file)
          Parses an XML file which is loaded using the given file.
 JFreeReport parseReport(org.xml.sax.InputSource input, java.net.URL contentBase)
          Parses an XML report template file.
 JFreeReport parseReport(java.lang.String file)
          Parses a report using the given parameter as filename and the directory containing the file as content base.
 JFreeReport parseReport(java.net.URL file)
          Parses an XML file which is loaded using the given URL.
 JFreeReport parseReport(java.net.URL file, java.net.URL contentBase)
          Parses an XML file which is loaded using the given URL.
 
Methods inherited from class org.jfree.xml.ParserFrontend
createDefaultHandler, getDefaultHandler, getEntityResolver, getParser, isValidateDTD, parse, parse, setDefaultHandler, setEntityResolver, setValidateDTD
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ReportGenerator

protected ReportGenerator()
Creates a new report generator. The generator uses the singleton pattern by default, so use generator.getInstance() to get the generator.

Method Detail

initFromSystem

public void initFromSystem()
Tries to initilialize the generator by reading the system property "com.jrefinery.report.dtd". This property should point to the dtd used for parsing.


parseReport

public JFreeReport parseReport(java.lang.String file)
                        throws java.io.IOException,
                               org.jfree.xml.ElementDefinitionException
Parses a report using the given parameter as filename and the directory containing the file as content base.

Parameters:
file - the file name.
Returns:
the report.
Throws:
java.io.IOException - if an I/O error occurs.
org.jfree.xml.ElementDefinitionException - if there is a problem parsing the report template.

parseReport

public JFreeReport parseReport(java.net.URL file)
                        throws org.jfree.xml.ElementDefinitionException,
                               java.io.IOException
Parses an XML file which is loaded using the given URL. All needed relative file- and resourcespecification are loaded using the URL file as base.

Parameters:
file - the URL for the report template file.
Returns:
the report.
Throws:
java.io.IOException - if an I/O error occurs.
org.jfree.xml.ElementDefinitionException - if there is a problem parsing the report template.

parseReport

public JFreeReport parseReport(java.net.URL file,
                               java.net.URL contentBase)
                        throws org.jfree.xml.ElementDefinitionException,
                               java.io.IOException
Parses an XML file which is loaded using the given URL. All needed relative file- and resourcespecification are loaded using the URL contentBase as base.

After the report is generated, the ReportDefinition-source and the contentbase are stored as string in the reportproperties.

Parameters:
file - the URL for the report template file.
contentBase - the URL for the report template content base.
Returns:
the parsed report.
Throws:
java.io.IOException - if an I/O error occurs.
org.jfree.xml.ElementDefinitionException - if there is a problem parsing the report template.

parseReport

public JFreeReport parseReport(java.io.File file)
                        throws java.io.IOException,
                               org.jfree.xml.ElementDefinitionException
Parses an XML file which is loaded using the given file. All needed relative file- and resourcespecification are loaded using the parent directory of the file file as base.

Parameters:
file - the report template file.
Returns:
the parsed report.
Throws:
java.io.IOException - if an I/O error occurs.
org.jfree.xml.ElementDefinitionException - if there is a problem parsing the report template.

parseReport

public JFreeReport parseReport(org.xml.sax.InputSource input,
                               java.net.URL contentBase)
                        throws org.jfree.xml.ElementDefinitionException
Parses an XML report template file.

Parameters:
input - the input source.
contentBase - the content base.
Returns:
the report.
Throws:
org.jfree.xml.ElementDefinitionException - if an error occurred.

getInstance

public static ReportGenerator getInstance()
Returns a single shared instance of the ReportGenerator.

Returns:
The shared report generator.