KickJava   Java API By Example, From Geeks To Geeks.

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


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
18 import org.jfree.report.JFreeReport;
19 import org.jfree.report.ReportProcessingException;
20 import org.jfree.report.modules.output.table.html.HtmlProcessor;
21 import org.jfree.report.modules.output.table.html.StreamHtmlFilesystem;
22 import org.pentaho.plugin.jfreereport.helper.YieldReportListener;
23
24 /**
25  * Creation-Date: 07.07.2006, 20:42:17
26  *
27  * @author Thomas Morgner
28  */

29 public class JFreeReportStreamHtmlComponent extends AbstractGenerateStreamContentComponent {
30     private static final long serialVersionUID = 7103996413736560262L;
31
32     public JFreeReportStreamHtmlComponent() {
33     }
34
35     protected String JavaDoc getMimeType() {
36         return "text/html"; //$NON-NLS-1$
37
}
38
39     protected String JavaDoc getExtension() {
40         return ".html"; //$NON-NLS-1$
41
}
42
43     protected boolean performExport(final JFreeReport report, final OutputStream JavaDoc outputStream) {
44         try {
45             HtmlProcessor processor = new HtmlProcessor(report);
46             processor.setFilesystem(new StreamHtmlFilesystem(outputStream));
47             final int yieldRate = getYieldRate();
48             if (yieldRate > 0) {
49                 processor.addRepaginationListener(new YieldReportListener(yieldRate));
50             }
51             processor.processReport();
52             outputStream.flush();
53             return true;
54         } catch (ReportProcessingException e) {
55             return false;
56         } catch (IOException JavaDoc e) {
57             return false;
58         }
59     }
60 }
61
Popular Tags