org.jfree.report.modules.output.xml
public class: XMLProcessor [javadoc |
source]
java.lang.Object
org.jfree.report.modules.output.xml.XMLProcessor
The XMLProcessor coordinates the report processing for the XML-Output. This
class is responsible to initialize and maintain the XMLWriter, which performs
the output process.
The XMLProcessor is not intended to produce complex output, it is an
educational example. If you want valid xml data enriched with layouting
information, then have a look at the HTML-OutputTarget, this target is also
able to write XHTMl code.
| Constructor: |
public XMLProcessor(JFreeReport report) throws ReportProcessingException {
if (report == null)
{
throw new NullPointerException();
}
try
{
this.report = (JFreeReport) report.clone();
}
catch (CloneNotSupportedException cne)
{
throw new ReportProcessingException("Initial Clone of Report failed");
}
}
Creates a new XMLProcessor. The processor will output the report as simple
xml stream. Parameters:
report - the report that should be processed
Throws:
ReportProcessingException - if the report could not be initialized
|
| Method from org.jfree.report.modules.output.xml.XMLProcessor Detail: |
protected JFreeReport getReport() {
return report;
}
Returns the XMLProcessors local report instance. This instance has the
XMLWriter attached and should be used outside of this class. |
public Writer getWriter() {
return writer;
}
Returns the writer, which will receive the generated output. |
protected static boolean isStrictErrorHandling(Configuration config) {
final String strictError = config.getConfigProperty(JFreeReportCoreModule.STRICT_ERROR_HANDLING_KEY);
return "true".equals(strictError);
}
Checks whether report processing should be aborted when an exception
occurs. |
public void processReport() throws ReportProcessingException {
if (writer == null)
{
throw new IllegalStateException("No writer defined");
}
try
{
ProcessState state = repaginate();
final XMLWriter w = (XMLWriter) state.getLayoutProcess().getOutputFunction();
w.setWriter(getWriter());
final boolean failOnError = isStrictErrorHandling
(getReport().getReportConfiguration());
final ReportProcessingErrorHandler errorHandler = new CollectingReportErrorHandler();
state.setErrorHandler(errorHandler);
while (!state.isFinish())
{
final ProcessState nextState = state.advance();
state.setErrorHandler(IgnoreEverythingReportErrorHandler.INSTANCE);
state = nextState.commit();
if (errorHandler.isErrorOccured() == true)
{
final List childExceptions = Arrays.asList(errorHandler.getErrors());
errorHandler.clearErrors();
if (failOnError)
{
throw new ReportEventException("Failed to dispatch an event.", childExceptions);
}
else
{
final ReportEventException exception =
new ReportEventException("Failed to dispatch an event.", childExceptions);
XMLProcessor.logger.error("Failed to dispatch an event.", exception);
}
}
// if (!state.isFinish())
// {
// if (!state.isProceeding(progress))
// {
// throw new ReportProcessingException("State did not proceed, bailing out!");
// }
// }
}
}
catch (CloneNotSupportedException cne)
{
throw new ReportProcessingException("StateCopy was not supported");
}
finally
{
activeDataFactory.close();
activeDataFactory = null;
}
}
Processes the report. The generated output is written using the defined
writer, the report is repaginated before the final writing. |
public void setWriter(Writer writer) {
this.writer = writer;
}
Sets the writer, which will receive the generated output. The writer should
have the proper encoding set. |