KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sf > jasperreports > engine > xml > JRXmlDigesterFactory


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.xml;
29
30 import javax.xml.parsers.ParserConfigurationException JavaDoc;
31
32 import net.sf.jasperreports.charts.JRChartAxis;
33 import net.sf.jasperreports.charts.design.JRDesignCategorySeries;
34 import net.sf.jasperreports.charts.design.JRDesignDataRange;
35 import net.sf.jasperreports.charts.design.JRDesignTimePeriodSeries;
36 import net.sf.jasperreports.charts.design.JRDesignTimeSeries;
37 import net.sf.jasperreports.charts.design.JRDesignValueDisplay;
38 import net.sf.jasperreports.charts.design.JRDesignXySeries;
39 import net.sf.jasperreports.charts.design.JRDesignXyzSeries;
40 import net.sf.jasperreports.charts.util.JRAxisFormat;
41 import net.sf.jasperreports.charts.util.JRMeterInterval;
42 import net.sf.jasperreports.charts.xml.JRAreaChartFactory;
43 import net.sf.jasperreports.charts.xml.JRAreaPlotFactory;
44 import net.sf.jasperreports.charts.xml.JRBar3DChartFactory;
45 import net.sf.jasperreports.charts.xml.JRBar3DPlotFactory;
46 import net.sf.jasperreports.charts.xml.JRBarChartFactory;
47 import net.sf.jasperreports.charts.xml.JRBarPlotFactory;
48 import net.sf.jasperreports.charts.xml.JRBubbleChartFactory;
49 import net.sf.jasperreports.charts.xml.JRBubblePlotFactory;
50 import net.sf.jasperreports.charts.xml.JRCandlestickChartFactory;
51 import net.sf.jasperreports.charts.xml.JRCandlestickPlotFactory;
52 import net.sf.jasperreports.charts.xml.JRCategoryDatasetFactory;
53 import net.sf.jasperreports.charts.xml.JRCategorySeriesFactory;
54 import net.sf.jasperreports.charts.xml.JRChartAxisFactory;
55 import net.sf.jasperreports.charts.xml.JRDataRangeFactory;
56 import net.sf.jasperreports.charts.xml.JRHighLowChartFactory;
57 import net.sf.jasperreports.charts.xml.JRHighLowDatasetFactory;
58 import net.sf.jasperreports.charts.xml.JRHighLowPlotFactory;
59 import net.sf.jasperreports.charts.xml.JRLineChartFactory;
60 import net.sf.jasperreports.charts.xml.JRLinePlotFactory;
61 import net.sf.jasperreports.charts.xml.JRMeterChartFactory;
62 import net.sf.jasperreports.charts.xml.JRMeterIntervalFactory;
63 import net.sf.jasperreports.charts.xml.JRMeterPlotFactory;
64 import net.sf.jasperreports.charts.xml.JRMultiAxisChartFactory;
65 import net.sf.jasperreports.charts.xml.JRMultiAxisPlotFactory;
66 import net.sf.jasperreports.charts.xml.JRPie3DChartFactory;
67 import net.sf.jasperreports.charts.xml.JRPie3DPlotFactory;
68 import net.sf.jasperreports.charts.xml.JRPieChartFactory;
69 import net.sf.jasperreports.charts.xml.JRPieDatasetFactory;
70 import net.sf.jasperreports.charts.xml.JRPiePlotFactory;
71 import net.sf.jasperreports.charts.xml.JRScatterChartFactory;
72 import net.sf.jasperreports.charts.xml.JRScatterPlotFactory;
73 import net.sf.jasperreports.charts.xml.JRStackedBar3DChartFactory;
74 import net.sf.jasperreports.charts.xml.JRStackedBarChartFactory;
75 import net.sf.jasperreports.charts.xml.JRThermometerChartFactory;
76 import net.sf.jasperreports.charts.xml.JRThermometerPlotFactory;
77 import net.sf.jasperreports.charts.xml.JRTimePeriodDatasetFactory;
78 import net.sf.jasperreports.charts.xml.JRTimePeriodSeriesFactory;
79 import net.sf.jasperreports.charts.xml.JRTimeSeriesChartFactory;
80 import net.sf.jasperreports.charts.xml.JRTimeSeriesDatasetFactory;
81 import net.sf.jasperreports.charts.xml.JRTimeSeriesFactory;
82 import net.sf.jasperreports.charts.xml.JRTimeSeriesPlotFactory;
83 import net.sf.jasperreports.charts.xml.JRValueDatasetFactory;
84 import net.sf.jasperreports.charts.xml.JRValueDisplayFactory;
85 import net.sf.jasperreports.charts.xml.JRXyAreaChartFactory;
86 import net.sf.jasperreports.charts.xml.JRXyBarChartFactory;
87 import net.sf.jasperreports.charts.xml.JRXyDatasetFactory;
88 import net.sf.jasperreports.charts.xml.JRXyLineChartFactory;
89 import net.sf.jasperreports.charts.xml.JRXySeriesFactory;
90 import net.sf.jasperreports.charts.xml.JRXyzDatasetFactory;
91 import net.sf.jasperreports.charts.xml.JRXyzSeriesFactory;
92 import net.sf.jasperreports.crosstabs.JRCrosstabParameter;
93 import net.sf.jasperreports.crosstabs.design.JRDesignCellContents;
94 import net.sf.jasperreports.crosstabs.design.JRDesignCrosstabBucket;
95 import net.sf.jasperreports.crosstabs.design.JRDesignCrosstabCell;
96 import net.sf.jasperreports.crosstabs.design.JRDesignCrosstabColumnGroup;
97 import net.sf.jasperreports.crosstabs.design.JRDesignCrosstabMeasure;
98 import net.sf.jasperreports.crosstabs.design.JRDesignCrosstabRowGroup;
99 import net.sf.jasperreports.crosstabs.xml.JRCellContentsFactory;
100 import net.sf.jasperreports.crosstabs.xml.JRCrosstabBucketExpressionFactory;
101 import net.sf.jasperreports.crosstabs.xml.JRCrosstabBucketFactory;
102 import net.sf.jasperreports.crosstabs.xml.JRCrosstabCellFactory;
103 import net.sf.jasperreports.crosstabs.xml.JRCrosstabColumnGroupFactory;
104 import net.sf.jasperreports.crosstabs.xml.JRCrosstabDatasetFactory;
105 import net.sf.jasperreports.crosstabs.xml.JRCrosstabFactory;
106 import net.sf.jasperreports.crosstabs.xml.JRCrosstabMeasureExpressionFactory;
107 import net.sf.jasperreports.crosstabs.xml.JRCrosstabMeasureFactory;
108 import net.sf.jasperreports.crosstabs.xml.JRCrosstabParameterFactory;
109 import net.sf.jasperreports.crosstabs.xml.JRCrosstabParameterValueExpressionFactory;
110 import net.sf.jasperreports.crosstabs.xml.JRCrosstabRowGroupFactory;
111 import net.sf.jasperreports.engine.JRBand;
112 import net.sf.jasperreports.engine.JRBox;
113 import net.sf.jasperreports.engine.JRChartPlot;
114 import net.sf.jasperreports.engine.JRDatasetParameter;
115 import net.sf.jasperreports.engine.JRDatasetRun;
116 import net.sf.jasperreports.engine.JRExpression;
117 import net.sf.jasperreports.engine.JRField;
118 import net.sf.jasperreports.engine.JRFont;
119 import net.sf.jasperreports.engine.JRHyperlink;
120 import net.sf.jasperreports.engine.JRHyperlinkParameter;
121 import net.sf.jasperreports.engine.JRParameter;
122 import net.sf.jasperreports.engine.JRReportFont;
123 import net.sf.jasperreports.engine.JRSortField;
124 import net.sf.jasperreports.engine.JRStyle;
125 import net.sf.jasperreports.engine.JRSubreportParameter;
126 import net.sf.jasperreports.engine.JRSubreportReturnValue;
127 import net.sf.jasperreports.engine.design.JRDesignDataset;
128 import net.sf.jasperreports.engine.design.JRDesignElement;
129 import net.sf.jasperreports.engine.design.JRDesignElementGroup;
130 import net.sf.jasperreports.engine.design.JRDesignExpression;
131 import net.sf.jasperreports.engine.design.JRDesignGroup;
132 import net.sf.jasperreports.engine.design.JRDesignQuery;
133 import net.sf.jasperreports.engine.design.JRDesignVariable;
134 import net.sf.jasperreports.engine.design.JasperDesign;
135 import net.sf.jasperreports.engine.util.JRProperties;
136
137 import org.apache.commons.digester.Digester;
138 import org.apache.commons.digester.SetNestedPropertiesRule;
139 import org.xml.sax.ErrorHandler JavaDoc;
140 import org.xml.sax.SAXException JavaDoc;
141 import org.xml.sax.SAXParseException JavaDoc;
142
143
144 /**
145  * JRXmlDigesterFactory encapsulates the code necessary to construct and configure
146  * a digester in order to prepare it for parsing JasperReports xml definition files.
147  *
148  * @author Peter Severin (peter_p_s@users.sourceforge.net)
149  * @version $Id: JRXmlDigesterFactory.java 1536 2006-12-22 12:34:40 +0200 (Fri, 22 Dec 2006) teodord $
150  */

