1 28 package net.sf.jasperreports.engine.base; 29 30 import java.io.Serializable ; 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 49 public class JRBaseDataset implements JRDataset, Serializable 50 { 51 private static final long serialVersionUID = JRConstants.SERIAL_VERSION_UID; 52 53 protected final boolean isMain; 54 protected String name = null; 55 protected String 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 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 152 public String getName() 153 { 154 return name; 155 } 156 157 160 public String getScriptletClass() 161 { 162 return scriptletClass; 163 } 164 165 168 public JRQuery getQuery() 169 { 170 return query; 171 } 172 173 176 public JRParameter[] getParameters() 177 { 178 return parameters; 179 } 180 181 184 public JRField[] getFields() 185 { 186 return fields; 187 } 188 189 192 public JRSortField[] getSortFields() 193 { 194 return sortFields; 195 } 196 197 200 public JRVariable[] getVariables() 201 { 202 return variables; 203 } 204 205 208 public JRGroup[] getGroups() 209 { 210 return groups; 211 } 212 213 public boolean isMainDataset() 214 { 215 return isMain; 216 } 217 218 public String 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 |