Source Code Cross Referenced for JasperFillManager.java in  » Report » jasperreports-2.0.1 » net » sf » jasperreports » engine » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Report » jasperreports 2.0.1 » net.sf.jasperreports.engine 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * ============================================================================
003:         * GNU Lesser General Public License
004:         * ============================================================================
005:         *
006:         * JasperReports - Free Java report-generating library.
007:         * Copyright (C) 2001-2006 JasperSoft Corporation http://www.jaspersoft.com
008:         * 
009:         * This library is free software; you can redistribute it and/or
010:         * modify it under the terms of the GNU Lesser General Public
011:         * License as published by the Free Software Foundation; either
012:         * version 2.1 of the License, or (at your option) any later version.
013:         * 
014:         * This library is distributed in the hope that it will be useful,
015:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
016:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
017:         * Lesser General Public License for more details.
018:         * 
019:         * You should have received a copy of the GNU Lesser General Public
020:         * License along with this library; if not, write to the Free Software
021:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307, USA.
022:         * 
023:         * JasperSoft Corporation
024:         * 303 Second Street, Suite 450 North
025:         * San Francisco, CA 94107
026:         * http://www.jaspersoft.com
027:         */
028:        package net.sf.jasperreports.engine;
029:
030:        import java.io.File;
031:        import java.io.InputStream;
032:        import java.io.OutputStream;
033:        import java.sql.Connection;
034:        import java.util.Map;
035:
036:        import net.sf.jasperreports.engine.fill.JRFiller;
037:        import net.sf.jasperreports.engine.util.JRLoader;
038:        import net.sf.jasperreports.engine.util.JRSaver;
039:
040:        /**
041:         * Façade class for filling compiled report designs with data from report data sources, 
042:         * in order to produce page-oriented documents, ready-to-print.
043:         * <p>
044:         * All methods receive a Map object that should contain the values for the report parameters.
045:         * These value are retrieved by the engine using the corresponding report parameter name as the key. 
046:         * <p>
047:         * There are two types of method signatures with regards to the data source
048:         * provided for filling the report:
049:         * <ul>
050:         * <li>Methods that receive an instance of the {@link net.sf.jasperreports.engine.JRDataSource} interface
051:         * and use it directly for retrieving report data;
052:         * <li>Methods that receive an instance of the {@link java.sql.Connection} interface and retrieve
053:         * the report data by executing the report internal SQL query through this JDBC connection and wrapping 
054:         * the returned {@link java.sql.ResultSet} object inside a {@link net.sf.jasperreports.engine.JRResultSetDataSource}
055:         * instance. 
056:         * </ul>
057:         * 
058:         * @see net.sf.jasperreports.engine.JasperReport
059:         * @see net.sf.jasperreports.engine.JRDataSource
060:         * @see net.sf.jasperreports.engine.fill.JRFiller
061:         * @see net.sf.jasperreports.engine.JasperPrint
062:         * @author Teodor Danciu (teodord@users.sourceforge.net)
063:         * @version $Id: JasperFillManager.java 1229 2006-04-19 10:27:35Z teodord $
064:         */
065:        public class JasperFillManager {
066:
067:            /**
068:             * Fills the compiled report design loaded from the specified file.
069:             * The result of this operation is another file that will contain the serialized  
070:             * {@link JasperPrint} object representing the generated document,
071:             * having the same name as the report design as declared in the source file, 
072:             * plus the <code>*.jrprint</code> extension, located in the same directory as the source file. 
073:             * 
074:             * @param sourceFileName source file containing the compile report design
075:             * @param parameters     report parameters map
076:             * @param connection     JDBC connection object to use for executing the report internal SQL query
077:             */
078:            public static String fillReportToFile(String sourceFileName,
079:                    Map parameters, Connection connection) throws JRException {
080:                File sourceFile = new File(sourceFileName);
081:
082:                JasperReport jasperReport = (JasperReport) JRLoader
083:                        .loadObject(sourceFile);
084:
085:                File destFile = new File(sourceFile.getParent(), jasperReport
086:                        .getName()
087:                        + ".jrprint");
088:                String destFileName = destFile.toString();
089:
090:                fillReportToFile(jasperReport, destFileName, parameters,
091:                        connection);
092:
093:                return destFileName;
094:            }
095:
096:            /**
097:             * Fills the compiled report design loaded from the specified file.
098:             * The result of this operation is another file that will contain the serialized  
099:             * {@link JasperPrint} object representing the generated document,
100:             * having the same name as the report design as declared in the source file, 
101:             * plus the <code>*.jrprint</code> extension, located in the same directory as the source file. 
102:             * 
103:             * @param sourceFileName source file containing the compile report design
104:             * @param parameters     report parameters map
105:             * @see JRFiller#fillReport(JasperReport, Map)
106:             */
107:            public static String fillReportToFile(String sourceFileName,
108:                    Map parameters) throws JRException {
109:                File sourceFile = new File(sourceFileName);
110:
111:                JasperReport jasperReport = (JasperReport) JRLoader
112:                        .loadObject(sourceFile);
113:
114:                File destFile = new File(sourceFile.getParent(), jasperReport
115:                        .getName()
116:                        + ".jrprint");
117:                String destFileName = destFile.toString();
118:
119:                fillReportToFile(jasperReport, destFileName, parameters);
120:
121:                return destFileName;
122:            }
123:
124:            /**
125:             * Fills the compiled report design loaded from the file received as the first parameter
126:             * and places the result in the file specified by the second parameter.
127:             * 
128:             * @param sourceFileName source file containing the compile report design
129:             * @param destFileName   file name to place the generated report into
130:             * @param parameters     report parameters map
131:             * @param connection     JDBC connection object to use for executing the report internal SQL query
132:             */
133:            public static void fillReportToFile(String sourceFileName,
134:                    String destFileName, Map parameters, Connection connection)
135:                    throws JRException {
136:                JasperReport jasperReport = (JasperReport) JRLoader
137:                        .loadObject(sourceFileName);
138:
139:                fillReportToFile(jasperReport, destFileName, parameters,
140:                        connection);
141:            }
142:
143:            /**
144:             * Fills the compiled report design loaded from the file received as the first parameter
145:             * and places the result in the file specified by the second parameter.
146:             * 
147:             * @param sourceFileName source file containing the compile report design
148:             * @param destFileName   file name to place the generated report into
149:             * @param parameters     report parameters map
150:             * @see JRFiller#fillReport(JasperReport, Map)
151:             */
152:            public static void fillReportToFile(String sourceFileName,
153:                    String destFileName, Map parameters) throws JRException {
154:                JasperReport jasperReport = (JasperReport) JRLoader
155:                        .loadObject(sourceFileName);
156:
157:                fillReportToFile(jasperReport, destFileName, parameters);
158:            }
159:
160:            /**
161:             * Fills the compiled report design received as the first parameter
162:             * and places the result in the file specified by the second parameter.
163:             * 
164:             * @param jasperReport compiled report design object to use for filling
165:             * @param destFileName file name to place the generated report into
166:             * @param parameters   report parameters map
167:             * @param connection   JDBC connection object to use for executing the report internal SQL query
168:             */
169:            public static void fillReportToFile(JasperReport jasperReport,
170:                    String destFileName, Map parameters, Connection connection)
171:                    throws JRException {
172:                JasperPrint jasperPrint = fillReport(jasperReport, parameters,
173:                        connection);
174:
175:                JRSaver.saveObject(jasperPrint, destFileName);
176:            }
177:
178:            /**
179:             * Fills the compiled report design received as the first parameter
180:             * and places the result in the file specified by the second parameter.
181:             * 
182:             * @param jasperReport compiled report design object to use for filling
183:             * @param destFileName file name to place the generated report into
184:             * @param parameters   report parameters map
185:             * @see JRFiller#fillReport(JasperReport, Map)
186:             */
187:            public static void fillReportToFile(JasperReport jasperReport,
188:                    String destFileName, Map parameters) throws JRException {
189:                JasperPrint jasperPrint = fillReport(jasperReport, parameters);
190:
191:                JRSaver.saveObject(jasperPrint, destFileName);
192:            }
193:
194:            /**
195:             * Fills the compiled report design loaded from the specified file and returns
196:             * the generated report object.
197:             * 
198:             * @param sourceFileName source file containing the compile report design
199:             * @param parameters     report parameters map
200:             * @param connection     JDBC connection object to use for executing the report internal SQL query
201:             * @return generated report object
202:             */
203:            public static JasperPrint fillReport(String sourceFileName,
204:                    Map parameters, Connection connection) throws JRException {
205:                File sourceFile = new File(sourceFileName);
206:
207:                JasperReport jasperReport = (JasperReport) JRLoader
208:                        .loadObject(sourceFile);
209:
210:                return fillReport(jasperReport, parameters, connection);
211:            }
212:
213:            /**
214:             * Fills the compiled report design loaded from the specified file and returns
215:             * the generated report object.
216:             * 
217:             * @param sourceFileName source file containing the compile report design
218:             * @param parameters     report parameters map
219:             * @return generated report object
220:             * @see JRFiller#fillReport(JasperReport, Map)
221:             */
222:            public static JasperPrint fillReport(String sourceFileName,
223:                    Map parameters) throws JRException {
224:                File sourceFile = new File(sourceFileName);
225:
226:                JasperReport jasperReport = (JasperReport) JRLoader
227:                        .loadObject(sourceFile);
228:
229:                return fillReport(jasperReport, parameters);
230:            }
231:
232:            /**
233:             * Fills the compiled report design loaded from the supplied input stream and writes
234:             * the generated report object to the output stream specified by the second parameter.
235:             * 
236:             * @param inputStream  input stream to read the compiled report design object from
237:             * @param outputStream output stream to write the generated report object to
238:             * @param parameters   report parameters map
239:             * @param connection   JDBC connection object to use for executing the report internal SQL query
240:             */
241:            public static void fillReportToStream(InputStream inputStream,
242:                    OutputStream outputStream, Map parameters,
243:                    Connection connection) throws JRException {
244:                JasperReport jasperReport = (JasperReport) JRLoader
245:                        .loadObject(inputStream);
246:
247:                fillReportToStream(jasperReport, outputStream, parameters,
248:                        connection);
249:            }
250:
251:            /**
252:             * Fills the compiled report design loaded from the supplied input stream and writes
253:             * the generated report object to the output stream specified by the second parameter.
254:             * 
255:             * @param inputStream  input stream to read the compiled report design object from
256:             * @param outputStream output stream to write the generated report object to
257:             * @param parameters   report parameters map
258:             * @see JRFiller#fillReport(JasperReport, Map)
259:             */
260:            public static void fillReportToStream(InputStream inputStream,
261:                    OutputStream outputStream, Map parameters)
262:                    throws JRException {
263:                JasperReport jasperReport = (JasperReport) JRLoader
264:                        .loadObject(inputStream);
265:
266:                fillReportToStream(jasperReport, outputStream, parameters);
267:            }
268:
269:            /**
270:             * Fills the compiled report design supplied as the first parameter and writes
271:             * the generated report object to the output stream specified by the second parameter.
272:             * 
273:             * @param jasperReport compiled report design object to use for filling
274:             * @param outputStream output stream to write the generated report object to
275:             * @param parameters   report parameters map
276:             * @param connection   JDBC connection object to use for executing the report internal SQL query
277:             */
278:            public static void fillReportToStream(JasperReport jasperReport,
279:                    OutputStream outputStream, Map parameters,
280:                    Connection connection) throws JRException {
281:                JasperPrint jasperPrint = fillReport(jasperReport, parameters,
282:                        connection);
283:
284:                JRSaver.saveObject(jasperPrint, outputStream);
285:            }
286:
287:            /**
288:             * Fills the compiled report design supplied as the first parameter and writes
289:             * the generated report object to the output stream specified by the second parameter.
290:             * 
291:             * @param jasperReport compiled report design object to use for filling
292:             * @param outputStream output stream to write the generated report object to
293:             * @param parameters   report parameters map
294:             * @see JRFiller#fillReport(JasperReport, Map)
295:             */
296:            public static void fillReportToStream(JasperReport jasperReport,
297:                    OutputStream outputStream, Map parameters)
298:                    throws JRException {
299:                JasperPrint jasperPrint = fillReport(jasperReport, parameters);
300:
301:                JRSaver.saveObject(jasperPrint, outputStream);
302:            }
303:
304:            /**
305:             * Fills the compiled report design loaded from the supplied input stream and returns
306:             * the generated report object.
307:             * 
308:             * @param inputStream  input stream to read the compiled report design object from
309:             * @param parameters   report parameters map
310:             * @param connection   JDBC connection object to use for executing the report internal SQL query
311:             * @return generated report object
312:             */
313:            public static JasperPrint fillReport(InputStream inputStream,
314:                    Map parameters, Connection connection) throws JRException {
315:                JasperReport jasperReport = (JasperReport) JRLoader
316:                        .loadObject(inputStream);
317:
318:                return fillReport(jasperReport, parameters, connection);
319:            }
320:
321:            /**
322:             * Fills the compiled report design loaded from the supplied input stream and returns
323:             * the generated report object.
324:             * 
325:             * @param inputStream  input stream to read the compiled report design object from
326:             * @param parameters   report parameters map
327:             * @return generated report object
328:             * @see JRFiller#fillReport(JasperReport, Map)
329:             */
330:            public static JasperPrint fillReport(InputStream inputStream,
331:                    Map parameters) throws JRException {
332:                JasperReport jasperReport = (JasperReport) JRLoader
333:                        .loadObject(inputStream);
334:
335:                return fillReport(jasperReport, parameters);
336:            }
337:
338:            /**
339:             * Fills the compiled report design supplied as the first parameter and returns
340:             * the generated report object.
341:             * 
342:             * @param jasperReport compiled report design object to use for filling
343:             * @param parameters   report parameters map
344:             * @param connection   JDBC connection object to use for executing the report internal SQL query
345:             * @return generated report object
346:             */
347:            public static JasperPrint fillReport(JasperReport jasperReport,
348:                    Map parameters, Connection connection) throws JRException {
349:                return JRFiller
350:                        .fillReport(jasperReport, parameters, connection);
351:            }
352:
353:            /**
354:             * Fills the compiled report design supplied as the first parameter and returns
355:             * the generated report object.
356:             * 
357:             * @param jasperReport compiled report design object to use for filling
358:             * @param parameters   report parameters map
359:             * @return generated report object
360:             * @see JRFiller#fillReport(JasperReport, Map)
361:             */
362:            public static JasperPrint fillReport(JasperReport jasperReport,
363:                    Map parameters) throws JRException {
364:                return JRFiller.fillReport(jasperReport, parameters);
365:            }
366:
367:            /**
368:             * Fills the compiled report design loaded from the specified file.
369:             * The result of this operation is another file that will contain the serialized  
370:             * {@link JasperPrint} object representing the generated document,
371:             * having the same name as the report design as declared in the source file, 
372:             * plus the <code>*.jrprint</code> extension, located in the same directory as the source file. 
373:             * 
374:             * @param sourceFileName source file containing the compile report design
375:             * @param parameters     report parameters map
376:             * @param dataSource     data source object
377:             */
378:            public static String fillReportToFile(String sourceFileName,
379:                    Map parameters, JRDataSource dataSource) throws JRException {
380:                File sourceFile = new File(sourceFileName);
381:
382:                JasperReport jasperReport = (JasperReport) JRLoader
383:                        .loadObject(sourceFile);
384:
385:                File destFile = new File(sourceFile.getParent(), jasperReport
386:                        .getName()
387:                        + ".jrprint");
388:                String destFileName = destFile.toString();
389:
390:                fillReportToFile(jasperReport, destFileName, parameters,
391:                        dataSource);
392:
393:                return destFileName;
394:            }
395:
396:            /**
397:             * Fills the compiled report design loaded from the file received as the first parameter
398:             * and places the result in the file specified by the second parameter.
399:             * 
400:             * @param sourceFileName source file containing the compile report design
401:             * @param destFileName   file name to place the generated report into
402:             * @param parameters     report parameters map
403:             * @param dataSource     data source object
404:             */
405:            public static void fillReportToFile(String sourceFileName,
406:                    String destFileName, Map parameters, JRDataSource dataSource)
407:                    throws JRException {
408:                JasperReport jasperReport = (JasperReport) JRLoader
409:                        .loadObject(sourceFileName);
410:
411:                fillReportToFile(jasperReport, destFileName, parameters,
412:                        dataSource);
413:            }
414:
415:            /**
416:             * Fills the compiled report design received as the first parameter
417:             * and places the result in the file specified by the second parameter.
418:             * 
419:             * @param jasperReport compiled report design object to use for filling
420:             * @param destFileName file name to place the generated report into
421:             * @param parameters   report parameters map
422:             * @param dataSource   data source object
423:             */
424:            public static void fillReportToFile(JasperReport jasperReport,
425:                    String destFileName, Map parameters, JRDataSource dataSource)
426:                    throws JRException {
427:                JasperPrint jasperPrint = fillReport(jasperReport, parameters,
428:                        dataSource);
429:
430:                JRSaver.saveObject(jasperPrint, destFileName);
431:            }
432:
433:            /**
434:             * Fills the compiled report design loaded from the specified file and returns
435:             * the generated report object.
436:             * 
437:             * @param sourceFileName source file containing the compile report design
438:             * @param parameters     report parameters map
439:             * @param dataSource     data source object
440:             * @return generated report object
441:             */
442:            public static JasperPrint fillReport(String sourceFileName,
443:                    Map parameters, JRDataSource dataSource) throws JRException {
444:                File sourceFile = new File(sourceFileName);
445:
446:                JasperReport jasperReport = (JasperReport) JRLoader
447:                        .loadObject(sourceFile);
448:
449:                return fillReport(jasperReport, parameters, dataSource);
450:            }
451:
452:            /**
453:             * Fills the compiled report design loaded from the supplied input stream and writes
454:             * the generated report object to the output stream specified by the second parameter.
455:             * 
456:             * @param inputStream  input stream to read the compiled report design object from
457:             * @param outputStream output stream to write the generated report object to
458:             * @param parameters   report parameters map
459:             * @param dataSource   data source object
460:             */
461:            public static void fillReportToStream(InputStream inputStream,
462:                    OutputStream outputStream, Map parameters,
463:                    JRDataSource dataSource) throws JRException {
464:                JasperReport jasperReport = (JasperReport) JRLoader
465:                        .loadObject(inputStream);
466:
467:                fillReportToStream(jasperReport, outputStream, parameters,
468:                        dataSource);
469:            }
470:
471:            /**
472:             * Fills the compiled report design supplied as the first parameter and writes
473:             * the generated report object to the output stream specified by the second parameter.
474:             * 
475:             * @param jasperReport compiled report design object to use for filling
476:             * @param outputStream output stream to write the generated report object to
477:             * @param parameters   report parameters map
478:             * @param dataSource   data source object
479:             */
480:            public static void fillReportToStream(JasperReport jasperReport,
481:                    OutputStream outputStream, Map parameters,
482:                    JRDataSource dataSource) throws JRException {
483:                JasperPrint jasperPrint = fillReport(jasperReport, parameters,
484:                        dataSource);
485:
486:                JRSaver.saveObject(jasperPrint, outputStream);
487:            }
488:
489:            /**
490:             * Fills the compiled report design loaded from the supplied input stream and returns
491:             * the generated report object.
492:             * 
493:             * @param inputStream  input stream to read the compiled report design object from
494:             * @param parameters   report parameters map
495:             * @param dataSource   data source object
496:             * @return generated report object
497:             */
498:            public static JasperPrint fillReport(InputStream inputStream,
499:                    Map parameters, JRDataSource dataSource) throws JRException {
500:                JasperReport jasperReport = (JasperReport) JRLoader
501:                        .loadObject(inputStream);
502:
503:                return fillReport(jasperReport, parameters, dataSource);
504:            }
505:
506:            /**
507:             * Fills the compiled report design supplied as the first parameter and returns
508:             * the generated report object.
509:             * 
510:             * @param jasperReport compiled report design object to use for filling
511:             * @param parameters   report parameters map
512:             * @param dataSource   data source object
513:             * @return generated report object
514:             */
515:            public static JasperPrint fillReport(JasperReport jasperReport,
516:                    Map parameters, JRDataSource dataSource) throws JRException {
517:                return JRFiller
518:                        .fillReport(jasperReport, parameters, dataSource);
519:            }
520:
521:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.