2
* JasperReports - Free Java Reporting Library.
3
* Copyright (C) 2001 - 2009 Jaspersoft Corporation. All rights reserved.
4
* http://www.jaspersoft.com
6
* Unless you have purchased a commercial license agreement from Jaspersoft,
7
* the following license terms apply:
9
* This program is part of JasperReports.
11
* JasperReports is free software: you can redistribute it and/or modify
12
* it under the terms of the GNU Lesser General Public License as published by
13
* the Free Software Foundation, either version 3 of the License, or
14
* (at your option) any later version.
16
* JasperReports is distributed in the hope that it will be useful,
17
* but WITHOUT ANY WARRANTY; without even the implied warranty of
18
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
* GNU Lesser General Public License for more details.
21
* You should have received a copy of the GNU Lesser General Public License
22
* along with JasperReports. If not, see <http://www.gnu.org/licenses/>.
24
package net.sf.jasperreports.engine.base;
26
import java.io.Serializable;
28
import net.sf.jasperreports.engine.JRConstants;
29
import net.sf.jasperreports.engine.JRDatasetParameter;
30
import net.sf.jasperreports.engine.JRDatasetRun;
31
import net.sf.jasperreports.engine.JRExpression;
32
import net.sf.jasperreports.engine.JRRuntimeException;
35
* Base implementation of the {@link net.sf.jasperreports.engine.JRDatasetRun JRDatasetRun} interface.
37
* @author Lucian Chirita (lucianc@users.sourceforge.net)
38
* @version $Id: JRBaseDatasetRun.java 3033 2009-08-27 11:46:22Z teodord $
40
public class JRBaseDatasetRun implements JRDatasetRun, Serializable
42
private static final long serialVersionUID = JRConstants.SERIAL_VERSION_UID;
44
protected String datasetName;
45
protected JRExpression parametersMapExpression;
46
protected JRDatasetParameter[] parameters;
47
protected JRExpression connectionExpression;
48
protected JRExpression dataSourceExpression;
52
* Creates an empty object.
54
protected JRBaseDatasetRun()
60
* Creates a copy of a dataset instantiation.
62
* @param datasetRun the dataset instantiation
63
* @param factory the base object factory
65
protected JRBaseDatasetRun(JRDatasetRun datasetRun, JRBaseObjectFactory factory)
67
factory.put(datasetRun, this);
69
datasetName = datasetRun.getDatasetName();
70
parametersMapExpression = factory.getExpression(datasetRun.getParametersMapExpression());
71
connectionExpression = factory.getExpression(datasetRun.getConnectionExpression());
72
dataSourceExpression = factory.getExpression(datasetRun.getDataSourceExpression());
74
JRDatasetParameter[] datasetParams = datasetRun.getParameters();
75
if (datasetParams != null && datasetParams.length > 0)
77
parameters = new JRBaseDatasetParameter[datasetParams.length];
78
for (int i = 0; i < parameters.length; i++)
80
parameters[i] = factory.getDatasetParameter(datasetParams[i]);
85
public String getDatasetName()
90
public JRExpression getParametersMapExpression()
92
return parametersMapExpression;
95
public JRDatasetParameter[] getParameters()
100
public JRExpression getConnectionExpression()
102
return connectionExpression;
105
public JRExpression getDataSourceExpression()
107
return dataSourceExpression;
113
public Object clone()
115
JRBaseDatasetRun clone = null;
119
clone = (JRBaseDatasetRun)super.clone();
121
catch (CloneNotSupportedException e)
123
throw new JRRuntimeException(e);
126
if (parametersMapExpression != null)
128
clone.parametersMapExpression = (JRExpression)parametersMapExpression.clone();
130
if (connectionExpression != null)
132
clone.connectionExpression = (JRExpression)connectionExpression.clone();
134
if (dataSourceExpression != null)
136
clone.dataSourceExpression = (JRExpression)dataSourceExpression.clone();
139
if (parameters != null)
141
clone.parameters = new JRDatasetParameter[parameters.length];
142
for(int i = 0; i < parameters.length; i++)
144
clone.parameters[i] = (JRDatasetParameter)parameters[i].clone();