151 public class JRXmlDigesterFactory
152 {
153
154
155     /**
156      *
157      */

158     private JRXmlDigesterFactory()
159     {
160         super();
161     }
162
163
164     /**
165      * Configures the given digester for parsing jasperreport xml report definition files.
166      */

167     public static void configureDigester(Digester digester) throws SAXException JavaDoc, ParserConfigurationException JavaDoc
168     {
169         boolean validating = JRProperties.getBooleanProperty(JRProperties.COMPILER_XML_VALIDATION);
170         
171         digester.setErrorHandler(new ErrorHandlerImpl());
172         digester.setValidating(validating);
173         digester.setFeature("http://xml.org/sax/features/validation", validating);
174                 
175         /* */
176         digester.addFactoryCreate("jasperReport", JasperDesignFactory.class.getName());
177         digester.addSetNext("jasperReport", "setJasperDesign", JasperDesign.class.getName());
178
179         /* */
180         digester.addCallMethod("*/property", "setProperty", 2);
181         digester.addCallParam("*/property", 0, "name");
182         digester.addCallParam("*/property", 1, "value");
183
184         /* */
185         digester.addCallMethod("jasperReport/import", "addImport", 1);
186         digester.addCallParam("jasperReport/import", 0, "value");
187
188         /* */
189         digester.addFactoryCreate("jasperReport/reportFont", JRReportFontFactory.class.getName());
190         digester.addSetNext("jasperReport/reportFont", "addFont", JRReportFont.class.getName());
191         
192         /* */
193         digester.addFactoryCreate("jasperReport/style", JRStyleFactory.class.getName());
194         digester.addSetNext("jasperReport/style", "addStyle", JRStyle.class.getName());
195
196         digester.addFactoryCreate("jasperReport/style/conditionalStyle", JRConditionalStyleFactory.class.getName());
197         digester.addFactoryCreate("jasperReport/style/conditionalStyle/conditionExpression", JRExpressionFactory.BooleanExpressionFactory.class.getName());
198         digester.addSetNext("jasperReport/style/conditionalStyle/conditionExpression", "setConditionExpression", JRExpression.class.getName());
199         digester.addCallMethod("jasperReport/style/conditionalStyle/conditionExpression", "setText", 0);
200         digester.addFactoryCreate("jasperReport/style/conditionalStyle/style", JRConditionalStyleFillerFactory.class.getName());
201
202         /* */
203         digester.addFactoryCreate("*/parameter", JRParameterFactory.class.getName());
204         digester.addSetNext("*/parameter", "addParameter", JRParameter.class.getName());
205         digester.addCallMethod("*/parameter/parameterDescription", "setDescription", 0);
206
207         /* */
208         digester.addFactoryCreate("*/parameter/defaultValueExpression", JRDefaultValueExpressionFactory.class.getName());
209         digester.addSetNext("*/parameter/defaultValueExpression", "setDefaultValueExpression", JRExpression.class.getName());
210         digester.addCallMethod("*/parameter/defaultValueExpression", "setText", 0);
211
212         /* */
213         digester.addFactoryCreate("*/queryString", JRQueryFactory.class.getName());
214         digester.addSetNext("*/queryString", "setQuery", JRDesignQuery.class.getName());
215         digester.addCallMethod("*/queryString", "setText", 0);
216         
217         /* */
218         digester.addFactoryCreate("*/field", JRFieldFactory.class.getName());
219         digester.addSetNext("*/field", "addField", JRField.class.getName());
220         digester.addCallMethod("*/field/fieldDescription", "setDescription", 0);
221
222         /* */
223         digester.addFactoryCreate("*/sortField", JRSortFieldFactory.class.getName());
224         digester.addSetNext("*/sortField", "addSortField", JRSortField.class.getName());
225
226         /* */
227         digester.addFactoryCreate("*/variable", JRVariableFactory.class.getName());
228         digester.addSetNext("*/variable", "addVariable", JRDesignVariable.class.getName());
229
230         /* */
231         digester.addFactoryCreate("*/variable/variableExpression", JRVariableExpressionFactory.class.getName());
232         digester.addSetNext("*/variable/variableExpression", "setExpression", JRExpression.class.getName());
233         digester.addCallMethod("*/variable/variableExpression", "setText", 0);
234
235         /* */
236         digester.addFactoryCreate("*/variable/initialValueExpression", JRInitialValueExpressionFactory.class.getName());
237         digester.addSetNext("*/variable/initialValueExpression", "setInitialValueExpression", JRExpression.class.getName());
238         digester.addCallMethod("*/variable/initialValueExpression", "setText", 0);
239
240         String JavaDoc filterExpressionPath = "*/" + JRDatasetFactory.ELEMENT_filterExpression;
241         digester.addFactoryCreate(filterExpressionPath, JRExpressionFactory.BooleanExpressionFactory.class.getName());
242         digester.addSetNext(filterExpressionPath, "setFilterExpression", JRExpression.class.getName());
243         digester.addCallMethod(filterExpressionPath, "setText", 0);
244         
245         /* */
246         digester.addFactoryCreate("*/group", JRGroupFactory.class.getName());
247         digester.addSetNext("*/group", "addGroup", JRDesignGroup.class.getName());
248
249         /* */
250         digester.addFactoryCreate("*/group/groupExpression", JRExpressionFactory.ObjectExpressionFactory.class.getName());
251         digester.addSetNext("*/group/groupExpression", "setExpression", JRExpression.class.getName());
252         digester.addCallMethod("*/group/groupExpression", "setText", 0);
253
254         /* */
255         digester.addFactoryCreate("jasperReport/background/band", JRBandFactory.class.getName());
256         digester.addSetNext("jasperReport/background/band", "setBackground", JRBand.class.getName());
257         digester.addFactoryCreate("jasperReport/title/band", JRBandFactory.class.getName());
258         digester.addSetNext("jasperReport/title/band", "setTitle", JRBand.class.getName());
259         digester.addFactoryCreate("jasperReport/pageHeader/band", JRBandFactory.class.getName());
260         digester.addSetNext("jasperReport/pageHeader/band", "setPageHeader", JRBand.class.getName());
261         digester.addFactoryCreate("jasperReport/columnHeader/band", JRBandFactory.class.getName());
262         digester.addSetNext("jasperReport/columnHeader/band", "setColumnHeader", JRBand.class.getName());
263         digester.addFactoryCreate("jasperReport/group/groupHeader/band", JRBandFactory.class.getName());
264         digester.addSetNext("jasperReport/group/groupHeader/band", "setGroupHeader", JRBand.class.getName());
265         digester.addFactoryCreate("jasperReport/detail/band", JRBandFactory.class.getName());
266         digester.addSetNext("jasperReport/detail/band", "setDetail", JRBand.class.getName());
267         digester.addFactoryCreate("jasperReport/group/groupFooter/band", JRBandFactory.class.getName());
268         digester.addSetNext("jasperReport/group/groupFooter/band", "setGroupFooter", JRBand.class.getName());
269         digester.addFactoryCreate("jasperReport/columnFooter/band", JRBandFactory.class.getName());
270         digester.addSetNext("jasperReport/columnFooter/band", "setColumnFooter", JRBand.class.getName());
271         digester.addFactoryCreate("jasperReport/pageFooter/band", JRBandFactory.class.getName());
272         digester.addSetNext("jasperReport/pageFooter/band", "setPageFooter", JRBand.class.getName());
273         digester.addFactoryCreate("jasperReport/lastPageFooter/band", JRBandFactory.class.getName());
274         digester.addSetNext("jasperReport/lastPageFooter/band", "setLastPageFooter", JRBand.class.getName());
275         digester.addFactoryCreate("jasperReport/summary/band", JRBandFactory.class.getName());
276         digester.addSetNext("jasperReport/summary/band", "setSummary", JRBand.class.getName());
277
278         /* */
279         digester.addFactoryCreate("*/band/printWhenExpression", JRExpressionFactory.BooleanExpressionFactory.class.getName());
280         digester.addSetNext("*/band/printWhenExpression", "setPrintWhenExpression", JRExpression.class.getName());
281         digester.addCallMethod("*/band/printWhenExpression", "setText", 0);
282
283         /* */
284         digester.addFactoryCreate("*/break", JRBreakFactory.class.getName());
285         digester.addSetNext("*/break", "addElement", JRDesignElement.class.getName());
286
287         /* */
288         digester.addFactoryCreate("*/line", JRLineFactory.class.getName());
289         digester.addSetNext("*/line", "addElement", JRDesignElement.class.getName());
290
291         /* */
292         digester.addFactoryCreate("*/reportElement", JRElementFactory.class.getName());
293
294         /* */
295         digester.addFactoryCreate("*/reportElement/printWhenExpression", JRExpressionFactory.BooleanExpressionFactory.class.getName());
296         digester.addSetNext("*/reportElement/printWhenExpression", "setPrintWhenExpression", JRExpression.class.getName());
297         digester.addCallMethod("*/reportElement/printWhenExpression", "setText", 0);
298
299         /* */
300         digester.addFactoryCreate("*/graphicElement", JRGraphicElementFactory.class.getName());
301
302         /* */
303         digester.addFactoryCreate("*/rectangle", JRRectangleFactory.class.getName());
304         digester.addSetNext("*/rectangle", "addElement", JRDesignElement.class.getName());
305
306         /* */
307         digester.addFactoryCreate("*/ellipse", JREllipseFactory.class.getName());
308         digester.addSetNext("*/ellipse", "addElement", JRDesignElement.class.getName());
309
310         /* */
311         digester.addFactoryCreate("*/image", JRImageFactory.class.getName());
312         digester.addSetNext("*/image", "addElement", JRDesignElement.class.getName());
313
314         /* */
315         digester.addFactoryCreate("*/box", JRBoxFactory.class.getName());
316 // digester.addSetNext("*/box", "setBox", JRBox.class.getName());
317

318         /* */
319         digester.addFactoryCreate("*/image/imageExpression", JRImageExpressionFactory.class.getName());
320         digester.addSetNext("*/image/imageExpression", "setExpression", JRExpression.class.getName());
321         digester.addCallMethod("*/image/imageExpression", "setText", 0);
322
323         /* */
324         digester.addFactoryCreate("*/staticText", JRStaticTextFactory.class.getName());
325         digester.addSetNext("*/staticText", "addElement", JRDesignElement.class.getName());
326         SetNestedPropertiesRule textRule = new SetNestedPropertiesRule(new String JavaDoc[]{"text", "reportElement", "box", "textElement"}, new String JavaDoc[]{"text"});
327         textRule.setTrimData(false);
328         textRule.setAllowUnknownChildElements(true);
329         digester.addRule("*/staticText", textRule);
330
331
332         /* */
333         digester.addFactoryCreate("*/textElement", JRTextElementFactory.class.getName());
334
335         /* */
336         digester.addFactoryCreate("*/textElement/font", JRFontFactory.TextElementFontFactory.class.getName());
337 // digester.addSetNext("*/textElement/font", "setFont", JRFont.class.getName());
338

339         /* */
340         digester.addFactoryCreate("*/textField", JRTextFieldFactory.class.getName());
341         digester.addSetNext("*/textField", "addElement", JRDesignElement.class.getName());
342
343         /* */
344         digester.addFactoryCreate("*/textField/textFieldExpression", JRTextFieldExpressionFactory.class.getName());
345         digester.addSetNext("*/textField/textFieldExpression", "setExpression", JRExpression.class.getName());
346         digester.addCallMethod("*/textField/textFieldExpression", "setText", 0);
347
348         /* */
349         digester.addFactoryCreate("*/anchorNameExpression", JRExpressionFactory.StringExpressionFactory.class.getName());
350         digester.addSetNext("*/anchorNameExpression", "setAnchorNameExpression", JRExpression.class.getName());
351         digester.addCallMethod("*/anchorNameExpression", "setText", 0);
352         digester.addFactoryCreate("*/hyperlinkReferenceExpression", JRExpressionFactory.StringExpressionFactory.class.getName());
353         digester.addSetNext("*/hyperlinkReferenceExpression", "setHyperlinkReferenceExpression", JRExpression.class.getName());
354         digester.addCallMethod("*/hyperlinkReferenceExpression", "setText", 0);
355         digester.addFactoryCreate("*/hyperlinkAnchorExpression", JRExpressionFactory.StringExpressionFactory.class.getName());
356         digester.addSetNext("*/hyperlinkAnchorExpression", "setHyperlinkAnchorExpression", JRExpression.class.getName());
357         digester.addCallMethod("*/hyperlinkAnchorExpression", "setText", 0);
358         digester.addFactoryCreate("*/hyperlinkPageExpression", JRExpressionFactory.IntegerExpressionFactory.class.getName());
359         digester.addSetNext("*/hyperlinkPageExpression", "setHyperlinkPageExpression", JRExpression.class.getName());
360         digester.addCallMethod("*/hyperlinkPageExpression", "setText", 0);
361
362         String JavaDoc hyperlinkTooltipExpressionPattern = "*/" + JRHyperlinkFactory.ELEMENT_hyperlinkTooltipExpression;
363         digester.addFactoryCreate(hyperlinkTooltipExpressionPattern, JRExpressionFactory.StringExpressionFactory.class.getName());
364         digester.addSetNext(hyperlinkTooltipExpressionPattern, "setHyperlinkTooltipExpression", JRExpression.class.getName());
365         digester.addCallMethod(hyperlinkTooltipExpressionPattern, "setText", 0);
366         
367         addHyperlinkParameterRules(digester);
368
369         /* */
370         digester.addFactoryCreate("*/subreport", JRSubreportFactory.class.getName());
371         digester.addSetNext("*/subreport", "addElement", JRDesignElement.class.getName());
372
373         /* */
374         digester.addFactoryCreate("*/subreport/subreportParameter", JRSubreportParameterFactory.class.getName());
375         digester.addSetNext("*/subreport/subreportParameter", "addParameter", JRSubreportParameter.class.getName());
376
377         /* */
378         digester.addFactoryCreate("*/subreport/returnValue", JRSubreportReturnValueFactory.class.getName());
379         digester.addSetNext("*/subreport/returnValue", "addReturnValue", JRSubreportReturnValue.class.getName());
380
381         /* */
382         digester.addFactoryCreate("*/parametersMapExpression", JRExpressionFactory.MapExpressionFactory.class.getName());
383         digester.addSetNext("*/parametersMapExpression", "setParametersMapExpression", JRExpression.class.getName());
384         digester.addCallMethod("*/parametersMapExpression", "setText", 0);
385
386         /* */
387         digester.addFactoryCreate("*/subreport/subreportParameter/subreportParameterExpression", JRExpressionFactory.ObjectExpressionFactory.class.getName());
388         digester.addSetNext("*/subreport/subreportParameter/subreportParameterExpression", "setExpression", JRExpression.class.getName());
389         digester.addCallMethod("*/subreport/subreportParameter/subreportParameterExpression", "setText", 0);
390
391         /* */
392         digester.addFactoryCreate("*/connectionExpression", JRExpressionFactory.ConnectionExpressionFactory.class.getName());
393         digester.addSetNext("*/connectionExpression", "setConnectionExpression", JRExpression.class.getName());
394         digester.addCallMethod("*/connectionExpression", "setText", 0);
395
396         /* */
397         digester.addFactoryCreate("*/dataSourceExpression", JRExpressionFactory.DataSourceExpressionFactory.class.getName());
398         digester.addSetNext("*/dataSourceExpression", "setDataSourceExpression", JRExpression.class.getName());
399         digester.addCallMethod("*/dataSourceExpression", "setText", 0);
400
401         /* */
402         digester.addFactoryCreate("*/subreport/subreportExpression", JRSubreportExpressionFactory.class.getName());
403         digester.addSetNext("*/subreport/subreportExpression", "setExpression", JRExpression.class.getName());
404         digester.addCallMethod("*/subreport/subreportExpression", "setText", 0);
405
406         /* */
407         digester.addFactoryCreate("*/elementGroup", JRElementGroupFactory.class.getName());
408         digester.addSetNext("*/elementGroup", "addElementGroup", JRDesignElementGroup.class.getName());
409
410         addChartRules(digester);
411
412         addDatasetRules(digester);
413         
414         addCrosstabRules(digester);
415         
416         addFrameRules(digester);
417     }
418
419
420     /**
421      *
422      */

423     private static void addChartRules(Digester digester)
424     {
425         digester.addFactoryCreate("*/dataset", JRElementDatasetFactory.class.getName());
426         
427         String JavaDoc datasetIncrementWhenExpressionPath = "*/dataset/" + JRElementDatasetFactory.ELEMENT_incrementWhenExpression;
428         digester.addFactoryCreate(datasetIncrementWhenExpressionPath, JRExpressionFactory.BooleanExpressionFactory.class.getName());
429         digester.addSetNext(datasetIncrementWhenExpressionPath, "setIncrementWhenExpression", JRExpression.class.getName());
430         digester.addCallMethod(datasetIncrementWhenExpressionPath, "setText", 0);
431         
432         digester.addFactoryCreate("*/plot", JRChartPlotFactory.class.getName());
433         digester.addFactoryCreate("*/plot/seriesColor", JRChartPlotFactory.JRSeriesColorFactory.class.getName());
434         digester.addSetNext("*/plot/seriesColor", "addSeriesColor", JRChartPlot.JRSeriesColor.class.getName());
435
436         digester.addFactoryCreate("*/chart", JRChartFactory.class.getName());
437         digester.addFactoryCreate("*/chart/chartTitle", JRChartFactory.JRChartTitleFactory.class.getName());
438         digester.addFactoryCreate("*/chart/chartTitle/font", JRFontFactory.ChartFontFactory.class.getName());
439         digester.addSetNext("*/chart/chartTitle/font", "setTitleFont", JRFont.class.getName());
440         digester.addFactoryCreate("*/chart/chartTitle/titleExpression", JRExpressionFactory.StringExpressionFactory.class);
441         digester.addSetNext("*/chart/chartTitle/titleExpression", "setTitleExpression", JRDesignExpression.class.getName());
442         digester.addCallMethod("*/chart/chartTitle/titleExpression", "setText", 0);
443         digester.addFactoryCreate("*/chart/chartSubtitle", JRChartFactory.JRChartSubtitleFactory.class.getName());
444         digester.addFactoryCreate("*/chart/chartSubtitle/font", JRFontFactory.ChartFontFactory.class.getName());
445         digester.addSetNext("*/chart/chartSubtitle/font", "setSubtitleFont", JRFont.class.getName());
446         digester.addFactoryCreate("*/chart/chartSubtitle/subtitleExpression", JRExpressionFactory.StringExpressionFactory.class);
447         digester.addSetNext("*/chart/chartSubtitle/subtitleExpression", "setSubtitleExpression", JRDesignExpression.class.getName());
448         digester.addCallMethod("*/chart/chartSubtitle/subtitleExpression", "setText", 0);
449         digester.addFactoryCreate("*/chart/chartLegend", JRChartFactory.JRChartLegendFactory.class.getName());
450         digester.addFactoryCreate("*/chart/chartLegend/font", JRFontFactory.ChartFontFactory.class.getName());
451         digester.addSetNext("*/chart/chartLegend/font", "setLegendFont", JRFont.class.getName());
452
453         // axis labels
454
digester.addFactoryCreate("*/categoryAxisFormat/axisFormat", JRChartFactory.JRChartAxisFormatFactory.class.getName());
455         digester.addSetNext("*/categoryAxisFormat/axisFormat", "setCategoryAxisFormat", JRAxisFormat.class.getName());
456         digester.addFactoryCreate("*/categoryAxisFormat/axisFormat/labelFont/font", JRFontFactory.ChartFontFactory.class.getName());
457         digester.addSetNext("*/categoryAxisFormat/axisFormat/labelFont/font", "setLabelFont", JRFont.class.getName());
458         digester.addFactoryCreate("*/categoryAxisFormat/axisFormat/tickLabelFont/font", JRFontFactory.ChartFontFactory.class.getName());
459         digester.addSetNext("*/categoryAxisFormat/axisFormat/tickLabelFont/font", "setTickLabelFont", JRFont.class.getName());
460
461         digester.addFactoryCreate("*/valueAxisFormat/axisFormat", JRChartFactory.JRChartAxisFormatFactory.class.getName());
462         digester.addSetNext("*/valueAxisFormat/axisFormat", "setValueAxisFormat", JRAxisFormat.class.getName());
463         digester.addFactoryCreate("*/valueAxisFormat/axisFormat/labelFont/font", JRFontFactory.ChartFontFactory.class.getName());
464         digester.addSetNext("*/valueAxisFormat/axisFormat/labelFont/font", "setLabelFont", JRFont.class.getName());
465         digester.addFactoryCreate("*/valueAxisFormat/axisFormat/tickLabelFont/font", JRFontFactory.ChartFontFactory.class.getName());
466         digester.addSetNext("*/valueAxisFormat/axisFormat/tickLabelFont/font", "setTickLabelFont", JRFont.class.getName());
467
468         digester.addFactoryCreate("*/timeAxisFormat/axisFormat", JRChartFactory.JRChartAxisFormatFactory.class.getName());
469         digester.addSetNext("*/timeAxisFormat/axisFormat", "setTimeAxisFormat", JRAxisFormat.class.getName());
470         digester.addFactoryCreate("*/timeAxisFormat/axisFormat/labelFont/font", JRFontFactory.ChartFontFactory.class.getName());
471         digester.addSetNext("*/timeAxisFormat/axisFormat/labelFont/font", "setLabelFont", JRFont.class.getName());
472         digester.addFactoryCreate("*/timeAxisFormat/axisFormat/tickLabelFont/font", JRFontFactory.ChartFontFactory.class.getName());
473         digester.addSetNext("*/timeAxisFormat/axisFormat/tickLabelFont/font", "setTickLabelFont", JRFont.class.getName());
474
475         digester.addFactoryCreate("*/xAxisFormat/axisFormat", JRChartFactory.JRChartAxisFormatFactory.class.getName());
476         digester.addSetNext("*/xAxisFormat/axisFormat", "setXAxisFormat", JRAxisFormat.class.getName());
477         digester.addFactoryCreate("*/xAxisFormat/axisFormat/labelFont/font", JRFontFactory.ChartFontFactory.class.getName());
478         digester.addSetNext("*/xAxisFormat/axisFormat/labelFont/font", "setLabelFont", JRFont.class.getName());
479         digester.addFactoryCreate("*/xAxisFormat/axisFormat/tickLabelFont/font", JRFontFactory.ChartFontFactory.class.getName());
480         digester.addSetNext("*/xAxisFormat/axisFormat/tickLabelFont/font", "setTickLabelFont", JRFont.class.getName());
481
482         digester.addFactoryCreate("*/yAxisFormat/axisFormat", JRChartFactory.JRChartAxisFormatFactory.class.getName());
483         digester.addSetNext("*/yAxisFormat/axisFormat", "setYAxisFormat", JRAxisFormat.class.getName());
484         digester.addFactoryCreate("*/yAxisFormat/axisFormat/labelFont/font", JRFontFactory.ChartFontFactory.class.getName());
485         digester.addSetNext("*/yAxisFormat/axisFormat/labelFont/font", "setLabelFont", JRFont.class.getName());
486         digester.addFactoryCreate("*/yAxisFormat/axisFormat/tickLabelFont/font", JRFontFactory.ChartFontFactory.class.getName());
487         digester.addSetNext("*/yAxisFormat/axisFormat/tickLabelFont/font", "setTickLabelFont", JRFont.class.getName());
488
489         // pie charts
490
digester.addFactoryCreate("*/pieChart", JRPieChartFactory.class.getName());
491         digester.addSetNext("*/pieChart", "addElement", JRDesignElement.class.getName());
492         digester.addFactoryCreate("*/pieChart/piePlot", JRPiePlotFactory.class.getName());
493
494         digester.addFactoryCreate("*/pieDataset", JRPieDatasetFactory.class.getName());
495         digester.addFactoryCreate("*/pieDataset/keyExpression", JRExpressionFactory.ComparableExpressionFactory.class);
496         digester.addSetNext("*/pieDataset/keyExpression", "setKeyExpression", JRDesignExpression.class.getName());
497         digester.addCallMethod("*/pieDataset/keyExpression", "setText", 0);
498         digester.addFactoryCreate("*/pieDataset/labelExpression", JRExpressionFactory.StringExpressionFactory.class);
499         digester.addSetNext("*/pieDataset/labelExpression", "setLabelExpression", JRDesignExpression.class.getName());
500         digester.addCallMethod("*/pieDataset/labelExpression", "setText", 0);
501         digester.addFactoryCreate("*/pieDataset/valueExpression", JRExpressionFactory.NumberExpressionFactory.class);
502         digester.addSetNext("*/pieDataset/valueExpression", "setValueExpression", JRDesignExpression.class.getName());
503         digester.addCallMethod("*/pieDataset/valueExpression", "setText", 0);
504         
505         String JavaDoc sectionHyperlinkPattern = "*/pieDataset/" + JRHyperlinkFactory.ELEMENT_sectionHyperlink;
506         digester.addFactoryCreate(sectionHyperlinkPattern, JRHyperlinkFactory.class);
507         digester.addSetNext(sectionHyperlinkPattern, "setSectionHyperlink", JRHyperlink.class.getName());
508         
509         // pie 3D charts
510
digester.addFactoryCreate("*/pie3DChart", JRPie3DChartFactory.class.getName());
511         digester.addSetNext("*/pie3DChart", "addElement", JRDesignElement.class.getName());
512         digester.addFactoryCreate("*/pie3DPlot", JRPie3DPlotFactory.class.getName());
513
514         // bar charts
515
digester.addFactoryCreate("*/barChart", JRBarChartFactory.class.getName());
516         digester.addSetNext("*/barChart", "addElement", JRDesignElement.class.getName());
517         digester.addFactoryCreate("*/barChart/barPlot", JRBarPlotFactory.class.getName());
518         
519         digester.addFactoryCreate( "*/barPlot/categoryAxisLabelExpression", JRExpressionFactory.ComparableExpressionFactory.class );
520         digester.addSetNext( "*/barPlot/categoryAxisLabelExpression", "setCategoryAxisLabelExpression", JRDesignExpression.class.getName() );
521         digester.addCallMethod( "*/barPlot/categoryAxisLabelExpression", "setText", 0 );
522         
523         digester.addFactoryCreate( "*/barPlot/valueAxisLabelExpression", JRExpressionFactory.ComparableExpressionFactory.class );
524         digester.addSetNext( "*/barPlot/valueAxisLabelExpression", "setValueAxisLabelExpression", JRDesignExpression.class.getName() );
525         digester.addCallMethod( "*/barPlot/valueAxisLabelExpression", "setText", 0 );
526         
527         
528         
529         // area charts
530
digester.addFactoryCreate( "*/areaChart", JRAreaChartFactory.class.getName() );
531         digester.addSetNext( "*/areaChart", "addElement", JRDesignElement.class.getName() );
532         digester.addFactoryCreate( "*/areaChart/areaPlot", JRAreaPlotFactory.class.getName() );
533         
534         digester.addFactoryCreate( "*/xyAreaChart", JRXyAreaChartFactory.class.getName() );
535         digester.addSetNext( "*/xyAreaChart", "addElement", JRDesignElement.class.getName() );
536         digester.addFactoryCreate( "*/xyAreaChart/areaPlot", JRAreaPlotFactory.class.getName() );
537         
538         digester.addFactoryCreate( "*/areaPlot/categoryAxisLabelExpression", JRExpressionFactory.ComparableExpressionFactory.class );
539         digester.addSetNext( "*/areaPlot/categoryAxisLabelExpression", "setCategoryAxisLabelExpression", JRDesignExpression.class.getName() );
540         digester.addCallMethod( "*/areaPlot/categoryAxisLabelExpression", "setText", 0 );
541         
542         digester.addFactoryCreate( "*/areaPlot/valueAxisLabelExpression", JRExpressionFactory.ComparableExpressionFactory.class );
543         digester.addSetNext( "*/areaPlot/valueAxisLabelExpression", "setValueAxisLabelExpression", JRDesignExpression.class.getName() );
544         digester.addCallMethod( "*/areaPlot/valueAxisLabelExpression", "setText", 0 );
545         
546         // bar3d charts
547
digester.addFactoryCreate( "*/bar3DChart", JRBar3DChartFactory.class.getName() );
548         digester.addSetNext( "*/bar3DChart", "addElement", JRDesignElement.class.getName() );
549         digester.addFactoryCreate("*/bar3DChart/bar3DPlot", JRBar3DPlotFactory.class.getName());
550         
551         digester.addFactoryCreate( "*/bar3DPlot/categoryAxisLabelExpression", JRExpressionFactory.ComparableExpressionFactory.class );
552         digester.addSetNext( "*/bar3DPlot/categoryAxisLabelExpression", "setCategoryAxisLabelExpression", JRDesignExpression.class.getName() );
553         digester.addCallMethod( "*/bar3DPlot/categoryAxisLabelExpression", "setText", 0 );
554         
555         digester.addFactoryCreate( "*/bar3DPlot/valueAxisLabelExpression", JRExpressionFactory.ComparableExpressionFactory.class );
556         digester.addSetNext( "*/bar3DPlot/valueAxisLabelExpression", "setValueAxisLabelExpression", JRDesignExpression.class.getName() );
557         digester.addCallMethod( "*/bar3DPlot/valueAxisLabelExpression", "setText", 0 );
558         
559         digester.addFactoryCreate("*/categoryDataset", JRCategoryDatasetFactory.class.getName());
560         digester.addFactoryCreate("*/categoryDataset/categorySeries", JRCategorySeriesFactory.class.getName());
561         digester.addSetNext("*/categoryDataset/categorySeries", "addCategorySeries", JRDesignCategorySeries.class.getName());
562
563         //digester.addFactoryCreate("*/categorySeries", JRCategoryDatasetFactory.class.getName());
564
digester.addFactoryCreate("*/categorySeries/seriesExpression", JRExpressionFactory.ComparableExpressionFactory.class);
565         digester.addSetNext("*/categorySeries/seriesExpression", "setSeriesExpression", JRDesignExpression.class.getName());
566         digester.addCallMethod("*/categorySeries/seriesExpression", "setText", 0);
567         digester.addFactoryCreate("*/categorySeries/categoryExpression", JRExpressionFactory.ComparableExpressionFactory.class);
568         digester.addSetNext("*/categorySeries/categoryExpression", "setCategoryExpression", JRDesignExpression.class.getName());
569         digester.addCallMethod("*/categorySeries/categoryExpression", "setText", 0);
570         digester.addFactoryCreate("*/categorySeries/labelExpression", JRExpressionFactory.StringExpressionFactory.class);
571         digester.addSetNext("*/categorySeries/labelExpression", "setLabelExpression", JRDesignExpression.class.getName());
572         digester.addCallMethod("*/categorySeries/labelExpression", "setText", 0);
573         digester.addFactoryCreate("*/categorySeries/valueExpression", JRExpressionFactory.NumberExpressionFactory.class);
574         digester.addSetNext("*/categorySeries/valueExpression", "setValueExpression", JRDesignExpression.class.getName());
575         digester.addCallMethod("*/categorySeries/valueExpression", "setText", 0);
576         
577         String JavaDoc itemHyperlinkPattern = "*/" + JRHyperlinkFactory.ELEMENT_itemHyperlink;
578         digester.addFactoryCreate(itemHyperlinkPattern, JRHyperlinkFactory.class);
579         digester.addSetNext(itemHyperlinkPattern, "setItemHyperlink", JRHyperlink.class.getName());
580         
581         digester.addFactoryCreate( "*/xyzDataset", JRXyzDatasetFactory.class.getName() );
582         digester.addFactoryCreate( "*/xyzDataset/xyzSeries", JRXyzSeriesFactory.class.getName() );
583         digester.addSetNext( "*/xyzDataset/xyzSeries", "addXyzSeries", JRDesignXyzSeries.class.getName() );
584         
585         digester.addFactoryCreate( "*/xyzSeries/seriesExpression", JRExpressionFactory.ComparableExpressionFactory.class );
586         digester.addSetNext( "*/xyzSeries/seriesExpression", "setSeriesExpression", JRDesignExpression.class.getName() );
587         digester.addCallMethod( "*/xyzSeries/seriesExpression", "setText", 0 );
588         digester.addFactoryCreate( "*/xyzSeries", JRXyzDatasetFactory.class.getName() );
589         digester.addFactoryCreate( "*/xyzSeries/xValueExpression", JRExpressionFactory.NumberExpressionFactory.class );
590         digester.addSetNext( "*/xyzSeries/xValueExpression", "setXValueExpression", JRDesignExpression.class.getName() );
591         digester.addCallMethod( "*/xyzSeries/xValueExpression", "setText", 0 );
592         digester.addFactoryCreate( "*/xyzSeries/yValueExpression", JRExpressionFactory.NumberExpressionFactory.class );
593         digester.addSetNext( "*/xyzSeries/yValueExpression", "setYValueExpression", JRDesignExpression.class.getName() );
594         digester.addCallMethod( "*/xyzSeries/yValueExpression", "setText", 0 );
595         digester.addFactoryCreate( "*/xyzSeries/zValueExpression", JRExpressionFactory.NumberExpressionFactory.class );
596         digester.addSetNext( "*/xyzSeries/zValueExpression", "setZValueExpression", JRDesignExpression.class.getName() );
597         digester.addCallMethod( "*/xyzSeries/zValueExpression", "setText", 0 );
598         
599         
600         // time period dataset
601
digester.addFactoryCreate( "*/timePeriodDataset", JRTimePeriodDatasetFactory.class.getName() );
602         digester.addFactoryCreate( "*/timePeriodDataset/timePeriodSeries", JRTimePeriodSeriesFactory.class.getName() );
603         digester.addSetNext( "*/timePeriodDataset/timePeriodSeries", "addTimePeriodSeries", JRDesignTimePeriodSeries.class.getName() );
604         
605         digester.addFactoryCreate("*/timePeriodSeries/seriesExpression", JRExpressionFactory.ComparableExpressionFactory.class);
606         digester.addSetNext("*/timePeriodSeries/seriesExpression", "setSeriesExpression", JRDesignExpression.class.getName());
607         digester.addCallMethod("*/timePeriodSeries/seriesExpression", "setText", 0);
608         digester.addFactoryCreate("*/timePeriodSeries/startDateExpression", JRExpressionFactory.DateExpressionFactory.class);
609         digester.addSetNext("*/timePeriodSeries/startDateExpression", "setStartDateExpression", JRDesignExpression.class.getName());
610         digester.addCallMethod("*/timePeriodSeries/startDateExpression", "setText", 0);
611         digester.addFactoryCreate("*/timePeriodSeries/endDateExpression", JRExpressionFactory.DateExpressionFactory.class);
612         digester.addSetNext("*/timePeriodSeries/endDateExpression", "setEndDateExpression", JRDesignExpression.class.getName());
613         digester.addCallMethod("*/timePeriodSeries/endDateExpression", "setText", 0);
614         digester.addFactoryCreate("*/timePeriodSeries/valueExpression", JRExpressionFactory.NumberExpressionFactory.class);
615         digester.addSetNext("*/timePeriodSeries/valueExpression", "setValueExpression", JRDesignExpression.class.getName());
616         digester.addCallMethod("*/timePeriodSeries/valueExpression", "setText", 0);
617         digester.addFactoryCreate( "*/timePeriodSeries/labelExpression", JRExpressionFactory.StringExpressionFactory.class );
618         digester.addSetNext( "*/timePeriodSeries/labelExpression", "setLabelExpression", JRDesignExpression.class.getName() );
619         digester.addCallMethod( "*/timePeriodSeries/labelExpression", "setText", 0);
620         
621         digester.addFactoryCreate("*/timeSeriesChart", JRTimeSeriesChartFactory.class.getName());
622         digester.addFactoryCreate("*/timeSeriesChart/timeSeriesPlot", JRTimeSeriesPlotFactory.class.getName());
623         digester.addSetNext("*/timeSeriesChart", "addElement", JRDesignElement.class.getName());
624         
625         // add plot labels
626
digester.addFactoryCreate( "*/timeSeriesPlot/timeAxisLabelExpression", JRExpressionFactory.ComparableExpressionFactory.class );
627         digester.addSetNext("*/timeSeriesPlot/timeAxisLabelExpression", "setTimeAxisLabelExpression", JRDesignExpression.class.getName() );
628         digester.addCallMethod( "*/timeSeriesPlot/timeAxisLabelExpression", "setText", 0 );
629         
630         digester.addFactoryCreate( "*/timeSeriesPlot/valueAxisLabelExpression", JRExpressionFactory.ComparableExpressionFactory.class );
631         digester.addSetNext( "*/timeSeriesPlot/valueAxisLabelExpression", "setValueAxisLabelExpression", JRDesignExpression.class.getName() );
632         digester.addCallMethod( "*/timeSeriesPlot/valueAxisLabelExpression", "setText", 0 );
633             
634         // XY bar charts
635
digester.addFactoryCreate("*/xyBarChart", JRXyBarChartFactory.class.getName());
636         digester.addSetNext("*/xyBarChart", "addElement", JRDesignElement.class.getName());
637         digester.addFactoryCreate("*/xyBarChart/barPlot", JRBarPlotFactory.class.getName());
638
639         
640 // time series dataset
641
digester.addFactoryCreate( "*/timeSeriesDataset", JRTimeSeriesDatasetFactory.class.getName() );
642         digester.addFactoryCreate( "*/timeSeriesDataset/timeSeries", JRTimeSeriesFactory.class.getName());
643         digester.addSetNext( "*/timeSeriesDataset/timeSeries", "addTimeSeries", JRDesignTimeSeries.class.getName() );
644         
645         digester.addFactoryCreate("*/timeSeries/seriesExpression", JRExpressionFactory.ComparableExpressionFactory.class);
646         digester.addSetNext("*/timeSeries/seriesExpression", "setSeriesExpression", JRDesignExpression.class.getName());
647         digester.addCallMethod("*/timeSeries/seriesExpression", "setText", 0);
648         digester.addFactoryCreate("*/timeSeries/timePeriodExpression", JRExpressionFactory.DateExpressionFactory.class);
649         digester.addSetNext("*/timeSeries/timePeriodExpression", "setTimePeriodExpression", JRDesignExpression.class.getName());
650         digester.addCallMethod("*/timeSeries/timePeriodExpression", "setText", 0);
651         digester.addFactoryCreate("*/timeSeries/labelExpression", JRExpressionFactory.StringExpressionFactory.class);
652         digester.addSetNext("*/timeSeries/labelExpression", "setLabelExpression", JRDesignExpression.class.getName());
653         digester.addCallMethod("*/timeSeries/labelExpression", "setText", 0);
654         digester.addFactoryCreate("*/timeSeries/valueExpression", JRExpressionFactory.NumberExpressionFactory.class);
655         digester.addSetNext("*/timeSeries/valueExpression", "setValueExpression", JRDesignExpression.class.getName());
656         digester.addCallMethod("*/timeSeries/valueExpression", "setText", 0);
657
658         digester.addFactoryCreate("*/stackedBarChart", JRStackedBarChartFactory.class.getName());
659         digester.addSetNext("*/stackedBarChart", "addElement", JRDesignElement.class.getName());
660         digester.addFactoryCreate("*/stackedBarChart/barPlot", JRBarPlotFactory.class.getName());
661         
662         digester.addFactoryCreate( "*/lineChart", JRLineChartFactory.class.getName() );
663         digester.addSetNext( "*/lineChart", "addElement", JRDesignElement.class.getName() );
664         digester.addFactoryCreate( "*/linePlot", JRLinePlotFactory.class.getName() );
665         
666         
667         //add plot labels
668
digester.addFactoryCreate( "*/linePlot/categoryAxisLabelExpression", JRExpressionFactory.ComparableExpressionFactory.class );
669         digester.addSetNext("*/linePlot/categoryAxisLabelExpression", "setCategoryAxisLabelExpression", JRDesignExpression.class.getName() );
670         digester.addCallMethod( "*/linePlot/categoryAxisLabelExpression", "setText", 0 );
671         
672         digester.addFactoryCreate( "*/linePlot/valueAxisLabelExpression", JRExpressionFactory.ComparableExpressionFactory.class );
673         digester.addSetNext("*/linePlot/valueAxisLabelExpression", "setValueAxisLabelExpression", JRDesignExpression.class.getName() );
674         digester.addCallMethod( "*/linePlot/valueAxisLabelExpression", "setText", 0 );
675         
676     
677         digester.addFactoryCreate( "*/xyLineChart", JRXyLineChartFactory.class.getName() );
678         digester.addSetNext( "*/xyLineChart", "addElement", JRDesignElement.class.getName() );
679     
680         digester.addFactoryCreate( "*/scatterChart", JRScatterChartFactory.class.getName() );
681         digester.addSetNext( "*/scatterChart", "addElement", JRDesignElement.class.getName() );
682         digester.addFactoryCreate( "*/scatterPlot", JRScatterPlotFactory.class.getName() );
683         
684         // add plot labels
685
digester.addFactoryCreate( "*/scatterPlot/xAxisLabelExpression", JRExpressionFactory.ComparableExpressionFactory.class );
686         digester.addSetNext( "*/scatterPlot/xAxisLabelExpression", "setXAxisLabelExpression", JRDesignExpression.class.getName() );
687         digester.addCallMethod( "*scatterPlot/xAxisLabelExpression", "setText", 0 );
688         
689         digester.addFactoryCreate( "*/scatterPlot/yAxisLabelExpression", JRExpressionFactory.ComparableExpressionFactory.class );
690         digester.addSetNext( "*/scatterPlot/yAxisLabelExpression", "setYAxisLabelExpression", JRDesignExpression.class.getName() );
691         digester.addCallMethod( "*/scatterPlot/yAxisLabelExpression", "setText", 0 );
692         
693     
694         digester.addFactoryCreate("*/xyDataset", JRXyDatasetFactory.class.getName());
695         digester.addFactoryCreate("*/xyDataset/xySeries", JRXySeriesFactory.class.getName());
696         digester.addSetNext("*/xyDataset/xySeries", "addXySeries", JRDesignXySeries.class.getName());
697
698         digester.addFactoryCreate("*/xySeries", JRXyDatasetFactory.class.getName());
699         digester.addFactoryCreate("*/xySeries/seriesExpression", JRExpressionFactory.ComparableExpressionFactory.class);
700         digester.addSetNext("*/xySeries/seriesExpression", "setSeriesExpression", JRDesignExpression.class.getName());
701         digester.addCallMethod("*/xySeries/seriesExpression", "setText", 0);
702         digester.addFactoryCreate("*/xySeries/xValueExpression", JRExpressionFactory.NumberExpressionFactory.class);
703         digester.addSetNext("*/xySeries/xValueExpression", "setXValueExpression", JRDesignExpression.class.getName());
704         digester.addCallMethod("*/xySeries/xValueExpression", "setText", 0);
705         digester.addFactoryCreate("*/xySeries/yValueExpression", JRExpressionFactory.NumberExpressionFactory.class);
706         digester.addSetNext("*/xySeries/yValueExpression", "setYValueExpression", JRDesignExpression.class.getName());
707         digester.addCallMethod("*/xySeries/yValueExpression", "setText", 0);
708         digester.addFactoryCreate("*/xySeries/labelExpression", JRExpressionFactory.StringExpressionFactory.class);
709         digester.addSetNext("*/xySeries/labelExpression", "setLabelExpression", JRDesignExpression.class.getName());
710         digester.addCallMethod("*/xySeries/labelExpression", "setText", 0);
711
712         digester.addFactoryCreate("*/stackedBar3DChart", JRStackedBar3DChartFactory.class.getName());
713         digester.addSetNext("*/stackedBar3DChart", "addElement", JRDesignElement.class.getName());
714         digester.addFactoryCreate("*/stackedBar3DChart/bar3DPlot", JRBar3DPlotFactory.class.getName());
715         
716         digester.addFactoryCreate( "*/bubbleChart", JRBubbleChartFactory.class.getName() );
717         digester.addSetNext( "*/bubbleChart", "addElement", JRDesignElement.class.getName() );
718         digester.addFactoryCreate( "*/bubblePlot", JRBubblePlotFactory.class.getName() );
719     
720         // add plot labels
721
digester.addFactoryCreate( "*/bubblePlot/xAxisLabelExpression", JRExpressionFactory.ComparableExpressionFactory.class );
722         digester.addSetNext( "*/bubblePlot/xAxisLabelExpression", "setXAxisLabelExpression", JRDesignExpression.class.getName() );
723         digester.addCallMethod( "*/bubblePlot/xAxisLabelExpression", "setText", 0 );
724         
725         digester.addFactoryCreate( "*/bubblePlot/yAxisLabelExpression", JRExpressionFactory.ComparableExpressionFactory.class );
726         digester.addSetNext( "*/bubblePlot/yAxisLabelExpression", "setYAxisLabelExpression", JRDesignExpression.class.getName() );
727         digester.addCallMethod( "*/bubblePlot/yAxisLabelExpression", "setText", 0 );
728         
729
730         // high-low charts
731
digester.addFactoryCreate("*/highLowChart", JRHighLowChartFactory.class.getName());
732         digester.addSetNext("*/highLowChart", "addElement", JRDesignElement.class.getName());
733         digester.addFactoryCreate("*/highLowChart/highLowPlot", JRHighLowPlotFactory.class.getName());
734         
735         digester.addFactoryCreate( "*/highLowPlot/timeAxisLabelExpression", JRExpressionFactory.ComparableExpressionFactory.class );
736         digester.addSetNext( "*/highLowPlot/timeAxisLabelExpression", "setTimeAxisLabelExpression", JRDesignExpression.class.getName() );
737         digester.addCallMethod( "*/highLowPlot/timeAxisLabelExpression", "setText", 0 );
738         
739         digester.addFactoryCreate( "*/highLowPlot/valueAxisLabelExpression", JRExpressionFactory.ComparableExpressionFactory.class );
740         digester.addSetNext( "*/highLowPlot/valueAxisLabelExpression", "setValueAxisLabelExpression", JRDesignExpression.class.getName() );
741         digester.addCallMethod( "*/highLowPlot/valueAxisLabelExpression", "setText", 0 );
742         
743
744         digester.addFactoryCreate("*/highLowDataset", JRHighLowDatasetFactory.class.getName());
745         digester.addFactoryCreate("*/highLowDataset/seriesExpression", JRExpressionFactory.ComparableExpressionFactory.class);
746         digester.addSetNext("*/highLowDataset/seriesExpression", "setSeriesExpression", JRDesignExpression.class.getName());
747         digester.addCallMethod("*/highLowDataset/seriesExpression", "setText", 0);
748         digester.addFactoryCreate("*/highLowDataset/dateExpression", JRExpressionFactory.DateExpressionFactory.class);
749         digester.addSetNext("*/highLowDataset/dateExpression", "setDateExpression", JRDesignExpression.class.getName());
750         digester.addCallMethod("*/highLowDataset/dateExpression", "setText", 0);
751         digester.addFactoryCreate("*/highLowDataset/highExpression", JRExpressionFactory.NumberExpressionFactory.class);
752         digester.addSetNext("*/highLowDataset/highExpression", "setHighExpression", JRDesignExpression.class.getName());
753         digester.addCallMethod("*/highLowDataset/highExpression", "setText", 0);
754         digester.addFactoryCreate("*/highLowDataset/lowExpression", JRExpressionFactory.NumberExpressionFactory.class);
755         digester.addSetNext("*/highLowDataset/lowExpression", "setLowExpression", JRDesignExpression.class.getName());
756         digester.addCallMethod("*/highLowDataset/lowExpression", "setText", 0);
757         digester.addFactoryCreate("*/highLowDataset/openExpression", JRExpressionFactory.NumberExpressionFactory.class);
758         digester.addSetNext("*/highLowDataset/openExpression", "setOpenExpression", JRDesignExpression.class.getName());
759         digester.addCallMethod("*/highLowDataset/openExpression", "setText", 0);
760         digester.addFactoryCreate("*/highLowDataset/closeExpression", JRExpressionFactory.NumberExpressionFactory.class);
761         digester.addSetNext("*/highLowDataset/closeExpression", "setCloseExpression", JRDesignExpression.class.getName());
762         digester.addCallMethod("*/highLowDataset/closeExpression", "setText", 0);
763         digester.addFactoryCreate("*/highLowDataset/volumeExpression", JRExpressionFactory.NumberExpressionFactory.class);
764         digester.addSetNext("*/highLowDataset/volumeExpression", "setVolumeExpression", JRDesignExpression.class.getName());
765         digester.addCallMethod("*/highLowDataset/volumeExpression", "setText", 0);
766
767         // candlestick charts
768
digester.addFactoryCreate("*/candlestickChart", JRCandlestickChartFactory.class);
769         digester.addSetNext("*/candlestickChart", "addElement", JRDesignElement.class.getName());
770         digester.addFactoryCreate("*/candlestickChart/candlestickPlot", JRCandlestickPlotFactory.class);
771         
772         digester.addFactoryCreate( "*/candlestickPlot/timeAxisLabelExpression", JRExpressionFactory.ComparableExpressionFactory.class );
773         digester.addSetNext( "*/candlestickPlot/timeAxisLabelExpression", "setTimeAxisLabelExpression", JRDesignExpression.class.getName() );
774         digester.addCallMethod( "*/candlestickPlot/timeAxisLabelExpression", "setText", 0 );
775         
776         digester.addFactoryCreate( "*/candlestickPlot/valueAxisLabelExpression", JRExpressionFactory.ComparableExpressionFactory.class );
777         digester.addSetNext( "*/candlestickPlot/valueAxisLabelExpression", "setValueAxisLabelExpression", JRDesignExpression.class.getName() );
778         digester.addCallMethod( "*/candlestickPlot/valueAxisLabelExpression", "setText", 0 );
779         
780         // value datasets
781
digester.addFactoryCreate("*/valueDataset", JRValueDatasetFactory.class.getName());
782         digester.addFactoryCreate("*/valueDataset/valueExpression", JRExpressionFactory.NumberExpressionFactory.class);
783         digester.addSetNext("*/valueDataset/valueExpression", "setValueExpression", JRDesignExpression.class.getName());
784         digester.addCallMethod("*/valueDataset/valueExpression", "setText", 0);
785         
786         // data ranges - anything that contains a data range must have a "setDataRange" method.
787
digester.addFactoryCreate("*/dataRange", JRDataRangeFactory.class.getName());
788         digester.addSetNext("*/dataRange", "setDataRange", JRDesignDataRange.class.getName());
789         digester.addFactoryCreate("*/dataRange/lowExpression", JRExpressionFactory.NumberExpressionFactory.class);
790         digester.addSetNext("*/dataRange/lowExpression", "setLowExpression", JRDesignExpression.class.getName());
791         digester.addCallMethod("*/dataRange/lowExpression", "setText", 0);
792         digester.addFactoryCreate("*/dataRange/highExpression", JRExpressionFactory.NumberExpressionFactory.class);
793         digester.addSetNext("*/dataRange/highExpression", "setHighExpression", JRDesignExpression.class.getName());
794         digester.addCallMethod("*/dataRange/highExpression", "setText", 0);
795
796         // value displays - anything that contains a display value must have a "setValueDisplay" method.
797
digester.addFactoryCreate("*/valueDisplay", JRValueDisplayFactory.class.getName());
798         digester.addSetNext("*/valueDisplay", "setValueDisplay", JRDesignValueDisplay.class.getName());
799         digester.addFactoryCreate("*/valueDisplay/font", JRFontFactory.ChartFontFactory.class.getName());
800         digester.addSetNext("*/valueDisplay/font", "setFont", JRFont.class.getName());
801         
802         // meter charts
803
digester.addFactoryCreate("*/meterChart", JRMeterChartFactory.class.getName());
804         digester.addSetNext("*/meterChart", "addElement", JRDesignElement.class.getName());
805         digester.addFactoryCreate("*/meterChart/meterPlot", JRMeterPlotFactory.class.getName());
806         
807         digester.addFactoryCreate("*/meterPlot/lowExpression", JRExpressionFactory.NumberExpressionFactory.class);
808         digester.addSetNext("*/meterPlot/lowExpression", "setLowExpression", JRDesignExpression.class.getName());
809         digester.addCallMethod("*/meterPlot/lowExpression", "setText", 0);
810         digester.addFactoryCreate("*/meterPlot/highExpression", JRExpressionFactory.NumberExpressionFactory.class);
811         digester.addSetNext("*/meterPlot/highExpression", "setHighExpression", JRDesignExpression.class.getName());
812         digester.addCallMethod("*/meterPlot/highExpression", "setText", 0);
813         
814         digester.addFactoryCreate("*/meterPlot/meterInterval", JRMeterIntervalFactory.class.getName());
815         digester.addSetNext("*/meterPlot/meterInterval", "addInterval", JRMeterInterval.class.getName());
816         
817         // thermometer charts
818
digester.addFactoryCreate("*/thermometerChart", JRThermometerChartFactory.class.getName());
819         digester.addSetNext("*/thermometerChart", "addElement", JRDesignElement.class.getName());
820         digester.addFactoryCreate("*/thermometerChart/thermometerPlot", JRThermometerPlotFactory.class.getName());
821         
822         digester.addFactoryCreate("*/thermometerPlot/lowRange/dataRange", JRDataRangeFactory.class.getName());
823         digester.addSetNext("*/thermometerPlot/lowRange/dataRange", "setLowRange", JRDesignDataRange.class.getName());
824         digester.addFactoryCreate("*/thermometerPlot/mediumRange/dataRange", JRDataRangeFactory.class.getName());
825         digester.addSetNext("*/thermometerPlot/mediumRange/dataRange", "setMediumRange", JRDesignDataRange.class.getName());
826         digester.addFactoryCreate("*/thermometerPlot/highRange/dataRange", JRDataRangeFactory.class.getName());
827         digester.addSetNext("*/thermometerPlot/highRange/dataRange", "setHighRange", JRDesignDataRange.class.getName());
828     
829         //multi axis charts
830
digester.addFactoryCreate("*/multiAxisChart", JRMultiAxisChartFactory.class.getName());
831         digester.addSetNext("*/multiAxisChart", "addElement", JRDesignElement.class.getName());
832         digester.addFactoryCreate("*/multiAxisChart/multiAxisPlot", JRMultiAxisPlotFactory.class.getName());
833         digester.addFactoryCreate("*/axis", JRChartAxisFactory.class.getName());
834         digester.addSetNext("*/axis", "addAxis", JRChartAxis.class.getName());
835     }
836
837
838     private static void addDatasetRules(Digester digester)
839     {
840         String JavaDoc subDatasetPattern = "jasperReport/" + JRDatasetFactory.ELEMENT_subDataset;
841         digester.addFactoryCreate(subDatasetPattern, JRDatasetFactory.class.getName());
842         digester.addSetNext(subDatasetPattern, "addDataset", JRDesignDataset.class.getName());
843         
844         String JavaDoc datasetRunPattern = "*/dataset/" + JRDatasetRunFactory.ELEMENT_datasetRun;
845         digester.addFactoryCreate(datasetRunPattern, JRDatasetRunFactory.class.getName());
846         digester.addSetNext(datasetRunPattern, "setDatasetRun", JRDatasetRun.class.getName());
847         
848         String JavaDoc datasetParamPattern = datasetRunPattern + "/" + JRDatasetRunParameterFactory.ELEMENT_datasetParameter;
849         digester.addFactoryCreate(datasetParamPattern, JRDatasetRunParameterFactory.class.getName());
850         digester.addSetNext(datasetParamPattern, "addParameter", JRDatasetParameter.class.getName());
851         
852         String JavaDoc datasetParamExprPattern = datasetParamPattern + "/" + JRDatasetRunParameterExpressionFactory.ELEMENT_datasetParameterExpression;
853         digester.addFactoryCreate(datasetParamExprPattern, JRDatasetRunParameterExpressionFactory.class.getName());
854         digester.addSetNext(datasetParamExprPattern, "setExpression", JRExpression.class.getName());
855         digester.addCallMethod(datasetParamExprPattern, "setText", 0);
856     }
857
858
859     private static void addCrosstabRules(Digester digester)
860     {
861         digester.addFactoryCreate("*/crosstab", JRCrosstabFactory.class.getName());
862         digester.addSetNext("*/crosstab", "addElement", JRDesignElement.class.getName());
863         
864         digester.addFactoryCreate("*/crosstab/crosstabParameter", JRCrosstabParameterFactory.class.getName());
865         digester.addSetNext("*/crosstab/crosstabParameter", "addParameter", JRCrosstabParameter.class.getName());
866
867         digester.addFactoryCreate("*/crosstab/crosstabParameter/parameterValueExpression", JRCrosstabParameterValueExpressionFactory.class.getName());
868         digester.addSetNext("*/crosstab/crosstabParameter/parameterValueExpression", "setExpression", JRExpression.class.getName());
869         digester.addCallMethod("*/crosstab/crosstabParameter/parameterValueExpression", "setText", 0);
870
871         digester.addFactoryCreate("*/crosstab/crosstabDataset", JRCrosstabDatasetFactory.class.getName());
872         
873         digester.addFactoryCreate("*/crosstab/rowGroup", JRCrosstabRowGroupFactory.class.getName());
874         digester.addSetNext("*/crosstab/rowGroup", "addRowGroup", JRDesignCrosstabRowGroup.class.getName());
875         
876         digester.addFactoryCreate("*/crosstab/rowGroup/crosstabRowHeader/cellContents", JRCellContentsFactory.class.getName());
877         digester.addSetNext("*/crosstab/rowGroup/crosstabRowHeader/cellContents", "setHeader", JRDesignCellContents.class.getName());
878         
879         digester.addFactoryCreate("*/crosstab/rowGroup/crosstabTotalRowHeader/cellContents", JRCellContentsFactory.class.getName());
880         digester.addSetNext("*/crosstab/rowGroup/crosstabTotalRowHeader/cellContents", "setTotalHeader", JRDesignCellContents.class.getName());
881         
882         digester.addFactoryCreate("*/crosstab/columnGroup", JRCrosstabColumnGroupFactory.class.getName());
883         digester.addSetNext("*/crosstab/columnGroup", "addColumnGroup", JRDesignCrosstabColumnGroup.class.getName());
884         
885         digester.addFactoryCreate("*/crosstab/columnGroup/crosstabColumnHeader/cellContents", JRCellContentsFactory.class.getName());
886         digester.addSetNext("*/crosstab/columnGroup/crosstabColumnHeader/cellContents", "setHeader", JRDesignCellContents.class.getName());
887         
888         digester.addFactoryCreate("*/crosstab/columnGroup/crosstabTotalColumnHeader/cellContents", JRCellContentsFactory.class.getName());
889         digester.addSetNext("*/crosstab/columnGroup/crosstabTotalColumnHeader/cellContents", "setTotalHeader", JRDesignCellContents.class.getName());
890         
891         digester.addFactoryCreate("*/bucket", JRCrosstabBucketFactory.class.getName());
892         digester.addSetNext("*/bucket", "setBucket", JRDesignCrosstabBucket.class.getName());
893         
894         digester.addFactoryCreate("*/bucket/bucketExpression", JRCrosstabBucketExpressionFactory.class.getName());
895         digester.addSetNext("*/bucket/bucketExpression", "setExpression", JRDesignExpression.class.getName());
896         digester.addCallMethod("*/bucket/bucketExpression", "setText", 0);
897         
898         digester.addFactoryCreate("*/bucket/comparatorExpression", JRExpressionFactory.ComparatorExpressionFactory.class.getName());
899         digester.addSetNext("*/bucket/comparatorExpression", "setComparatorExpression", JRExpression.class.getName());
900         digester.addCallMethod("*/bucket/comparatorExpression", "setText", 0);
901
902         digester.addFactoryCreate("*/crosstab/measure", JRCrosstabMeasureFactory.class.getName());
903         digester.addSetNext("*/crosstab/measure", "addMeasure", JRDesignCrosstabMeasure.class.getName());
904         
905         digester.addFactoryCreate("*/crosstab/measure/measureExpression", JRCrosstabMeasureExpressionFactory.class.getName());
906         digester.addSetNext("*/crosstab/measure/measureExpression", "setValueExpression", JRExpression.class.getName());
907         digester.addCallMethod("*/crosstab/measure/measureExpression", "setText", 0);
908         
909         digester.addFactoryCreate("*/crosstab/crosstabCell", JRCrosstabCellFactory.class.getName());
910         digester.addSetNext("*/crosstab/crosstabCell", "addCell", JRDesignCrosstabCell.class.getName());
911         digester.addFactoryCreate("*/crosstab/crosstabCell/cellContents", JRCellContentsFactory.class.getName());
912         digester.addSetNext("*/crosstab/crosstabCell/cellContents", "setContents", JRDesignCellContents.class.getName());
913         
914         digester.addFactoryCreate("*/crosstab/whenNoDataCell/cellContents", JRCellContentsFactory.class.getName());
915         digester.addSetNext("*/crosstab/whenNoDataCell/cellContents", "setWhenNoDataCell", JRDesignCellContents.class.getName());
916         
917         digester.addFactoryCreate("*/crosstab/crosstabHeaderCell/cellContents", JRCellContentsFactory.class.getName());
918         digester.addSetNext("*/crosstab/crosstabHeaderCell/cellContents", "setHeaderCell", JRDesignCellContents.class.getName());
919         
920         digester.addFactoryCreate("*/cellContents/box", JRBaseBoxFactory.class.getName());
921         digester.addSetNext("*/cellContents/box", "setBox", JRBox.class.getName());
922     }
923
924
925     private static void addFrameRules(Digester digester)
926     {
927         String JavaDoc framePattern = "*/" + JRFrameFactory.ELEMENT_frame;
928         digester.addFactoryCreate(framePattern, JRFrameFactory.class.getName());
929         digester.addSetNext(framePattern, "addElement", JRDesignElement.class.getName());
930     }
931
932
933     private static void addHyperlinkParameterRules(Digester digester)
934     {
935         String JavaDoc hyperlinkParameterPattern = "*/" + JRHyperlinkParameterFactory.ELEMENT_hyperlinkParameter;
936         digester.addFactoryCreate(hyperlinkParameterPattern, JRHyperlinkParameterFactory.class.getName());
937         digester.addSetNext(hyperlinkParameterPattern, "addHyperlinkParameter", JRHyperlinkParameter.class.getName());
938
939         String JavaDoc hyperlinkParameterExpressionPattern = hyperlinkParameterPattern + '/' + JRHyperlinkParameterExpressionFactory.ELEMENT_hyperlinkParameterExpression;
940         digester.addFactoryCreate(hyperlinkParameterExpressionPattern, JRHyperlinkParameterExpressionFactory.class.getName());
941         digester.addSetNext(hyperlinkParameterExpressionPattern, "setValueExpression", JRExpression.class.getName());
942         digester.addCallMethod(hyperlinkParameterExpressionPattern, "setText", 0);
943
944     }
945     
946     
947     /**
948      * Creates a new instance of digester. The created digester is ready for
949      * parsing report definition files.
950      */

951     public static JRXmlDigester createDigester() throws ParserConfigurationException JavaDoc, SAXException JavaDoc
952     {
953         JRXmlDigester digester = new JRXmlDigester();
954         configureDigester(digester);
955         return digester;
956     }
957     
958
959     /**
960      *
961      */

962     private static class ErrorHandlerImpl implements ErrorHandler JavaDoc
963     {
964         /**
965          * @see org.xml.sax.ErrorHandler#error(org.xml.sax.SAXParseException)
966          */

967         public void error(SAXParseException JavaDoc exception) throws SAXException JavaDoc
968         {
969             throw exception;
970         }
971
972         /**
973          * @see org.xml.sax.ErrorHandler#fatalError(org.xml.sax.SAXParseException)
974          */

975         public void fatalError(SAXParseException JavaDoc exception) throws SAXException JavaDoc
976         {
977             throw exception;
978         }
979
980         /**
981          * @see org.xml.sax.ErrorHandler#warning(org.xml.sax.SAXParseException)
982          */

983         public void warning(SAXParseException JavaDoc exception) throws SAXException JavaDoc
984         {
985             throw exception;
986         }
987     }
988     
989 }
990
Popular Tags