org.pentaho.reporting.engine.classic.core
Class MasterReport

java.lang.Object
  extended by org.pentaho.reporting.engine.classic.core.Element
      extended by org.pentaho.reporting.engine.classic.core.Section
          extended by org.pentaho.reporting.engine.classic.core.AbstractReportDefinition
              extended by org.pentaho.reporting.engine.classic.core.MasterReport
All Implemented Interfaces:
Serializable, Cloneable, DataTarget, ReportDefinition, ReportElement

public class MasterReport
extends AbstractReportDefinition

A JFreeReport instance is used as report template to define the visual layout of a report and to collect all data sources for the reporting. Possible data sources are the TableModel, Expressions or ReportParameterValues. The report is made up of 'bands', which are used repeatedly as necessary to generate small sections of the report.

Accessing the bands and the elements:

The different bands can be accessed using the main report definition (this class):

Groups can be queried using getGroup(int groupLevel). The group header and footer are accessible through the group object, so use getGroup(int groupLevel).getGroupHeader() and getGroup(int groupLevel).getGroupFooter().

All report elements share the same stylesheet collection. Report elements cannot be shared between two different report instances. Adding a report element to one band will remove it from the other one.

For dynamic computation of content you can add Expressions and Functions to the report.

Creating a new instance of JFreeReport seems to lock down the JDK on some Windows Systems, where no printer driver is installed. To prevent that behaviour on these systems, you can set the Configuration key "org.pentaho.reporting.engine.classic.core.NoPrinterAvailable" to "false" and JFreeReport will use a hardcoded default page format instead.

A JFreeReport object always acts as Master-Report. The JFreeReport object defines the global report-configuration, the report's datasource (through the DataFactory property) and the ResourceBundleFactory (for localization).

Author:
David Gilbert, Thomas Morgner
See Also:
Serialized Form

Field Summary
static String NAME_PROPERTY
          Key for the 'report name' property.
static String REPORT_DATE_PROPERTY
          Key for the 'report date' property.
 
Fields inherited from class org.pentaho.reporting.engine.classic.core.Element
ANONYMOUS_ELEMENT_PREFIX
 
Constructor Summary
MasterReport()
          The default constructor.
 
Method Summary
 Object clone()
          Clones the report.
static ResourceBundleFactory computeAndInitResourceBundleFactory(ResourceBundleFactory resourceBundleFactory, ReportEnvironment environment)
           
 Element derive(boolean preserveElementInstanceIds)
          Creates a deep copy of this element and regenerates all instance-ids.
 org.pentaho.reporting.libraries.docbundle.DocumentBundle getBundle()
           
 Integer getCompatibilityLevel()
           
 org.pentaho.reporting.libraries.base.config.Configuration getConfiguration()
          Returns the report's configuration.
 DataFactory getDataFactory()
          Returns the data factory that has been assigned to this report.
 String getName()
          Returns the name of the report.
 PageDefinition getPageDefinition()
          Returns the logical page definition for this report.
 ReportParameterDefinition getParameterDefinition()
           
 ReportParameterValues getParameterValues()
           
 org.pentaho.reporting.libraries.base.config.ModifiableConfiguration getReportConfiguration()
          Returns the report configuration.
 ReportEnvironment getReportEnvironment()
           
 org.pentaho.reporting.libraries.resourceloader.ResourceManager getResourceManager()
          Returns the resource manager that was responsible for loading the report.
 String getTitle()
           
 void setBundle(org.pentaho.reporting.libraries.docbundle.DocumentBundle bundle)
           
 void setCompatibilityLevel(Integer level)
           
 void setDataFactory(DataFactory dataFactory)
          Sets the data factory for the report.
 void setName(String name)
          Sets the name of the report.
 void setPageDefinition(PageDefinition format)
          Defines the logical page definition for this report.
 void setParameterDefinition(ReportParameterDefinition parameterDefinition)
           
 void setProperty(String key, Object value)
          Deprecated. Properties should not be used. Use the master-report's parameters instead.
 void setReportEnvironment(ReportEnvironment reportEnvironment)
           
 void setResourceBundleFactory(ResourceBundleFactory resourceBundleFactory)
          Redefines the resource bundle factory for the report.
 void setResourceManager(org.pentaho.reporting.libraries.resourceloader.ResourceManager resourceManager)
          Assigns a new resource manager or clears the current one.
 void updateLegacyConfiguration()
           
 
