13.07.2015 Views

iReport Ultimate Guide - Nimsoft Library

iReport Ultimate Guide - Nimsoft Library

iReport Ultimate Guide - Nimsoft Library

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Data Sources and Query Executersspecified as a directory path (for instance, C:\My Query Executer Folder). The query executer will read the path (which isactually our query) and will return a data source with the list of objects in the specified directory (files and subdirectories).The responsibility for managing query parameters belongs to the query executer implementation. Please note that the querycan always accept parameters using the canonical syntax $P{parameter name}.A query executer is composed of two objects: the query executer factory and the actual query executer. Figure 11-42 showshow a query is processed. UR instantiates the query executer factory, matching the language of the report query. Italso calls the method createQueryExecuter, passing as arguments a JRDataset (a structure to manage fields, parameters,variables, queries, and query languages declared in the report), and a map containing the values provided for each parameter.createQueryExecuter returns an instance of a JRQueryExecuter that provides the method createDatasource. Theengine will call it to get the data source to fill the report..Figure 11-42 Flow chart of the query executionLet’s start with the query executer factory. UR provides an interface to create this kind of object:JRQueryExecuterFactory.Code Example 11-9Interface JRQueryExecuterFactory provided by URpackage net.sf.jasperreports.engine.query;import java.util.Map;import net.sf.jasperreports.engine.JRDataset;import net.sf.jasperreports.engine.JRException;import net.sf.jasperreports.engine.JRValueParameter;/*** Factory classes used to create query executers.* For each query language, a query executer factory must be created* and registered as a JR property.* Query executer factory instances must be thread-safe as they are cached* and used as singletons.*/public interface JRQueryExecuterFactory211

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!