KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sf > jasperreports > engine > fill > JRBaseFiller


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
29 /*
30  * Contributors:
31  * John Bindel - jbindel@users.sourceforge.net
32  */

33
34 package net.sf.jasperreports.engine.fill;
35
36 import java.net.URLStreamHandlerFactory JavaDoc;
37 import java.sql.Connection JavaDoc;
38 import java.text.Format JavaDoc;
39 import java.util.ArrayList JavaDoc;
40 import java.util.HashMap JavaDoc;
41 import java.util.HashSet JavaDoc;
42 import java.util.Iterator JavaDoc;
43 import java.util.List JavaDoc;
44 import java.util.ListIterator JavaDoc;
45 import java.util.Locale JavaDoc;
46 import java.util.Map JavaDoc;
47 import java.util.Set JavaDoc;
48 import java.util.TimeZone JavaDoc;
49
50 import net.sf.jasperreports.engine.JRAbstractScriptlet;
51 import net.sf.jasperreports.engine.JRBand;
52 import net.sf.jasperreports.engine.JRConstants;
53 import net.sf.jasperreports.engine.JRDataSource;
54 import net.sf.jasperreports.engine.JRDataset;
55 import net.sf.jasperreports.engine.JRDefaultStyleProvider;
56 import net.sf.jasperreports.engine.JRException;
57 import net.sf.jasperreports.engine.JRExpression;
58 import net.sf.jasperreports.engine.JRGroup;
59 import net.sf.jasperreports.engine.JRParameter;
60 import net.sf.jasperreports.engine.JRPrintElement;
61 import net.sf.jasperreports.engine.JRPrintPage;
62 import net.sf.jasperreports.engine.JRReport;
63 import net.sf.jasperreports.engine.JRReportFont;
64 import net.sf.jasperreports.engine.JRRuntimeException;
65 import net.sf.jasperreports.engine.JRStyle;
66 import net.sf.jasperreports.engine.JRVirtualizer;
67 import net.sf.jasperreports.engine.JasperPrint;
68 import net.sf.jasperreports.engine.JasperReport;
69 import net.sf.jasperreports.engine.base.JRBasePrintPage;
70 import net.sf.jasperreports.engine.base.JRVirtualPrintPage;
71 import net.sf.jasperreports.engine.util.DefaultFormatFactory;
72 import net.sf.jasperreports.engine.util.FormatFactory;
73 import net.sf.jasperreports.engine.util.JRDataUtils;
74 import net.sf.jasperreports.engine.util.JRGraphEnvInitializer;
75 import net.sf.jasperreports.engine.util.JRResourcesUtil;
76 import net.sf.jasperreports.engine.util.JRStyledTextParser;
77
78
79 /**
80  * @author Teodor Danciu (teodord@users.sourceforge.net)
81  * @version $Id: JRBaseFiller.java 1500 2006-11-21 18:10:31 +0200 (Tue, 21 Nov 2006) teodord $
82  */