Methods inherited from class org.pentaho.reporting.engine.classic.core.AbstractReportDefinition
addExpression, addGroup, addGroup, addPreProcessor, addReportModelListener, addStructureFunction, fireModelLayoutChanged, getContentBase, getDataRow, getDataSchemaDefinition, getDatasourceChangeTracker, getDefinitionSource, getDetailsFooter, getDetailsHeader, getElement, getElementCount, getExpressions, getGroup, getGroupByName, getGroupCount, getItemBand, getNoDataBand, getNonVisualsChangeTracker, getPageFooter, getPageHeader, getPreProcessor, getPreProcessorCount, getPreProcessors, getProperties, getProperty, getQuery, getQueryLimit, getQueryTimeout, getReportDefinition, getReportFooter, getReportHeader, getResourceBundleFactory, getRootGroup, getStructureFunction, getStructureFunctionCount, getStructureFunctions, getStyleSheetCollection, getWatermark, removeExpression, removeGroup, removeGroup, removePreProcessor, removeReportModelListener, removeStructureFunction, setContentBase, setDataSchemaDefinition, setDefinitionSource, setDetailsFooter, setDetailsHeader, setElementAt, setExpressions, setGroups, setItemBand, setNoDataBand, setPageFooter, setPageHeader, setQuery, setQueryLimit, setQueryTimeout, setReportFooter, setReportHeader, setRootGroup, setWatermark
 
Methods inherited from class org.pentaho.reporting.engine.classic.core.Element
derive, getAttribute, getAttributeExpression, getAttributeExpressionNames, getAttributeExpressionNamespaces, getAttributeNames, getAttributeNamespaces, getAttributes, getChangeTracker, getDataSource, getElementType, getElementTypeName, getHRefTarget, getId, getMetaData, getObjectID, getParent, getParentSection, getStyle, getStyleExpression, getStyleExpressions, getTreeLock, getValue, isDynamicContent, isVisible, notifyNodeChildAdded, notifyNodeChildRemoved, notifyNodePropertiesChanged, notifyNodePropertiesChanged, notifyNodeStructureChanged, setAttribute, setAttribute, setAttributeExpression, setDataSource, setDynamicContent, setElementType, setHRefTarget, setId, setStyleExpression, setVisible, toString
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.pentaho.reporting.engine.classic.core.ReportElement
getAttribute, getAttributeExpression, getAttributeExpressionNames, getAttributeExpressionNamespaces, getAttributeNames, getAttributeNamespaces, getAttributes, getId, getMetaData, getObjectID, getParentSection, getStyle, getStyleExpression, getStyleExpressions, getTreeLock, setAttribute, setAttributeExpression, setStyleExpression
 

Field Detail

NAME_PROPERTY

public static final String NAME_PROPERTY
Key for the 'report name' property.

See Also:
Constant Field Values

REPORT_DATE_PROPERTY

public static final String REPORT_DATE_PROPERTY
Key for the 'report date' property.

See Also:
Constant Field Values
Constructor Detail

MasterReport

public MasterReport()
The default constructor. Creates an empty but fully initialized report.

Method Detail

setResourceBundleFactory

public void setResourceBundleFactory(ResourceBundleFactory resourceBundleFactory)
Redefines the resource bundle factory for the report.

Overrides:
setResourceBundleFactory in class AbstractReportDefinition
Parameters:
resourceBundleFactory - the new resource bundle factory, never null.
Throws:
NullPointerException - if the given ResourceBundleFactory is null.

getBundle

public org.pentaho.reporting.libraries.docbundle.DocumentBundle getBundle()

setBundle

public void setBundle(org.pentaho.reporting.libraries.docbundle.DocumentBundle bundle)

getParameterDefinition

public ReportParameterDefinition getParameterDefinition()

setParameterDefinition

public void setParameterDefinition(ReportParameterDefinition parameterDefinition)

getReportEnvironment

public ReportEnvironment getReportEnvironment()

setReportEnvironment

public void setReportEnvironment(ReportEnvironment reportEnvironment)

getTitle

public String getTitle()

getName

public String getName()
Returns the name of the report.

You can reference the report name in your XML report template file using the key 'report.name'.

