01: /*
02: * Copyright 2006 Pentaho Corporation. All rights reserved.
03: * This software was developed by Pentaho Corporation and is provided under the terms
04: * of the Mozilla Public License, Version 1.1, or any later version. You may not use
05: * this file except in compliance with the license. If you need a copy of the license,
06: * please go to http://www.mozilla.org/MPL/MPL-1.1.txt. The Original Code is the Pentaho
07: * BI Platform. The Initial Developer is Pentaho Corporation.
08: *
09: * Software distributed under the Mozilla Public License is distributed on an "AS IS"
10: * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. Please refer to
11: * the license for the specific language governing your rights and limitations.
12: */
13: package org.pentaho.plugin.jfreereport.outputs;
14:
15: import java.io.IOException;
16: import java.io.OutputStream;
17: import java.io.OutputStreamWriter;
18:
19: import org.jfree.report.JFreeReport;
20: import org.jfree.report.ReportProcessingException;
21: import org.jfree.report.modules.output.xml.XMLProcessor;
22: import org.pentaho.messages.Messages;
23:
24: /**
25: * Creation-Date: 07.07.2006, 20:42:17
26: *
27: * @author Thomas Morgner
28: */
29: public class JFreeReportXmlComponent extends
30: AbstractGenerateStreamContentComponent {
31: private static final long serialVersionUID = 8323789322309175815L;
32:
33: public JFreeReportXmlComponent() {
34: }
35:
36: protected String getMimeType() {
37: return "text/xml"; //$NON-NLS-1$
38: }
39:
40: protected String getExtension() {
41: return ".xml"; //$NON-NLS-1$
42: }
43:
44: protected boolean performExport(final JFreeReport report,
45: final OutputStream outputStream) {
46: try {
47: final XMLProcessor processor = new XMLProcessor(report);
48: final OutputStreamWriter writer = new OutputStreamWriter(
49: outputStream);
50: processor.setWriter(writer);
51: processor.processReport();
52:
53: writer.close();
54: close();
55: return true;
56: } catch (ReportProcessingException e) {
57: error(
58: Messages
59: .getString("JFreeReportXmlComponent.ERROR_0046_FAILED_TO_PROCESS_REPORT"), e); //$NON-NLS-1$
60: return false;
61: } catch (IOException e) {
62: error(
63: Messages
64: .getString("JFreeReportXmlComponent.ERROR_0046_FAILED_TO_PROCESS_REPORT"), e); //$NON-NLS-1$
65: return false;
66: }
67: }
68: }
|