Skip navigation links

Package org.pentaho.reporting.engine.classic.core.filter

Support for the creation of 'filter chains' used to transform data objects into other forms for presentation on reports.

See: Description

Package org.pentaho.reporting.engine.classic.core.filter Description

Support for the creation of 'filter chains' used to transform data objects into other forms for presentation on reports.

Basic flow of data in JFreeReport

Three interfaces create the abstract way of the dataflow in JFreeReport.

DataSource

By default all data used in the report's elements is read from DataSource implementations. DataSource defines a single function called getValue() which returns the current value of the datasource. DataSources are stateless, and implementations should not maintain a state of the process of querying data. It is not guaranteed that DataSources are in a particular order. If you need to maintain a state or get informed of events, you should implement a function instead of using the DataSource interface.

DataTarget

A DataTarget is a container for a DataSource. A DataTarget queries the DataSource when it needs new data. All elements of the report implement the DataTarget interface and query its assigned DataSource whenever they need to print the data. DataTargets should not rely on the data type of the data returned by the DataSource. If they cannot handle the data returned by the DataSource, DataTargets should perform a controled way of errorhandling instead of just throwing exceptions. Some DataSources can return NullValues, so DataTargets will have to handle this case correctly.

DataFilter

A DataFilter is the conjunction of DataSource and DataTarget. If a DataFilter is queried to return a value, the request if forwareded to the assigned DataSource of the filter. The returned value is then processed and the result is returned.

FormatFilter and FormatParser

FormatFilter and FormatParsers are special implementations of the filter interface. Both of them are using an implementation of java.text.Format to perform parsing and formatting. Commonly used implementation are the SimpleDateFormat to format and parse java.util.Date objects and the DecimalFormat to parse and format Number instances.

A FormatFilter implementation will try to create a string representation of an object using the parse method of its assigned java.text.Format object. It is guaranteed that a FormatFilter will return a default not null String in case that getValue() returns invalid values. This default string is defined by setNullString (String).

A FormatParser implementation will try to parse a String read from its DataSource into an object. The actual work of parsing is delegated to the java.text.Formats parse method. If the string was null or invalid, and parsing was unable to create an object, a predefined value can be returned instead of null.

Common use cases of Filters

These examples should give an idea what can be done with the filters. As filters can contain other filters, you are free to create any combination and put them into the elements.

DataRowConnectable

Elements are connected to the Report's DataSources using a DataRow as connector. The DataRow unifies the access to functions, expressions and the tablemodel. DataSources that need to access one of these sources should use the DataRowDataSource as primary datasource. The specialized sources for accessing Functions and the Reports TableModel should not be used.

Skip navigation links