KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > Scriptlet


1 /*
2  * ============================================================================
3  * GNU Lesser General Public License
4  * ============================================================================
5  *
6  * JasperReports - Free Java report-generating library.
7  * Copyright (C) 2001-2006 JasperSoft Corporation http://www.jaspersoft.com
8  *
9  * This library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License as published by the Free Software Foundation; either
12  * version 2.1 of the License, or (at your option) any later version.
13  *
14  * This library is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with this library; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
22  *
23  * JasperSoft Corporation
24  * 303 Second Street, Suite 450 North
25  * San Francisco, CA 94107
26  * http://www.jaspersoft.com
27  */

28
29 import net.sf.jasperreports.engine.JRDefaultScriptlet;
30 import net.sf.jasperreports.engine.JRScriptletException;
31
32
33 /**
34  * @author Teodor Danciu (teodord@users.sourceforge.net)
35  * @version $Id: Scriptlet.java 1229 2006-04-19 13:27:35 +0300 (Wed, 19 Apr 2006) teodord $
36  */

37 public class Scriptlet extends JRDefaultScriptlet
38 {
39
40
41     /**
42      *
43      */

44     public void beforeReportInit() throws JRScriptletException
45     {
46         System.out.println("call beforeReportInit");
47     }
48
49
50     /**
51      *
52      */

53     public void afterReportInit() throws JRScriptletException
54     {
55         System.out.println("call afterReportInit");
56     }
57
58
59     /**
60      *
61      */

62     public void beforePageInit() throws JRScriptletException
63     {
64         System.out.println("call beforePageInit : PAGE_NUMBER = " + this.getVariableValue("PAGE_NUMBER"));
65     }
66
67
68     /**
69      *
70      */

71     public void afterPageInit() throws JRScriptletException
72     {
73         System.out.println("call afterPageInit : PAGE_NUMBER = " + this.getVariableValue("PAGE_NUMBER"));
74     }
75
76
77     /**
78      *
79      */

80     public void beforeColumnInit() throws JRScriptletException
81     {
82         System.out.println("call beforeColumnInit");
83     }
84
85
86     /**
87      *
88      */

89     public void afterColumnInit() throws JRScriptletException
90     {
91         System.out.println("call afterColumnInit");
92     }
93
94
95     /**
96      *
97      */

98     public void beforeGroupInit(String JavaDoc groupName) throws JRScriptletException
99     {
100         if (groupName.equals("CityGroup"))
101         {
102             System.out.println("call beforeGroupInit : City = " + this.getFieldValue("City"));
103         }
104     }
105
106
107     /**
108      *
109      */

110     public void afterGroupInit(String JavaDoc groupName) throws JRScriptletException
111     {
112         if (groupName.equals("CityGroup"))
113         {
114             System.out.println("call afterGroupInit : City = " + this.getFieldValue("City"));
115         
116             String JavaDoc allCities = (String JavaDoc)this.getVariableValue("AllCities");
117             String JavaDoc city = (String JavaDoc)this.getFieldValue("City");
118             StringBuffer JavaDoc sbuffer = new StringBuffer JavaDoc();
119         
120             if (allCities != null)
121             {
122                 sbuffer.append(allCities);
123                 sbuffer.append(", ");
124             }
125         
126             sbuffer.append(city);
127             this.setVariableValue("AllCities", sbuffer.toString());
128         }
129     }
130
131
132     /**
133      *
134      */

135     public void beforeDetailEval() throws JRScriptletException
136     {
137         System.out.println(" detail");
138     }
139
140
141     /**
142      *
143      */

144     public void afterDetailEval() throws JRScriptletException
145     {
146     }
147
148
149     /**
150      *
151      */

152     public String JavaDoc hello() throws JRScriptletException
153     {
154         return "Hello! I'm the report's scriptlet object.";
155     }
156
157
158 }
159
Popular Tags