KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sf > jasperreports > engine > base > JRBaseVariable


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 package net.sf.jasperreports.engine.base;
29
30 import java.io.Serializable JavaDoc;
31
32 import net.sf.jasperreports.engine.JRConstants;
33 import net.sf.jasperreports.engine.JRExpression;
34 import net.sf.jasperreports.engine.JRGroup;
35 import net.sf.jasperreports.engine.JRRuntimeException;
36 import net.sf.jasperreports.engine.JRVariable;
37 import net.sf.jasperreports.engine.util.JRClassLoader;
38
39
40 /**
41  * @author Teodor Danciu (teodord@users.sourceforge.net)
42  * @version $Id: JRBaseVariable.java 1229 2006-04-19 13:27:35 +0300 (Wed, 19 Apr 2006) teodord $
43  */

44 public class JRBaseVariable implements JRVariable, Serializable JavaDoc
45 {
46
47
48     /**
49      *
50      */

51     private static final long serialVersionUID = JRConstants.SERIAL_VERSION_UID;
52
53     /**
54      *
55      */

56     protected String JavaDoc name = null;
57     protected String JavaDoc valueClassName = java.lang.String JavaDoc.class.getName();
58     protected String JavaDoc incrementerFactoryClassName = null;
59     protected byte resetType = RESET_TYPE_REPORT;
60     protected byte incrementType = RESET_TYPE_NONE;
61     protected byte calculation = CALCULATION_NOTHING;
62     protected boolean isSystemDefined = false;
63
64     protected transient Class JavaDoc valueClass = null;
65     protected transient Class JavaDoc incrementerFactoryClass = null;
66
67     /**
68      *
69      */

70     protected JRExpression expression = null;
71     protected JRExpression initialValueExpression = null;
72     protected JRGroup resetGroup = null;
73     protected JRGroup incrementGroup = null;
74
75
76     /**
77      *
78      */

79     protected JRBaseVariable()
80     {
81     }
82     
83     
84     /**
85      *
86      */

87     protected JRBaseVariable(JRVariable variable, JRBaseObjectFactory factory)
88     {
89         factory.put(variable, this);
90         
91         name = variable.getName();
92         valueClassName = variable.getValueClassName();
93         incrementerFactoryClassName = variable.getIncrementerFactoryClassName();
94         resetType = variable.getResetType();
95         incrementType = variable.getIncrementType();
96         calculation = variable.getCalculation();
97         isSystemDefined = variable.isSystemDefined();
98         
99         expression = factory.getExpression(variable.getExpression());
100         initialValueExpression = factory.getExpression(variable.getInitialValueExpression());
101
102         resetGroup = factory.getGroup(variable.getResetGroup());
103         incrementGroup = factory.getGroup(variable.getIncrementGroup());
104     }
105         
106
107     /**
108      *
109      */

110     public String JavaDoc getName()
111     {
112         return this.name;
113     }
114         
115     /**
116      *
117      */

118     public Class JavaDoc getValueClass()
119     {
120         if (valueClass == null)
121         {
122             if (valueClassName != null)
123             {
124                 try
125                 {
126                     valueClass = JRClassLoader.loadClassForName(valueClassName);
127                 }
128                 catch(ClassNotFoundException JavaDoc e)
129                 {
130                     throw new JRRuntimeException(e);
131                 }
132             }
133         }
134         
135         return valueClass;
136     }
137         
138     /**
139      *
140      */

141     public String JavaDoc getValueClassName()
142     {
143         return valueClassName;
144     }
145         
146     /**
147      *
148      */

149     public Class JavaDoc getIncrementerFactoryClass()
150     {
151         if (incrementerFactoryClass == null)
152         {
153             if (incrementerFactoryClassName != null)
154             {
155                 try
156                 {
157                     incrementerFactoryClass = JRClassLoader.loadClassForName(incrementerFactoryClassName);
158                 }
159                 catch(ClassNotFoundException JavaDoc e)
160                 {
161                     throw new JRRuntimeException(e);
162                 }
163             }
164         }
165         
166         return incrementerFactoryClass;
167     }
168         
169     /**
170      *
171      */

172     public String JavaDoc getIncrementerFactoryClassName()
173     {
174         return incrementerFactoryClassName;
175     }
176         
177     /**
178      *
179      */

180     public byte getResetType()
181     {
182         return this.resetType;
183     }
184         
185     /**
186      *
187      */

188     public byte getIncrementType()
189     {
190         return this.incrementType;
191     }
192         
193     /**
194      *
195      */

196     public byte getCalculation()
197     {
198         return this.calculation;
199     }
200
201     /**
202      *
203      */

204     public boolean isSystemDefined()
205     {
206         return this.isSystemDefined;
207     }
208
209     /**
210      *
211      */

212     public JRExpression getExpression()
213     {
214         return this.expression;
215     }
216         
217     /**
218      *
219      */

220     public JRExpression getInitialValueExpression()
221     {
222         return this.initialValueExpression;
223     }
224         
225     /**
226      *
227      */

228     public JRGroup getResetGroup()
229     {
230         return this.resetGroup;
231     }
232         
233     /**
234      *
235      */

236     public JRGroup getIncrementGroup()
237     {
238         return this.incrementGroup;
239     }
240
241         
242 }
243
Popular Tags