KickJava   Java API By Example, From Geeks To Geeks.

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


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.ZIPHtmlFilesystem;
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 JFreeReportZipHtmlComponent extends AbstractGenerateStreamContentComponent {
30     private static final long serialVersionUID = -3904516365257691828L;
31
32     public JFreeReportZipHtmlComponent() {
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             String JavaDoc dataDirectory = getInputStringValue(REPORTDIRECTORYHTML_DATADIR);
46             if (dataDirectory == null) {
47                 dataDirectory = "data"; //$NON-NLS-1$
48
}
49
50             HtmlProcessor processor = new HtmlProcessor(report);
51             processor.setFilesystem(new ZIPHtmlFilesystem(outputStream, dataDirectory));
52             final int yieldRate = getYieldRate();
53             if (yieldRate > 0) {
54                 processor.addRepaginationListener(new YieldReportListener(yieldRate));
55             }
56             processor.processReport();
57             outputStream.flush();
58             return true;
59         } catch (ReportProcessingException e) {
60             return false;
61         } catch (IOException JavaDoc e) {
62             return false;
63         }
64     }
65 }
66
Popular Tags