1 28 package net.sf.jasperreports.engine.design; 29 30 import java.util.ArrayList ; 31 import java.util.HashMap ; 32 import java.util.List ; 33 import java.util.Map ; 34 35 import net.sf.jasperreports.engine.JRConstants; 36 import net.sf.jasperreports.engine.JRDatasetParameter; 37 import net.sf.jasperreports.engine.JRException; 38 import net.sf.jasperreports.engine.JRExpression; 39 import net.sf.jasperreports.engine.base.JRBaseDatasetRun; 40 41 47 public class JRDesignDatasetRun extends JRBaseDatasetRun 48 { 49 private static final long serialVersionUID = JRConstants.SERIAL_VERSION_UID; 50 51 private Map parametersMap; 52 private List parametersList; 53 54 55 58 public JRDesignDatasetRun() 59 { 60 parametersMap = new HashMap (); 61 parametersList = new ArrayList (); 62 } 63 64 65 72 public void addParameter(JRDatasetParameter parameter) throws JRException 73 { 74 if (parametersMap.containsKey(parameter.getName())) 75 { 76 throw new JRException("Duplicate declaration of dataset parameter : " + parameter.getName()); 77 } 78 79 parametersMap.put(parameter.getName(), parameter); 80 parametersList.add(parameter); 81 } 82 83 84 90 public JRDatasetParameter removeParameter(String parameterName) 91 { 92 JRDatasetParameter param = (JRDatasetParameter) parametersMap.remove(parameterName); 93 if (param != null) 94 { 95 parametersList.remove(param); 96 } 97 98 return param; 99 } 100 101 102 108 public JRDatasetParameter removeParameter(JRDatasetParameter parameter) 109 { 110 JRDatasetParameter param = (JRDatasetParameter) parametersMap.remove(parameter.getName()); 111 if (param != null) 112 { 113 parametersList.remove(parameter); 114 } 115 116 return param; 117 } 118 119 120 126 public void setConnectionExpression(JRExpression connectionExpression) 127 { 128 this.connectionExpression = connectionExpression; 129 } 130 131 132 138 public void setDatasetName(String datasetName) 139 { 140 this.datasetName = datasetName; 141 } 142 143 144 150 public void setDataSourceExpression(JRExpression dataSourceExpression) 151 { 152 this.dataSourceExpression = dataSourceExpression; 153 } 154 155 156 162 public void setParametersMapExpression(JRExpression parametersMapExpression) 163 { 164 this.parametersMapExpression = parametersMapExpression; 165 } 166 167 public JRDatasetParameter[] getParameters() 168 { 169 JRDatasetParameter[] params = new JRDatasetParameter[parametersList.size()]; 170 parametersList.toArray(params); 171 return params; 172 } 173 174 } 175 | Popular Tags |