KickJava   Java API By Example, From Geeks To Geeks.

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


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.JRDataset;
34 import net.sf.jasperreports.engine.JRExpression;
35 import net.sf.jasperreports.engine.JRField;
36 import net.sf.jasperreports.engine.JRGroup;
37 import net.sf.jasperreports.engine.JRParameter;
38 import net.sf.jasperreports.engine.JRPropertiesMap;
39 import net.sf.jasperreports.engine.JRQuery;
40 import net.sf.jasperreports.engine.JRSortField;
41 import net.sf.jasperreports.engine.JRVariable;
42
43 /**
44  * The base implementation of {@link net.sf.jasperreports.engine.JRDataset JRDataset}.
45  *
46  * @author Lucian Chirita (lucianc@users.sourceforge.net)
47  * @version $Id: JRBaseDataset.java 1409 2006-09-28 12:53:43 +0300 (Thu, 28 Sep 2006) teodord $
48  */

49 public class JRBaseDataset implements JRDataset, Serializable JavaDoc
50 {
51     private static final long serialVersionUID = JRConstants.SERIAL_VERSION_UID;
52
53     protected final boolean isMain;
54     protected String JavaDoc name = null;
55     protected String JavaDoc scriptletClass = null;
56     protected JRParameter[] parameters = null;
57     protected JRQuery query = null;
58     protected JRField[] fields = null;
59     protected JRSortField[] sortFields = null;
60     protected JRVariable[] variables = null;
61     protected JRGroup[] groups = null;
62     protected String JavaDoc resourceBundle = null;
63     protected byte whenResourceMissingType = WHEN_RESOURCE_MISSING_TYPE_NULL;
64     protected JRPropertiesMap propertiesMap;
65     protected JRExpression filterExpression;
66     
67     protected JRBaseDataset(boolean isMain)
68     {
69         this.isMain = isMain;
70         
71         propertiesMap = new JRPropertiesMap();
72     }
73     
74     protected JRBaseDataset(JRDataset dataset, JRBaseObjectFactory factory)
75     {
76         factory.put(dataset, this);
77         
78         name = dataset.getName();
79         scriptletClass = dataset.getScriptletClass();
80         resourceBundle = dataset.getResourceBundle();
81         whenResourceMissingType = dataset.getWhenResourceMissingType();
82
83         /* */
84         this.propertiesMap = new JRPropertiesMap(dataset.getPropertiesMap());
85
86         query = factory.getQuery(dataset.getQuery());
87
88         isMain = dataset.isMainDataset();
89         
90         /* */
91         JRParameter[] jrParameters = dataset.getParameters();
92         if (jrParameters != null && jrParameters.length > 0)
93         {
94             parameters = new JRParameter[jrParameters.length];
95             for(int i = 0; i < parameters.length; i++)
96             {
97                 parameters[i] = factory.getParameter(jrParameters[i]);
98             }
99         }
100         
101         /* */
102         JRField[] jrFields = dataset.getFields();
103         if (jrFields != null && jrFields.length > 0)
104         {
105             fields = new JRField[jrFields.length];
106             for(int i = 0; i < fields.length; i++)
107             {
108                 fields[i] = factory.getField(jrFields[i]);
109             }
110         }
111
112         /* */
113         JRSortField[] jrSortFields = dataset.getSortFields();
114         if (jrSortFields != null && jrSortFields.length > 0)
115         {
116             sortFields = new JRSortField[jrSortFields.length];
117             for(int i = 0; i < sortFields.length; i++)
118             {
119                 sortFields[i] = factory.getSortField(jrSortFields[i]);
120             }
121         }
122
123         /* */
124         JRVariable[] jrVariables = dataset.getVariables();
125         if (jrVariables != null && jrVariables.length > 0)
126         {
127             variables = new JRVariable[jrVariables.length];
128             for(int i = 0; i < variables.length; i++)
129             {
130                 variables[i] = factory.getVariable(jrVariables[i]);
131             }
132         }
133
134         /* */
135         JRGroup[] jrGroups = dataset.getGroups();
136         if (jrGroups != null && jrGroups.length > 0)
137         {
138             groups = new JRGroup[jrGroups.length];
139             for(int i = 0; i < groups.length; i++)
140             {
141                 groups[i] = factory.getGroup(jrGroups[i]);
142             }
143         }
144         
145         filterExpression = factory.getExpression(dataset.getFilterExpression());
146     }
147
148     
149     /**
150      *
151      */

152     public String JavaDoc getName()
153     {
154         return name;
155     }
156     
157     /**
158      *
159      */

160     public String JavaDoc getScriptletClass()
161     {
162         return scriptletClass;
163     }
164
165     /**
166      *
167      */

168     public JRQuery getQuery()
169     {
170         return query;
171     }
172
173     /**
174      *
175      */

176     public JRParameter[] getParameters()
177     {
178         return parameters;
179     }
180
181     /**
182      *
183      */

184     public JRField[] getFields()
185     {
186         return fields;
187     }
188
189     /**
190      *
191      */

192     public JRSortField[] getSortFields()
193     {
194         return sortFields;
195     }
196
197     /**
198      *
199      */

200     public JRVariable[] getVariables()
201     {
202         return variables;
203     }
204
205     /**
206      *
207      */

208     public JRGroup[] getGroups()
209     {
210         return groups;
211     }
212
213     public boolean isMainDataset()
214     {
215         return isMain;
216     }
217
218     public String JavaDoc getResourceBundle()
219     {
220         return resourceBundle;
221     }
222
223     public byte getWhenResourceMissingType()
224     {
225         return whenResourceMissingType;
226     }
227
228     public void setWhenResourceMissingType(byte whenResourceMissingType)
229     {
230         this.whenResourceMissingType = whenResourceMissingType;
231     }
232
233     public JRPropertiesMap getPropertiesMap()
234     {
235         return propertiesMap;
236     }
237
238     public JRExpression getFilterExpression()
239     {
240         return filterExpression;
241     }
242 }
243
Popular Tags