83 public abstract class JRBaseFiller implements JRDefaultStyleProvider, JRVirtualPrintPage.IdentityDataProvider//, JRDefaultFontProvider
84
{
85
86     /**
87      * Map class to be used for bound elements.
88      * <p/>
89      * Keeps print elements to fill elements maps.
90      * If per page element maps are used, such maps are kept per page.
91      *
92      * @author John Bindel
93      */

94     public class BoundElementMap
95     {
96         private static final long serialVersionUID = JRConstants.SERIAL_VERSION_UID;
97
98         private final Map JavaDoc map;
99
100         BoundElementMap()
101         {
102             map = new HashMap JavaDoc();
103         }
104
105         /**
106          * Keep track of the objects per page for our virtualizer.
107          */

108         public Object JavaDoc put(Object JavaDoc key, Object JavaDoc value, JRPrintPage keyPage)
109         {
110             Map JavaDoc pageMap = (Map JavaDoc) map.get(keyPage);
111             if (pageMap == null)
112             {
113                 pageMap = new HashMap JavaDoc();
114                 map.put(keyPage, pageMap);
115             }
116
117             return pageMap.put(key, value);
118         }
119
120         /**
121          * If per page map is required, the entry will also be added for the
122          * current print page.
123          */

124         public Object JavaDoc put(Object JavaDoc key, Object JavaDoc value)
125         {
126             if (isPerPageBoundElements)
127             {
128                 return put(key, value, fillContext.getPrintPage());
129             }
130
131             return map.put(key, value);
132         }
133
134         public void clear()
135         {
136             map.clear();
137         }
138
139         public Map JavaDoc getMap()
140         {
141             return map;
142         }
143
144         public Map JavaDoc getMap(JRPrintPage page)
145         {
146             return (Map JavaDoc) map.get(page);
147         }
148
149         public Map JavaDoc putMap(JRPrintPage page, Map JavaDoc valueMap)
150         {
151             return (Map JavaDoc) map.put(page, valueMap);
152         }
153     }
154
155     /**
156      *
157      */

158     protected JRBaseFiller parentFiller = null;
159
160     private JRStyledTextParser styledTextParser = new JRStyledTextParser();
161
162     /**
163      *
164      */

165     private boolean isInterrupted = false;
166
167     /**
168      *
169      */

170     protected String JavaDoc name = null;
171
172     protected int columnCount = 1;
173
174     protected byte printOrder = JRReport.PRINT_ORDER_VERTICAL;
175
176     protected int pageWidth = 0;
177
178     protected int pageHeight = 0;
179
180     protected byte orientation = JRReport.ORIENTATION_PORTRAIT;
181
182     protected byte whenNoDataType = JRReport.WHEN_NO_DATA_TYPE_NO_PAGES;
183
184     protected int columnWidth = 0;
185
186     protected int columnSpacing = 0;
187
188     protected int leftMargin = 0;
189
190     protected int rightMargin = 0;
191
192     protected int topMargin = 0;
193
194     protected int bottomMargin = 0;
195
196     protected boolean isTitleNewPage = false;
197
198     protected boolean isSummaryNewPage = false;
199
200     protected boolean isFloatColumnFooter = false;
201
202     /**
203      * the resource missing handling type
204      */

205     protected byte whenResourceMissingType = JRReport.WHEN_RESOURCE_MISSING_TYPE_NULL;
206
207     protected JRReportFont defaultFont = null;
208
209     protected JRReportFont[] fonts = null;
210
211     protected JRStyle defaultStyle = null;
212
213     protected JRStyle[] styles = null;
214
215     /**
216      * Main report dataset.
217      */

218     protected JRFillDataset mainDataset;
219
220     protected JRFillGroup[] groups = null;
221
222     protected JRFillBand missingFillBand = null;
223
224     protected JRFillBand background = null;
225
226     protected JRFillBand title = null;
227
228     protected JRFillBand pageHeader = null;
229
230     protected JRFillBand columnHeader = null;
231
232     protected JRFillBand detail = null;
233
234     protected JRFillBand columnFooter = null;
235
236     protected JRFillBand pageFooter = null;
237
238     protected JRFillBand lastPageFooter = null;
239
240     protected JRFillBand summary = null;
241
242     protected JRVirtualizer virtualizer = null;
243
244     protected ClassLoader JavaDoc reportClassLoader = null;
245
246     protected FormatFactory formatFactory = null;
247     
248     protected URLStreamHandlerFactory JavaDoc urlHandlerFactory;
249
250     protected Map JavaDoc loadedSubreports = null;
251
252     protected JRFillContext fillContext;
253
254     /**
255      * Bound element maps indexed by {@link JREvaluationTime JREvaluationTime} objects.
256      */

257     protected Map JavaDoc boundElements;
258
259     /**
260      *
261      */

262     protected JasperPrint jasperPrint = null;
263
264     protected JRPrintPage printPage = null;
265
266     protected int printPageStretchHeight = 0;
267
268     /**
269      * List of {@link JRFillBand JRFillBand} objects containing all bands of the
270      * report.
271      */

272     protected List JavaDoc bands;
273
274     /**
275      * Collection of subfillers
276      */

277     protected Set JavaDoc subfillers;
278
279     private List JavaDoc identityPages;
280
281     private Thread JavaDoc fillingThread;
282
283     protected JRCalculator calculator;
284
285     protected JRAbstractScriptlet scriptlet;
286
287     /**
288      * Map of datasets ({@link JRFillDataset JRFillDataset} objects} indexed by name.
289      */

290     protected Map JavaDoc datasetMap;
291
292     /**
293      * The report.
294      */

295     protected JasperReport jasperReport;
296
297     private boolean bandOverFlowAllowed;
298
299     protected boolean isPerPageBoundElements;
300
301     /**
302      *
303      */

304     protected Map JavaDoc dateFormatCache = new HashMap JavaDoc();
305     protected Map JavaDoc numberFormatCache = new HashMap JavaDoc();
306     
307     private JRSubreportRunner subreportRunner;
308
309
310     /**
311      *
312      */

313     protected boolean isCreatingNewPage = false;
314     protected boolean isNewPage = false;
315     protected boolean isNewColumn = false;
316     protected boolean isNewGroup = true;
317
318     protected int columnIndex = 0;
319
320     protected int offsetX = 0;
321     protected int offsetY = 0;
322     protected int columnHeaderOffsetY = 0;
323     protected int columnFooterOffsetY = 0;
324     protected int lastPageColumnFooterOffsetY = 0;
325
326     protected boolean isLastPageFooter = false;
327
328     
329     /**
330      *
331      */

332     protected JRBaseFiller(JasperReport jasperReport, JREvaluator initEvaluator, JRBaseFiller parentFiller) throws JRException
333     {
334         JRGraphEnvInitializer.initializeGraphEnv();
335
336         this.jasperReport = jasperReport;
337
338         /* */
339         this.parentFiller = parentFiller;
340
341         if (parentFiller == null)
342         {
343             fillContext = new JRFillContext();
344         }
345         else
346         {
347             fillContext = parentFiller.fillContext;
348         }
349
350         /* */
351         name = jasperReport.getName();
352         columnCount = jasperReport.getColumnCount();
353         printOrder = jasperReport.getPrintOrder();
354         pageWidth = jasperReport.getPageWidth();
355         pageHeight = jasperReport.getPageHeight();
356         orientation = jasperReport.getOrientation();
357         whenNoDataType = jasperReport.getWhenNoDataType();
358         columnWidth = jasperReport.getColumnWidth();
359         columnSpacing = jasperReport.getColumnSpacing();
360         leftMargin = jasperReport.getLeftMargin();
361         rightMargin = jasperReport.getRightMargin();
362         topMargin = jasperReport.getTopMargin();
363         bottomMargin = jasperReport.getBottomMargin();
364         isTitleNewPage = jasperReport.isTitleNewPage();
365         isSummaryNewPage = jasperReport.isSummaryNewPage();
366         isFloatColumnFooter = jasperReport.isFloatColumnFooter();
367         whenResourceMissingType = jasperReport.getWhenResourceMissingType();
368
369         jasperPrint = new JasperPrint();
370
371         if (initEvaluator == null)
372         {
373             calculator = JRFillDataset.createCalculator(jasperReport, jasperReport.getMainDataset());
374         }
375         else
376         {
377             calculator = new JRCalculator(initEvaluator);
378         }
379
380         /* */
381         JRFillObjectFactory factory = new JRFillObjectFactory(this);
382
383         /* */
384         defaultFont = factory.getReportFont(jasperReport.getDefaultFont());
385
386         /* */
387         JRReportFont[] jrFonts = jasperReport.getFonts();
388         if (jrFonts != null && jrFonts.length > 0)
389         {
390             fonts = new JRReportFont[jrFonts.length];
391             for (int i = 0; i < fonts.length; i++)
392             {
393                 fonts[i] = factory.getReportFont(jrFonts[i]);
394             }
395         }
396
397         createDatasets(factory);
398         mainDataset = factory.getDataset(jasperReport.getMainDataset());
399         groups = mainDataset.groups;
400
401         /* */
402         defaultStyle = factory.getStyle(jasperReport.getDefaultStyle());
403
404         /* */
405         JRStyle[] jrStyles = jasperReport.getStyles();
406         if (jrStyles != null && jrStyles.length > 0)
407         {
408             styles = new JRStyle[jrStyles.length];
409             for (int i = 0; i < styles.length; i++)
410             {
411                 styles[i] = factory.getStyle(jrStyles[i]);
412             }
413         }
414
415         /* */
416         missingFillBand = factory.getBand(null);
417         background = factory.getBand(jasperReport.getBackground());
418         title = factory.getBand(jasperReport.getTitle());
419         pageHeader = factory.getBand(jasperReport.getPageHeader());
420         columnHeader = factory.getBand(jasperReport.getColumnHeader());
421         detail = factory.getBand(jasperReport.getDetail());
422         columnFooter = factory.getBand(jasperReport.getColumnFooter());
423         pageFooter = factory.getBand(jasperReport.getPageFooter());
424         lastPageFooter = factory.getBand(jasperReport.getLastPageFooter());
425         if (isEmpty(jasperReport.getSummary()))
426         {
427             summary = missingFillBand;
428         }
429         else
430         {
431             summary = factory.getBand(jasperReport.getSummary());
432         }
433
434         mainDataset.initElementDatasets(factory);
435         initDatasets(factory);
436
437         mainDataset.checkVariableCalculationReqs(factory);
438
439         /* */
440         mainDataset.setCalculator(calculator);
441         mainDataset.initCalculator();
442
443         initBands();
444     }
445
446
447     /**
448      * Returns the report parameters indexed by name.
449      *
450      * @return the report parameters map
451      */

452     protected Map JavaDoc getParametersMap()
453     {
454         return mainDataset.parametersMap;
455     }
456
457
458     /**
459      * Returns the report fields indexed by name.
460      *
461      * @return the report fields map
462      */

463     protected Map JavaDoc getFieldsMap()
464     {
465         return mainDataset.fieldsMap;
466     }
467
468
469     /**
470      * Returns the report variables indexed by name.
471      *
472      * @return the report variables map
473      */

474     protected Map JavaDoc getVariablesMap()
475     {
476         return mainDataset.variablesMap;
477     }
478
479
480     /**
481      * Returns a report variable.
482      *
483      * @param variableName the variable name
484      * @return the variable
485      */

486     protected JRFillVariable getVariable(String JavaDoc variableName)
487     {
488         return (JRFillVariable) mainDataset.variablesMap.get(variableName);
489     }
490
491
492     /**
493      * Returns a report field.
494      *
495      * @param fieldName the field name
496      * @return the field
497      */

498     protected JRFillField getField(String JavaDoc fieldName)
499     {
500         return (JRFillField) mainDataset.fieldsMap.get(fieldName);
501     }
502
503     private void initBands()
504     {
505         bands = new ArrayList JavaDoc(8 + (groups == null ? 0 : (2 * groups.length)));
506         bands.add(title);
507         bands.add(summary);
508         bands.add(pageHeader);
509         bands.add(pageFooter);
510         bands.add(lastPageFooter);
511         bands.add(columnHeader);
512         bands.add(columnFooter);
513         bands.add(detail);
514
515         if (groups != null && groups.length > 0)
516         {
517             for (int i = 0; i < groups.length; i++)
518             {
519                 JRFillGroup group = groups[i];
520                 bands.add(group.getGroupHeader());
521                 bands.add(group.getGroupFooter());
522             }
523         }
524
525         initBandsNowEvaluationTimes();
526     }
527
528
529     private void initBandsNowEvaluationTimes()
530     {
531         JREvaluationTime[] groupEvaluationTimes;
532         if (groups == null)
533         {
534             groupEvaluationTimes = new JREvaluationTime[0];
535         }
536         else
537         {
538             groupEvaluationTimes = new JREvaluationTime[groups.length];
539             for (int i = 0; i < groups.length; i++)
540             {
541                 groupEvaluationTimes[i] = JREvaluationTime.getGroupEvaluationTime(groups[i].getName());
542             }
543
544             for (int i = 0; i < groups.length; i++)
545             {
546                 JRGroup group = groups[i];
547                 JRFillBand footer = (JRFillBand) group.getGroupFooter();
548
549                 for (int j = i; j < groupEvaluationTimes.length; ++j)
550                 {
551                     footer.addNowEvaluationTime(groupEvaluationTimes[j]);
552                 }
553             }
554         }
555
556         columnFooter.addNowEvaluationTime(JREvaluationTime.EVALUATION_TIME_COLUMN);
557
558         pageFooter.addNowEvaluationTime(JREvaluationTime.EVALUATION_TIME_COLUMN);
559         pageFooter.addNowEvaluationTime(JREvaluationTime.EVALUATION_TIME_PAGE);
560
561         summary.addNowEvaluationTimes(groupEvaluationTimes);
562     }
563
564
565     /**
566      *
567      */

568     public JRStyledTextParser getStyledTextParser()
569     {
570         return styledTextParser;
571     }
572
573     /**
574      *
575      */

576     public JasperPrint getJasperPrint()
577     {
578         return jasperPrint;
579     }
580
581     /**
582      *
583      */

584     public JRReportFont getDefaultFont()
585     {
586         return defaultFont;
587     }
588
589     /**
590      *
591      */

592     public JRStyle getDefaultStyle()
593     {
594         return defaultStyle;
595     }
596
597     /**
598      *
599      */

600     protected boolean isSubreport()
601     {
602         return (parentFiller != null);
603     }
604
605     /**
606      *
607      */

608     protected boolean isInterrupted()
609     {
610         return (isInterrupted || (parentFiller != null && parentFiller.isInterrupted()));
611     }
612
613     /**
614      *
615      */

616     protected void setInterrupted(boolean isInterrupted)
617     {
618         this.isInterrupted = isInterrupted;
619     }
620
621     /**
622      *
623      */

624     protected JRPrintPage getCurrentPage()
625     {
626         return printPage;
627     }
628
629     /**
630      *
631      */

632     protected JRReportFont[] getFonts()
633     {
634         return fonts;
635     }
636
637     /**
638      *
639      */

640     protected int getCurrentPageStretchHeight()
641     {
642         return printPageStretchHeight;
643     }
644
645     /**
646      *
647      */

648     protected abstract void setPageHeight(int pageHeight);
649
650
651     public JasperPrint fill(Map JavaDoc parameterValues, Connection JavaDoc conn) throws JRException
652     {
653         if (parameterValues == null)
654         {
655             parameterValues = new HashMap JavaDoc();
656         }
657
658         setConnectionParameterValue(parameterValues, conn);
659
660         return fill(parameterValues);
661     }
662
663
664     protected void setConnectionParameterValue(Map JavaDoc parameterValues, Connection JavaDoc conn)
665     {
666         mainDataset.setConnectionParameterValue(parameterValues, conn);
667     }
668
669
670     public JasperPrint fill(Map JavaDoc parameterValues, JRDataSource ds) throws JRException
671     {
672         if (parameterValues == null)
673         {
674             parameterValues = new HashMap JavaDoc();
675         }
676
677         setDatasourceParameterValue(parameterValues, ds);
678
679         return fill(parameterValues);
680     }
681
682
683     protected void setDatasourceParameterValue(Map JavaDoc parameterValues, JRDataSource ds)
684     {
685         mainDataset.setDatasourceParameterValue(parameterValues, ds);
686     }
687
688
689     public JasperPrint fill(Map JavaDoc parameterValues) throws JRException
690     {
691         if (parameterValues == null)
692         {
693             parameterValues = new HashMap JavaDoc();
694         }
695
696         fillingThread = Thread.currentThread();
697         boolean urlHandlerFactorySet = false;
698         boolean classLoaderSet = false;
699         try
700         {
701             /* */
702             setParameters(parameterValues);
703
704             classLoaderSet = setClassLoader(parameterValues);
705             urlHandlerFactorySet = setUrlHandlerFactory(parameterValues);
706
707             if (parentFiller != null)
708             {
709                 parentFiller.registerSubfiller(this);
710             }
711
712             jasperPrint.setName(name);
713             jasperPrint.setPageWidth(pageWidth);
714             jasperPrint.setPageHeight(pageHeight);
715             jasperPrint.setOrientation(orientation);
716
717             jasperPrint.setDefaultFont(defaultFont);
718             
719             jasperPrint.setFormatFactoryClass(jasperReport.getFormatFactoryClass());
720             jasperPrint.setLocaleCode(JRDataUtils.getLocaleCode(getLocale()));
721             jasperPrint.setTimeZoneId(JRDataUtils.getTimeZoneId(getTimeZone()));
722
723             /* */
724             if (fonts != null && fonts.length > 0)
725             {
726                 for (int i = 0; i < fonts.length; i++)
727                 {
728                     jasperPrint.addFont(fonts[i], true);
729                 }
730             }
731
732             jasperPrint.setDefaultStyle(defaultStyle);
733
734             /* */
735             if (styles != null && styles.length > 0)
736             {
737                 for (int i = 0; i < styles.length; i++)
738                 {
739                     jasperPrint.addStyle(styles[i], true);
740                 }
741             }
742
743             loadedSubreports = new HashMap JavaDoc();
744
745             createBoundElemementMaps();
746
747             /* */
748             mainDataset.start();
749
750             /* */
751             fillReport();
752
753             // add consolidates styles as normal styles in the print object
754
// for (Iterator it = consolidatedStyles.values().iterator(); it.hasNext();)
755
// {
756
// jasperPrint.addStyle((JRStyle) it.next());
757
// }
758

759             return jasperPrint;
760         }
761         finally
762         {
763             mainDataset.closeDatasource();
764
765             if (parentFiller != null)
766             {
767                 parentFiller.unregisterSubfiller(this);
768             }
769
770             fillingThread = null;
771
772             //kill the subreport filler threads
773
killSubfillerThreads();
774             
775             if (classLoaderSet)
776             {
777                 JRResourcesUtil.resetClassLoader();
778             }
779
780             if (urlHandlerFactorySet)
781             {
782                 JRResourcesUtil.resetThreadURLHandlerFactory();
783             }
784         }
785     }
786
787
788     private void createBoundElemementMaps()
789     {
790         boundElements = new HashMap JavaDoc();
791
792         createBoundElementMaps(JREvaluationTime.EVALUATION_TIME_REPORT);
793         createBoundElementMaps(JREvaluationTime.EVALUATION_TIME_PAGE);
794         createBoundElementMaps(JREvaluationTime.EVALUATION_TIME_COLUMN);
795
796         if (groups != null)
797         {
798             for (int i = 0; i < groups.length; i++)
799             {
800                 createBoundElementMaps(JREvaluationTime.getGroupEvaluationTime(groups[i].getName()));
801             }
802         }
803
804         for (Iterator JavaDoc i = bands.iterator(); i.hasNext();)
805         {
806             JRFillBand band = (JRFillBand) i.next();
807             createBoundElementMaps(JREvaluationTime.getBandEvaluationTime(band));
808         }
809     }
810
811
812     private void createBoundElementMaps(JREvaluationTime evaluationTime)
813     {
814         BoundElementMap boundElementsMap = new BoundElementMap();
815         boundElements.put(evaluationTime, boundElementsMap);
816     }
817
818
819     private void killSubfillerThreads()
820     {
821         if (subfillers != null && !subfillers.isEmpty())
822         {
823             for (Iterator JavaDoc it = subfillers.iterator(); it.hasNext();)
824             {
825                 JRBaseFiller subfiller = (JRBaseFiller) it.next();
826                 if (subfiller.fillingThread != null)
827                 {
828                     subfiller.fillingThread.interrupt();
829                 }
830             }
831         }
832     }
833
834
835     /**
836      *
837      */

838     protected abstract void fillReport() throws JRException;
839
840     /**
841      *
842      */

843     protected void setParameters(Map JavaDoc parameterValues) throws JRException
844     {
845         if (!isSubreport())
846         {
847             /* Virtualizer */
848             virtualizer = (JRVirtualizer) parameterValues.get(JRParameter.REPORT_VIRTUALIZER);
849
850             if (virtualizer != null)
851             {
852                 fillContext.setUsingVirtualizer(true);
853                 fillContext.setPerPageBoundElements(true);
854                 JRVirtualizationContext.register(fillContext.getVirtualizationContext(), jasperPrint);
855             }
856         }
857
858         isPerPageBoundElements = fillContext.isPerPageBoundElements();
859
860         setFormatFactory(parameterValues);
861         
862         setIgnorePagination(parameterValues);
863
864         mainDataset.setParameterValues(parameterValues);
865         
866         this.scriptlet = mainDataset.scriptlet;
867         
868         if (!isSubreport())
869         {
870             fillContext.setMasterFormatFactory(getFormatFactory());
871             fillContext.setMasterLocale(getLocale());
872             fillContext.setMasterTimeZone(getTimeZone());
873         }
874     }
875
876
877     private void setFormatFactory(Map JavaDoc parameterValues)
878     {
879         formatFactory = (FormatFactory)parameterValues.get(JRParameter.REPORT_FORMAT_FACTORY);
880         if (formatFactory == null)
881         {
882             formatFactory = DefaultFormatFactory.createFormatFactory(jasperReport.getFormatFactoryClass());
883             parameterValues.put(JRParameter.REPORT_FORMAT_FACTORY, formatFactory);
884         }
885     }
886
887
888     private boolean setClassLoader(Map JavaDoc parameterValues)
889     {
890         reportClassLoader = (ClassLoader JavaDoc) parameterValues.get(JRParameter.REPORT_CLASS_LOADER);
891         boolean setClassLoader = reportClassLoader != null;
892         if (setClassLoader)
893         {
894             JRResourcesUtil.setThreadClassLoader(reportClassLoader);
895         }
896         return setClassLoader;
897     }
898
899
900     private boolean setUrlHandlerFactory(Map JavaDoc parameterValues)
901     {
902         urlHandlerFactory = (URLStreamHandlerFactory JavaDoc) parameterValues.get(JRParameter.REPORT_URL_HANDLER_FACTORY);
903         boolean setUrlHandlerFactory = urlHandlerFactory != null;
904         if (setUrlHandlerFactory)
905         {
906             JRResourcesUtil.setThreadURLHandlerFactory(urlHandlerFactory);
907         }
908         return setUrlHandlerFactory;
909     }
910
911
912     private void setIgnorePagination(Map JavaDoc parameterValues)
913     {
914         if (parentFiller == null)//pagination is driven by the master
915
{
916             Boolean JavaDoc isIgnorePaginationParam = (Boolean JavaDoc) parameterValues.get(JRParameter.IS_IGNORE_PAGINATION);
917             if (isIgnorePaginationParam != null)
918             {
919                 fillContext.setIgnorePagination(isIgnorePaginationParam.booleanValue());
920             }
921             else
922             {
923                 boolean ignorePagination = jasperReport.isIgnorePagination();
924                 fillContext.setIgnorePagination(ignorePagination);
925                 parameterValues.put(JRParameter.IS_IGNORE_PAGINATION, ignorePagination ? Boolean.TRUE : Boolean.FALSE);
926             }
927         }
928         else
929         {
930             boolean ignorePagination = fillContext.isIgnorePagination();
931             parameterValues.put(JRParameter.IS_IGNORE_PAGINATION, ignorePagination ? Boolean.TRUE : Boolean.FALSE);
932         }
933
934         if (fillContext.isIgnorePagination())
935         {
936             isTitleNewPage = false;
937             isSummaryNewPage = false;
938             if (groups != null)
939             {
940                 for (int i = 0; i < groups.length; i++)
941                 {
942                     groups[i].setStartNewPage(false);
943                     groups[i].setResetPageNumber(false);
944                     groups[i].setStartNewColumn(false);
945                 }
946             }
947             setPageHeight(Integer.MAX_VALUE);
948         }
949     }
950
951
952     /**
953      * Returns the report locale.
954      *
955      * @return the report locale
956      */

957     protected Locale JavaDoc getLocale()
958     {
959         return mainDataset.locale;
960     }
961
962
963     /**
964      * Returns the report time zone.
965      *
966      * @return the report time zone
967      */

968     protected TimeZone JavaDoc getTimeZone()
969     {
970         return mainDataset.timeZone;
971     }
972
973     
974     /**
975      * Returns the report format factory.
976      *
977      * @return the report format factory
978      */

979     protected FormatFactory getFormatFactory()
980     {
981         return formatFactory;
982     }
983
984     
985     /**
986      *
987      */

988     protected Format JavaDoc getDateFormat(String JavaDoc pattern)
989     {
990         Locale JavaDoc lc = getLocale();
991         TimeZone JavaDoc tz = getTimeZone();
992         String JavaDoc key = pattern + "|" + JRDataUtils.getLocaleCode(lc) + "|" + JRDataUtils.getTimeZoneId(tz);
993         Format JavaDoc format = (Format JavaDoc)dateFormatCache.get(key);
994         if (format == null)
995         {
996             format = getFormatFactory().createDateFormat(pattern, lc, tz);
997             if (format != null)
998             {
999                 dateFormatCache.put(key, format);
1000            }
1001        }
1002        return format;
1003    }
1004
1005    
1006    /**
1007     *
1008     */

1009    protected Format JavaDoc getNumberFormat(String JavaDoc pattern)
1010    {
1011        Locale JavaDoc lc = getLocale();
1012        String JavaDoc key = pattern + "|" + JRDataUtils.getLocaleCode(lc);
1013        Format JavaDoc format = (Format JavaDoc)numberFormatCache.get(key);
1014        if (format == null)
1015        {
1016            format = getFormatFactory().createNumberFormat(pattern, lc);
1017            if (format != null)
1018            {
1019                numberFormatCache.put(key, format);
1020            }
1021        }
1022        return format;
1023    }
1024
1025    
1026    protected boolean hasMasterFormatFactory()
1027    {
1028        return
1029            !isSubreport()
1030            || getFormatFactory().getClass().getName().equals(
1031                fillContext.getMasterFormatFactory().getClass().getName()
1032                );
1033    }
1034    
1035    
1036    protected boolean hasMasterLocale()
1037    {
1038        return !isSubreport() || getLocale().equals(fillContext.getMasterLocale());
1039    }
1040    
1041    
1042    protected boolean hasMasterTimeZone()
1043    {
1044        return !isSubreport() || getTimeZone().equals(fillContext.getMasterTimeZone());
1045    }
1046
1047
1048    /**
1049     * Sets a parameter's value.
1050     *
1051     * @param parameterName the parameter name
1052     * @param value the value
1053     * @throws JRException
1054     */

1055    protected void setParameter(String JavaDoc parameterName, Object JavaDoc value) throws JRException
1056    {
1057        mainDataset.setParameter(parameterName, value);
1058    }
1059
1060
1061    /**
1062     * Sets a parameter's value.
1063     *
1064     * @param parameter the parameter
1065     * @param value the value
1066     * @throws JRException
1067     */

1068    protected void setParameter(JRFillParameter parameter, Object JavaDoc value) throws JRException
1069    {
1070        mainDataset.setParameter(parameter, value);
1071    }
1072
1073    /**
1074     *
1075     */

1076    protected boolean next() throws JRException
1077    {
1078        return mainDataset.next();
1079    }
1080
1081    private void resolveBoundElements(Map JavaDoc boundElementsMap, byte evaluation, JREvaluationTime evaluationTime) throws JRException
1082    {
1083        if (boundElementsMap != null)
1084        {
1085            for (Iterator JavaDoc it = boundElementsMap.entrySet().iterator(); it.hasNext();)
1086            {
1087                Map.Entry JavaDoc entry = (Map.Entry JavaDoc) it.next();
1088                JRPrintElement element = (JRPrintElement) entry.getKey();
1089                JRFillElement fillElement = (JRFillElement) entry.getValue();
1090
1091                fillElement.resolveElement(element, evaluation, evaluationTime);
1092            }
1093        }
1094    }
1095
1096    protected void resolveBoundElements(JREvaluationTime evaluationTime, byte evaluation) throws JRException
1097    {
1098        BoundElementMap boundElementsMap = (BoundElementMap) boundElements.get(evaluationTime);
1099        if (isPerPageBoundElements)
1100        {
1101            Map JavaDoc perPageElementsMap = boundElementsMap.getMap();
1102            for (Iterator JavaDoc it = perPageElementsMap.entrySet().iterator(); it.hasNext();)
1103            {
1104                Map.Entry JavaDoc entry = (Map.Entry JavaDoc) it.next();
1105                // Calling getElements() will page in the data for the page.
1106
JRPrintPage page = (JRPrintPage) entry.getKey();
1107                page.getElements();
1108                Map JavaDoc elementsMap = (Map JavaDoc) entry.getValue();
1109                resolveBoundElements(elementsMap, evaluation, evaluationTime);
1110            }
1111
1112            boundElementsMap.clear();
1113        }
1114        else
1115        {
1116            resolveBoundElements(boundElementsMap.getMap(), evaluation, evaluationTime);
1117            boundElementsMap.clear();
1118        }
1119    }
1120
1121    /**
1122     * Resolves elements which are to be evaluated at report level.
1123     */

1124    protected void resolveReportBoundElements() throws JRException
1125    {
1126        resolveBoundElements(JREvaluationTime.EVALUATION_TIME_REPORT, JRExpression.EVALUATION_DEFAULT);
1127    }
1128
1129    /**
1130     * Resolves elements which are to be evaluated at page level.
1131     *
1132     * @param evaluation
1133     * the evaluation type
1134     */

1135    protected void resolvePageBoundElements(byte evaluation) throws JRException
1136    {
1137        resolveBoundElements(JREvaluationTime.EVALUATION_TIME_PAGE, evaluation);
1138    }
1139
1140    /**
1141     * Resolves elements which are to be evaluated at column level.
1142     *
1143     * @param evaluation
1144     * the evaluation type
1145     */

1146    protected void resolveColumnBoundElements(byte evaluation) throws JRException
1147    {
1148        resolveBoundElements(JREvaluationTime.EVALUATION_TIME_COLUMN, evaluation);
1149    }
1150
1151    /**
1152     * Resolves elements which are to be evaluated at group level.
1153     *
1154     * @param evaluation
1155     * the evaluation type
1156     * @param isFinal
1157     */

1158    protected void resolveGroupBoundElements(byte evaluation, boolean isFinal) throws JRException
1159    {
1160        if (groups != null && groups.length > 0)
1161        {
1162            for (int i = 0; i < groups.length; i++)
1163            {
1164                JRFillGroup group = groups[i];
1165
1166                if ((group.hasChanged() && group.isFooterPrinted()) || isFinal)
1167                {
1168                    String JavaDoc groupName = group.getName();
1169
1170                    resolveBoundElements(JREvaluationTime.getGroupEvaluationTime(groupName), evaluation);
1171                }
1172            }
1173        }
1174    }
1175
1176    protected JRPrintPage newPage()
1177    {
1178        JRPrintPage page;
1179
1180        if (virtualizer != null)
1181        {
1182            JRVirtualPrintPage virtualPage = new JRVirtualPrintPage(jasperPrint, virtualizer, fillContext.getVirtualizationContext());
1183
1184            addIdentityDataProviders(virtualPage, this);
1185
1186            page = virtualPage;
1187        }
1188        else
1189        {
1190            page = new JRBasePrintPage();
1191        }
1192
1193        return page;
1194    }
1195
1196    /**
1197     * Returns the value of a variable.
1198     *
1199     * @param variableName
1200     * the variable name
1201     * @return the variable value
1202     */

1203    protected Object JavaDoc getVariableValue(String JavaDoc variableName)
1204    {
1205        return mainDataset.getVariableValue(variableName);
1206    }
1207
1208    /**
1209     * Resloves elements which are to be evaluated at band level.
1210     *
1211     * @param band
1212     * the band
1213     * @param evaluation
1214     * the evaluation type
1215     * @throws JRException
1216     */

1217    protected void resolveBandBoundElements(JRFillBand band, byte evaluation) throws JRException
1218    {
1219        resolveBoundElements(JREvaluationTime.getBandEvaluationTime(band), evaluation);
1220    }
1221
1222
1223    /**
1224     * Adds a variable calculation request.
1225     *
1226     * @param variableName
1227     * the variable name
1228     * @param calculation
1229     * the calculation type
1230     */

1231    protected void addVariableCalculationReq(String JavaDoc variableName, byte calculation)
1232    {
1233        mainDataset.addVariableCalculationReq(variableName, calculation);
1234    }
1235
1236
1237    /**
1238     * Cancells the fill process.
1239     *
1240     * @throws JRException
1241     */

1242    public void cancelFill() throws JRException
1243    {
1244        if (!fillContext.cancelRunningQuery())
1245        {
1246            Thread JavaDoc t = fillingThread;
1247            if (t != null)
1248            {
1249                t.interrupt();
1250            }
1251        }
1252    }
1253
1254
1255    protected void registerSubfiller(JRBaseFiller subfiller)
1256    {
1257        if (subfillers == null)
1258        {
1259            subfillers = new HashSet JavaDoc();
1260        }
1261
1262        if (subfillers.add(subfiller) && fillContext.isUsingVirtualizer())
1263        {
1264            subfiller.identityPages = new ArrayList JavaDoc();
1265
1266            JRVirtualPrintPage masterPrintPage = (JRVirtualPrintPage) fillContext.getPrintPage();
1267            subfiller.identityPages.add(masterPrintPage);
1268            addIdentityDataProviders(masterPrintPage, subfiller);
1269        }
1270    }
1271
1272    protected void unregisterSubfiller(JRBaseFiller subfiller)
1273    {
1274        if (subfillers != null && subfillers.remove(subfiller) && fillContext.isUsingVirtualizer())
1275        {
1276            removeIdentityDataProviders(subfiller);
1277        }
1278    }
1279
1280    private static void addIdentityDataProviders(JRVirtualPrintPage page, JRBaseFiller filler)
1281    {
1282        page.addIdentityDataProvider(filler);
1283
1284        if (filler.subfillers != null)
1285        {
1286            for (Iterator JavaDoc i = filler.subfillers.iterator(); i.hasNext();)
1287            {
1288                JRBaseFiller subfiller = (JRBaseFiller) i.next();
1289
1290                subfiller.identityPages.add(page);
1291                addIdentityDataProviders(page, subfiller);
1292            }
1293        }
1294    }
1295
1296    private void removeIdentityDataProviders(JRBaseFiller filler)
1297    {
1298        if (filler.identityPages != null)
1299        {
1300            for (Iterator JavaDoc it = filler.identityPages.iterator(); it.hasNext();)
1301            {
1302                JRVirtualPrintPage page = (JRVirtualPrintPage) it.next();
1303
1304                page.removeIdentityDataProvider(filler);
1305            }
1306
1307            filler.identityPages = null;
1308        }
1309    }
1310
1311
1312    protected void addPage(JRPrintPage page)
1313    {
1314        if (!isSubreport())
1315        {
1316            jasperPrint.addPage(page);
1317            fillContext.setPrintPage(page);
1318        }
1319    }
1320
1321
1322    protected static final class PageIdentityDataProvider implements JRVirtualPrintPage.IdentityDataProvider
1323    {
1324        private static final Map JavaDoc providers = new HashMap JavaDoc();
1325
1326        private final JRPrintPage printPage;
1327
1328        protected PageIdentityDataProvider(JRPrintPage printPage)
1329        {
1330            this.printPage = printPage;
1331        }
1332
1333        public JRVirtualPrintPage.ObjectIDPair[] getIdentityData(JRVirtualPrintPage page)
1334        {
1335            return null;
1336        }
1337
1338        public void setIdentityData(JRVirtualPrintPage page, JRVirtualPrintPage.ObjectIDPair[] identityData)
1339        {
1340            if (identityData != null && identityData.length > 0)
1341            {
1342                Map JavaDoc idMap = new HashMap JavaDoc();
1343                for (int i = 0; i < identityData.length; i++)
1344                {
1345                    idMap.put(new Integer JavaDoc(identityData[i].getIdentity()), identityData[i].getObject());
1346                }
1347
1348                for (ListIterator JavaDoc i = printPage.getElements().listIterator(); i.hasNext();)
1349                {
1350                    Object JavaDoc element = i.next();
1351                    Integer JavaDoc id = new Integer JavaDoc(System.identityHashCode(element));
1352
1353                    Object JavaDoc idObject = idMap.get(id);
1354                    if (idObject != null)
1355                    {
1356                        i.set(idObject);
1357                    }
1358                }
1359            }
1360        }
1361
1362        public static JRVirtualPrintPage.IdentityDataProvider getIdentityDataProvider(JRPrintPage printPage)
1363        {
1364            JRVirtualPrintPage.IdentityDataProvider provider = (JRVirtualPrintPage.IdentityDataProvider) providers.get(printPage);
1365            if (provider == null)
1366            {
1367                provider = new PageIdentityDataProvider(printPage);
1368                providers.put(printPage, provider);
1369            }
1370            return provider;
1371        }
1372
1373        public static JRVirtualPrintPage.IdentityDataProvider removeIdentityDataProvider(JRPrintPage printPage)
1374        {
1375            JRVirtualPrintPage.IdentityDataProvider provider = (JRVirtualPrintPage.IdentityDataProvider) providers.remove(printPage);
1376            return provider;
1377        }
1378    }
1379
1380
1381    protected void addPageIdentityDataProvider()
1382    {
1383        JRVirtualPrintPage.IdentityDataProvider pageProvider = PageIdentityDataProvider.getIdentityDataProvider(printPage);
1384        JRVirtualPrintPage masterPage = (JRVirtualPrintPage) fillContext.getPrintPage();
1385        masterPage.addIdentityDataProvider(pageProvider);
1386    }
1387
1388
1389    protected void removePageIdentityDataProvider()
1390    {
1391        JRVirtualPrintPage.IdentityDataProvider pageProvider = PageIdentityDataProvider.removeIdentityDataProvider(printPage);
1392        if (pageProvider != null)
1393        {
1394            ((JRVirtualPrintPage) fillContext.getPrintPage()).removeIdentityDataProvider(pageProvider);
1395        }
1396    }
1397
1398
1399    /**
1400     * Evaluates an expression
1401     * @param expression the expression
1402     * @param evaluation the evaluation type
1403     * @return the evaluation result
1404     * @throws JRException
1405     */

1406    protected Object JavaDoc evaluateExpression(JRExpression expression, byte evaluation) throws JRException
1407    {
1408        return mainDataset.calculator.evaluate(expression, evaluation);
1409    }
1410
1411
1412    private void createDatasets(JRFillObjectFactory factory) throws JRException
1413    {
1414        datasetMap = new HashMap JavaDoc();
1415
1416        JRDataset[] datasets = jasperReport.getDatasets();
1417        if (datasets != null && datasets.length > 0)
1418        {
1419            for (int i = 0; i < datasets.length; i++)
1420            {
1421                JRFillDataset fillDataset = factory.getDataset(datasets[i]);
1422                fillDataset.createCalculator(jasperReport);
1423
1424                datasetMap.put(datasets[i].getName(), fillDataset);
1425            }
1426        }
1427    }
1428
1429
1430    private void initDatasets(JRFillObjectFactory factory)
1431    {
1432        for (Iterator JavaDoc it = datasetMap.values().iterator(); it.hasNext();)
1433        {
1434            JRFillDataset dataset = (JRFillDataset) it.next();
1435            dataset.inheritFromMain();
1436            dataset.initElementDatasets(factory);
1437        }
1438    }
1439
1440
1441    protected byte getWhenResourceMissingType()
1442    {
1443        return mainDataset.whenResourceMissingType;
1444    }
1445
1446
1447    /**
1448     * Returns the report.
1449     *
1450     * @return the report
1451     */

1452    protected JasperReport getJasperReport()
1453    {
1454        return jasperReport;
1455    }
1456
1457
1458    protected boolean isBandOverFlowAllowed()
1459    {
1460        return bandOverFlowAllowed;
1461    }
1462
1463
1464    protected void setBandOverFlowAllowed(boolean splittableBand)
1465    {
1466        this.bandOverFlowAllowed = splittableBand;
1467    }
1468
1469    protected int getMasterColumnCount()
1470    {
1471        JRBaseFiller filler = parentFiller;
1472        int colCount = 1;
1473
1474        while (filler != null)
1475        {
1476            colCount *= filler.columnCount;
1477            filler = filler.parentFiller;
1478        }
1479
1480        return colCount;
1481    }
1482
1483
1484    public JRFillDataset getMainDataset()
1485    {
1486        return mainDataset;
1487    }
1488
1489
1490    protected void addBoundElement(JRFillElement element, JRPrintElement printElement, byte evaluationType, JRGroup group, JRFillBand band)
1491    {
1492        JREvaluationTime evaluationTime = JREvaluationTime.getEvaluationTime(evaluationType, group, band);
1493        addBoundElement(element, printElement, evaluationTime);
1494    }
1495
1496
1497    protected void addBoundElement(JRFillElement element, JRPrintElement printElement, JREvaluationTime evaluationTime)
1498    {
1499        BoundElementMap boundElementsMap = (BoundElementMap) boundElements.get(evaluationTime);
1500        boundElementsMap.put(printElement, element);
1501    }
1502
1503
1504
1505    /**
1506     * Collect all of the identity data the the JRBaseFiller needs to know.
1507     * <p>
1508     * All the bound elements on the page are collected and transformed into
1509     * identity objects.
1510     *
1511     * @param page
1512     * the page to get the identity data for
1513     */

1514    public JRVirtualPrintPage.ObjectIDPair[] getIdentityData(JRVirtualPrintPage page)
1515    {
1516        Map JavaDoc allElements = new HashMap JavaDoc();
1517        List JavaDoc identityList = new ArrayList JavaDoc();
1518
1519        for (Iterator JavaDoc it = boundElements.values().iterator(); it.hasNext();)
1520        {
1521            BoundElementMap pageBoundElementsMap = (BoundElementMap) it.next();
1522            Map JavaDoc map = pageBoundElementsMap.getMap(page);
1523            if (map != null && !map.isEmpty())
1524            {
1525                Map JavaDoc idMap = new HashMap JavaDoc();
1526
1527                for (Iterator JavaDoc iter = map.entrySet().iterator(); iter.hasNext();)
1528                {
1529                    Map.Entry JavaDoc entry = (Map.Entry JavaDoc) iter.next();
1530                    Object JavaDoc key = entry.getKey();
1531                    Integer JavaDoc id = (Integer JavaDoc) allElements.get(key);
1532                    if (id == null)
1533                    {
1534                        JRVirtualPrintPage.ObjectIDPair idPair = new JRVirtualPrintPage.ObjectIDPair(key);
1535                        identityList.add(idPair);
1536
1537                        id = new Integer JavaDoc(idPair.getIdentity());
1538                        allElements.put(key, id);
1539                    }
1540                    idMap.put(id, entry.getValue());
1541                }
1542                pageBoundElementsMap.putMap(page, idMap);
1543            }
1544        }
1545
1546        JRVirtualPrintPage.ObjectIDPair[] identityData = null;
1547        if (!identityList.isEmpty())
1548        {
1549            identityData = new JRVirtualPrintPage.ObjectIDPair[identityList.size()];
1550            identityList.toArray(identityData);
1551        }
1552
1553        return identityData;
1554    }
1555
1556    /**
1557     * Sets the identity date for a virtualized page.
1558     * <p>
1559     * The identity data consists of bound elements located on the page.
1560     * Pairs of identity hash code and objects are stored when the page is
1561     * virtualized. When the page gets devirtualized, the original objects
1562     * are substituted in the bound maps based on their identity hash code.
1563     *
1564     * @param page
1565     * the virtualized page
1566     * @param identityData
1567     * the identity data
1568     */

1569    public void setIdentityData(JRVirtualPrintPage page, JRVirtualPrintPage.ObjectIDPair[] identityData)
1570    {
1571        if (identityData == null || identityData.length == 0)
1572        {
1573            return;
1574        }
1575
1576        for (Iterator JavaDoc it = boundElements.values().iterator(); it.hasNext();)
1577        {
1578            BoundElementMap pageBoundElementsMap = (BoundElementMap) it.next();
1579            Map JavaDoc idMap = pageBoundElementsMap.getMap(page);
1580            if (idMap != null && !idMap.isEmpty())
1581            {
1582                Map JavaDoc map = new HashMap JavaDoc();
1583
1584                for (int i = 0; i < identityData.length; i++)
1585                {
1586                    JRVirtualPrintPage.ObjectIDPair idPair = identityData[i];
1587                    Integer JavaDoc id = new Integer JavaDoc(idPair.getIdentity());
1588
1589                    Object JavaDoc value = idMap.get(id);
1590                    if (value != null)
1591                    {
1592                        map.put(idPair.getObject(), value);
1593                    }
1594                }
1595
1596                pageBoundElementsMap.putMap(page, map);
1597            }
1598        }
1599    }
1600    
1601    
1602// protected JRStyle getConsolidatedStyle(String consolidatedStyleName)
1603
// {
1604
// return (JRStyle) consolidatedStyles.get(consolidatedStyleName);
1605
// }
1606
//
1607
//
1608
// protected void putConsolidatedStyle(JRStyle consolidatedStyle)
1609
// {
1610
// consolidatedStyles.put(consolidatedStyle.getName(), consolidatedStyle);
1611
// }
1612

1613    protected final boolean isEmpty(JRBand band)
1614    {
1615        return band == null ||
1616                (band.getHeight() == 0
1617                && (band.getElements() == null || band.getElements().length == 0)
1618                && band.getPrintWhenExpression() == null);
1619    }
1620    
1621    protected void setSubreportRunner(JRSubreportRunner runner)
1622    {
1623        this.subreportRunner = runner;
1624    }
1625    
1626    protected void suspendSubreportRunner() throws JRException
1627    {
1628        if (subreportRunner == null)
1629        {
1630            throw new JRRuntimeException("No subreport runner set.");
1631        }
1632
1633        subreportRunner.suspend();
1634    }
1635}
1636
Popular Tags