JFR9FlowProcessingModel

The default Report-Model: Flow structure processing

Introduction

JFreeReport as an engine is not bound to a specific processing model. The LayoutControllers we use define a very abstract processs model, in common words, their interface says, that they do some work, but it does not state how they do the work and what object types might be the base for their work. JFreeReport's default processing model is called the 'Flow-Modell'. When describing how JFreeReport processes content and how the data and layout layer interact with each other, we will use that Flow-Modell as reference.

A report model is a system of report elements and their behaviour. JFreeReport offers a general framework for implementing report models. A report model has to cope with two general tasks: (1) To process the report structure and (2) to update or process the data for the report. There are only a limited number of operations one can do to the data-set. As this data processing can be broken down into relatively fixed tasks, the engine provides a fine grained library of functions which should cover all current and future needs of data processing.

Elements of the flow model

The default flow model is a very minimalistic (yet still complete) reporting model. The model is built on the idea, that a report definition and its structural dependencies can be seen as some sort of content and processing description language. Each node in the tree represents specific layout and data processing instructions. Iterating the report definition (the instruction tree) drives the report processing. Once the tree is fully processed, the reporting is finished. Reporting is a highly iterative process: the same itemband is printed several times (but each time with new data, of course). The flow modell follows this approach by introducing repeatable nodes. These nodes can (depending on certain conditions) be repeatedly iterated. The 'flow-modell' uses a DOM tree to describe the report content. The tree consists of several Node types.

  • Static-Text
  • Content-Element
  • Sections
    • Group
    • Detail-Section
    • Sub-Report
    • Report

Static Text

Static text is immutable text content. This node type cannot have attributes or styles. When layouting, text nodes always inherit the style from their parent node.

Element Types

Elements are nodes that can have attributes and style. Contrary to the XML-DOM model, elements cannot have child nodes by default. Elements can have named expressions and functions. Named expressions get added to the global data-row and can be accessed from other expressions and functions by their name. Once the element goes out of scope, these expressions get removed from the data-row.

Attributes and styles can be computed at runtime. For this purpose, the Element class provides Style- and Attribute-Expression slots. The evaluation result of these expressions will be set as attribute. Attributes computed from expressions override any previously defined attribute on the element. Style properties computed from expressions override any previously declared style, no matter whether the style is static or computed indirectly by an attribute expression.

All elements can have a display-condition. A display condition is an anonymous expression. If that condition returns false, the element will be ignored for the processing. Display conditions are evaluated before the element's expressions get activated, so they have no access to any of these expressions. The display condition for the root element is ignored.

Content-Element

Content-Elements are mutable content. The element cannot have static children. The element's contents are read from a 'Value-Expression'. The 'Value-Expression' is an ordinary, anonymous and stateless expression that cannot be precomputed.

Flow-Behaviour

If the 'Value-Expression' returns a Node on evaluation, the node is inserted into the Document-Tree as if it were a direct child of the content element. The report processing continues with that returned element.

The 'LibLayout' report target treats the evaluation result as a special attribute and forwards this attibute along with all known meta-data to the layouting layer. The content can be formated or processed using the style rule system. The various properties of the DataFlag-object handed to the ReportTarget (including the value itself) get forwarded as attributes to the InputFeed. All these attributes have the namespace 'http://jfreereport.sourceforge.net/namespaces/engine'.

Section

A section is an element that can contain child nodes.

Sections can have flow operations defined. These flow operations can either be executed before the element is processed (and thus before any of the expressions gets activated, but after the display condition is evaluated) or after the element is fully processed.

Flow-Behaviour

If a section is marked as repeatable section, the layout controller has the choice to reprocess the contents of the section. The section will be repeated, if an advance has been requested and the data-row is advancable (there is a next row). By binding the repeatability of sections to the data-row, we effectivly prevent infinite loops caused by invalid expressions or other definitions.

If the section is contained in a group, the group's grouping expression will be evaluated. If the grouping expression indicates that the processing should stop (by returning 'true'), the section will not be repeated. If the expression indicates that the grouping should continue, the next sub-group is queried until all groups declare that they want to repeat the section.

If the layout controller decides to repeat the section, the 'advance' request will be commited and the cursor of the data-row is shifted to the next row. (A manual commit can be triggered by adding a 'Commit'-flow operation to any of the section's queues.) After that, the section is fully processed again.

Named expressions on a repeatable section go out-of scope and get readded as fresh instances on each iteration.

When processing sections, the layout controller iterates over the section itself and for each child-node a new subordinate layout-controller is instantiated and is handed over control over the structural processing. Creating these sub-controllers happens indirectly using the LayoutControllerFactory.

Group

A group is a section that has a grouping expression. Groups are repeatable by default.

Flow-Behaviour

If the group is repeatable, the repeat-test described above will use the parent group as first test for repeatability. The group's grouping expression will be ignored for that matter.

Detail-Section

The detail band is a ordinary band with no extra properties. It is repeatable by default and contains an 'Advance' Flow-Operation in its postprocessing queue. The main purpose of the Detail-Section is to provide some familiar elements for all users who are used to the old reporting engines.

JFreeReport

This is the first element of all report processings. The JFreeReport object holds several global objects, which influence the whole report processing.

  • Data-Factory and the initial Query
  • Input-Parameters
  • The global Style-Sheet collection (and in there the default page-format)
  • The report configuration and the localization support
  • Configuration information
  • Document Meta-Data information

The data-factory is a generic interface to query data-sources. The query-string and the given input-parameters are used for the query operation.

The input parameters are a plain collection of objects. These parameters are accessible through the global DataRow.

The (possibly empty) style-sheet collection is passed on to the layouting layer. It is a list Cascading-StyleSheets and contains layouting information.

Flow-Behaviour

When entering the report, the layout controller will first try to use the specified Query-name and input-parameters to query the DataSource Factory. The returned ReportData-object is used as primary dataset.

After a dataset has been acquired, the normal section processing takes place.

When all sub-nodes of the report-element have been full processed, the queried dataset is removed from the global datarow and all pending mark-contexts will be closed. Depending on the controll flow, a report is not required to process all rows contained in the Report-Data-collection.

Sub-Report

A Subreport is a lightweight report definition. It does not contain input parameters. but declares a set of input and output mappings, which mediate between the inner and outer data context.

Flow-Behaviour

when entering the subreport object, the engine maps all declared input-mappings under possibly changed names from the outside data set into the inner dataset. likewise the export parameters get mapped from the inside to the outer datarows.

The exported parameters can be accessed by deep-traversing expressions and stay visible after the subreport has been finished. (In that sense they behave like any expression that has been marked as 'preserved'.)