Specified by:
getName in interface ReportElement
Overrides:
getName in class Element
Returns:
the name.

setName

public void setName(String name)
Sets the name of the report.

The report name is stored as a property (key NAME_PROPERTY) inside the report properties. If you supply null as the name, the property is removed.

Overrides:
setName in class Element
Parameters:
name - the name of the report.

getPageDefinition

public PageDefinition getPageDefinition()
Returns the logical page definition for this report.

Returns:
the page definition.

setPageDefinition

public void setPageDefinition(PageDefinition format)
Defines the logical page definition for this report. If no format is defined the system's default page format is used.

If there is no printer available and the JDK blocks during the printer discovery, you can set the Configuration key "org.pentaho.reporting.engine.classic.core.NoPrinterAvailable" to "false" and JFreeReport will use a hardcoded default page format instead.

Parameters:
format - the default format (null permitted).

getDataFactory

public DataFactory getDataFactory()
Returns the data factory that has been assigned to this report. The data factory will never be null.

Specified by:
getDataFactory in class AbstractReportDefinition
Returns:
the data factory.

setDataFactory

public void setDataFactory(DataFactory dataFactory)
Sets the data factory for the report.

Specified by:
setDataFactory in class AbstractReportDefinition
Parameters:
dataFactory - the data factory for the report, never null.

clone

public Object clone()
             throws CloneNotSupportedException
Clones the report.

Specified by:
clone in interface DataTarget
Overrides:
clone in class AbstractReportDefinition
Returns:
the clone.
Throws:
CloneNotSupportedException - this should never happen.

derive

public Element derive(boolean preserveElementInstanceIds)
               throws CloneNotSupportedException
Description copied from class: Element
Creates a deep copy of this element and regenerates all instance-ids.

Overrides:
derive in class AbstractReportDefinition
Parameters:
preserveElementInstanceIds - defines whether this call generates new instance-ids for the derived elements. Instance-IDs are used by the report processor to recognize reoccurring elements and must not changed within the report run. Outside of the report processors new instance ids should be generated at all times to separate instances and to make them uniquely identifiable.
Returns:
the copy of the element.
Throws:
CloneNotSupportedException

getReportConfiguration

public org.pentaho.reporting.libraries.base.config.ModifiableConfiguration getReportConfiguration()
Returns the report configuration.

The report configuration is automatically set up when the report is first created, and uses the global JFreeReport configuration as its parent.

Returns:
the report configuration.

getConfiguration

public org.pentaho.reporting.libraries.base.config.Configuration getConfiguration()
Returns the report's configuration.

Returns:
the configuration.

getResourceManager

public org.pentaho.reporting.libraries.resourceloader.ResourceManager getResourceManager()
Returns the resource manager that was responsible for loading the report. This method will return a default manager if the report had been constructed otherwise.

The resource manager of the report should be used for all resource loading activities during the report processing.

Specified by:
getResourceManager in class AbstractReportDefinition
Returns:
the resource manager, never null.

setResourceManager

public void setResourceManager(org.pentaho.reporting.libraries.resourceloader.ResourceManager resourceManager)
Assigns a new resource manager or clears the current one. If no resource manager is set anymore, the next call to 'getResourceManager' will recreate one.

Parameters:
resourceManager - the new resource manager or null.

getParameterValues

public ReportParameterValues getParameterValues()

setProperty

public void setProperty(String key,
                        Object value)
Deprecated. Properties should not be used. Use the master-report's parameters instead.

Adds a property to the report.

If a property with the given name already exists, the property will be updated with the new value. If the supplied value is null, the property will be removed.

Developers are free to add any properties they want to a report, and then display those properties in the report. For example, you might add a 'user.name' property, so that you can display the username in the header of a report.

Overrides:
setProperty in class AbstractReportDefinition
Parameters:
key - the key.
value - the value.

computeAndInitResourceBundleFactory

public static ResourceBundleFactory computeAndInitResourceBundleFactory(ResourceBundleFactory resourceBundleFactory,
                                                                        ReportEnvironment environment)
                                                                 throws ReportProcessingException
Throws:
ReportProcessingException

getCompatibilityLevel

public Integer getCompatibilityLevel()

setCompatibilityLevel

public void setCompatibilityLevel(Integer level)

updateLegacyConfiguration

public void updateLegacyConfiguration()