KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > pentaho > plugin > jfreereport > outputs > JFreeReportXmlComponent


1 /*
2  * Copyright 2006 Pentaho Corporation. All rights reserved.
3  * This software was developed by Pentaho Corporation and is provided under the terms
4  * of the Mozilla Public License, Version 1.1, or any later version. You may not use
5  * this file except in compliance with the license. If you need a copy of the license,
6  * please go to http://www.mozilla.org/MPL/MPL-1.1.txt. The Original Code is the Pentaho
7  * BI Platform. The Initial Developer is Pentaho Corporation.
8  *
9  * 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 JavaDoc;
16 import java.io.OutputStream JavaDoc;
17 import java.io.OutputStreamWriter JavaDoc;
18
19 import org.jfree.report.JFreeReport;
20 import org.jfree.report.ReportProcessingException;
21 import org.jfree.report.modules.output.xml.XMLProcessor;
22
23 /**
24  * Creation-Date: 07.07.2006, 20:42:17
25  *
26  * @author Thomas Morgner
27  */

28 public class JFreeReportXmlComponent extends AbstractGenerateStreamContentComponent {
29     private static final long serialVersionUID = 8323789322309175815L;
30
31     public JFreeReportXmlComponent() {
32     }
33
34     protected String JavaDoc getMimeType() {
35         return "text/xml"; //$NON-NLS-1$
36
}
37
38     protected String JavaDoc getExtension() {
39         return ".xml"; //$NON-NLS-1$
40
}
41
42     protected boolean performExport(final JFreeReport report, final OutputStream JavaDoc outputStream) {
43         try {
44             XMLProcessor processor = new XMLProcessor(report);
45             OutputStreamWriter JavaDoc writer = new OutputStreamWriter JavaDoc(outputStream);
46             processor.setWriter(writer);
47             processor.processReport();
48             writer.close();
49             return true;
50         } catch (ReportProcessingException e) {
51             return false;
52         } catch (IOException JavaDoc e) {
53             return false;
54         }
55     }
56 }
57
Popular Tags