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

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
All Implemented Interfaces:
Serializable, Cloneable, DataTarget, ReportDefinition, ReportElement
Direct Known Subclasses:
MasterReport, SubReport

public abstract class AbstractReportDefinition
extends Section
implements ReportDefinition

The AbstractReportDefinition serves as base-implementation for both the SubReport and the global JFreeReport instance. There's no point to subclass this class any further.

ReportDefinitions define the query string to "default" by default, change this to reflect the accepted queries in your data-source.

Author:
Thomas Morgner
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.pentaho.reporting.engine.classic.core.Element
ANONYMOUS_ELEMENT_PREFIX
 
Method Summary
 void addExpression(Expression function)
          Adds a function to the report's collection of expressions.
 void addGroup(CrosstabGroup group)
          Adds a crosstab group.
 void addGroup(RelationalGroup group)
          Adds a group to the report.
 void addPreProcessor(ReportPreProcessor preProcessor)
           
 void addReportModelListener(ReportModelListener listener)
           
 void addStructureFunction(StructureFunction function)
          Adds a structural function to the report.
 Object clone()
          Clones the report.
 Element derive(boolean preserveElementInstanceIds)
          Creates a deep copy of this element and regenerates all instance-ids.
 void fireModelLayoutChanged(ReportElement node, int type, Object parameter)
           
 org.pentaho.reporting.libraries.resourceloader.ResourceKey getContentBase()
          Returns the content base of this report.
abstract  DataFactory getDataFactory()
          Returns the data factory that has been assigned to this report.
 DataRow getDataRow()
          Returns the current datarow assigned to this report definition.
 DataSchemaDefinition getDataSchemaDefinition()
           
 long getDatasourceChangeTracker()
           
 org.pentaho.reporting.libraries.resourceloader.ResourceKey getDefinitionSource()
          Returns the resource-key of the file that defined this element.
 DetailsFooter getDetailsFooter()
          Returns the details header band.
 DetailsHeader getDetailsHeader()
          Returns the details header band.
 ReportElement getElement(int index)
          Returns the element stored add the given index.
 int getElementCount()
          Returns the number of elements in this section.
 ExpressionCollection getExpressions()
          Returns the expressions for the report.
 Group getGroup(int groupIndex)
          Returns the group at the specified index or null, if there is no such group.
 RelationalGroup getGroupByName(String name)
          Searches a group by its defined name.
 int getGroupCount()
          Returns the number of groups in this report.
 ItemBand getItemBand()
          Returns the report's item band.
 NoDataBand getNoDataBand()
          Returns the report's watermark band.
 long getNonVisualsChangeTracker()
           
 PageFooter getPageFooter()
          Returns the page footer.
 PageHeader getPageHeader()
          Returns the page header.
 ReportPreProcessor getPreProcessor(int index)
           
 int getPreProcessorCount()
           
 ReportPreProcessor[] getPreProcessors()
           
 ReportProperties getProperties()
          Deprecated. Report-Properties should not be used anymore.
 Object getProperty(String key)
          Deprecated. Do not use this method anymore. Use the master report's parameters instead.
 String getQuery()
          Returns a new query or query-name that is used when retrieving the data from the data-factory.
 int getQueryLimit()
           
 int getQueryTimeout()
           
 ReportDefinition getReportDefinition()
          Returns the currently assigned report definition.
 ReportFooter getReportFooter()
          Returns the page footer.
 ReportHeader getReportHeader()
          Returns the report header.
 ResourceBundleFactory getResourceBundleFactory()
          Returns the resource bundle factory for this report definition.
abstract  org.pentaho.reporting.libraries.resourceloader.ResourceManager getResourceManager()
           
 Group getRootGroup()
          Returns the list of groups for the report.
 StructureFunction getStructureFunction(int index)
          Returns the structure function at the given position.
 int getStructureFunctionCount()
          Returns the number of structural functions added to the report.
 StructureFunction[] getStructureFunctions()
          Returns a copy of all structure functions contained in the report.
 StyleSheetCollection getStyleSheetCollection()
          Returns the stylesheet collection of this report.
 Watermark getWatermark()
          Returns the report's watermark band.
 void removeExpression(Expression expression)
           
 void removeGroup(CrosstabGroup group)
           
 void removeGroup(RelationalGroup deleteGroup)
           
 void removePreProcessor(ReportPreProcessor preProcessor)
           
 void removeReportModelListener(ReportModelListener listener)
           
 void removeStructureFunction(StructureFunction f)
          Removes the given function from the collection of structure functions.
 void setContentBase(org.pentaho.reporting.libraries.resourceloader.ResourceKey key)
          Defines the content base for the report.
abstract  void setDataFactory(DataFactory dataFactory)
          Sets the data factory for the report.
 void setDataSchemaDefinition(DataSchemaDefinition dataSchemaDefinition)
           
 void setDefinitionSource(org.pentaho.reporting.libraries.resourceloader.ResourceKey key)
           
 void setDetailsFooter(DetailsFooter band)
          Sets the item band for the report.
 void setDetailsHeader(DetailsHeader band)
          Sets the item band for the report.
 void setElementAt(int position, Element element)
           
 void setExpressions(ExpressionCollection expressions)
          Sets the expressions for the report.
 void setGroups(GroupList groupList)
          Sets the groups for this report.
 void setItemBand(ItemBand band)
          Sets the item band for the report.
 void setNoDataBand(NoDataBand band)
          Sets the watermark band for the report.
 void setPageFooter(PageFooter footer)
          Sets the page footer.
 void setPageHeader(PageHeader header)
          Sets the page header.
 void setProperty(String key, Object value)
          Deprecated. Properties should not be used. Use the master-report's parameters instead.
 void setQuery(String query)
          Defines a new query or query-name that is used when retrieving the data from the data-factory.
 void setQueryLimit(int queryLimit)
           
 void setQueryTimeout(int queryTimeout)
           
 void setReportFooter(ReportFooter footer)
          Sets the report footer.
 void setReportHeader(ReportHeader header)
          Sets the report header.
 void setResourceBundleFactory(ResourceBundleFactory resourceBundleFactory)
          Redefines the resource bundle factory for the report.
 void setRootGroup(Group rootGroup)
           
 void setWatermark(Watermark band)
          Sets the watermark band for the report.
 
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, getName, getObjectID, getParent, getParentSection, getStyle, getStyleExpression, getStyleExpressions, getTreeLock, getValue, isDynamicContent, isVisible, notifyNodeChildAdded, notifyNodeChildRemoved, notifyNodePropertiesChanged, notifyNodePropertiesChanged, notifyNodeStructureChanged, setAttribute, setAttribute, setAttributeExpression, setDataSource, setDynamicContent, setElementType, setHRefTarget, setId, setName, 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.ReportDefinition
getPageDefinition
 
Methods inherited from interface org.pentaho.reporting.engine.classic.core.ReportElement
getAttribute, getAttributeExpression, getAttributeExpressionNames, getAttributeExpressionNamespaces, getAttributeNames, getAttributeNamespaces, getAttributes, getId, getMetaData, getName, getObjectID, getParentSection, getStyle, getStyleExpression, getStyleExpressions, getTreeLock, setAttribute, setAttributeExpression, setStyleExpression
 

Method Detail

getResourceBundleFactory

public ResourceBundleFactory getResourceBundleFactory()
Returns the resource bundle factory for this report definition. The ResourceBundleFactory is used in internationalized reports to create the resourcebundles holding the localized resources.

Returns:
the assigned resource bundle factory.

setResourceBundleFactory

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

Parameters:
resourceBundleFactory - the new resource bundle factory, never null.
Throws:
NullPointerException - if the given ResourceBundleFactory is null.

getPreProcessorCount

public int getPreProcessorCount()

getPreProcessors

public ReportPreProcessor[] getPreProcessors()

getPreProcessor

public ReportPreProcessor getPreProcessor(int index)

addPreProcessor

public void addPreProcessor(ReportPreProcessor preProcessor)

removePreProcessor

public void removePreProcessor(ReportPreProcessor preProcessor)

getRootGroup

public Group getRootGroup()
Description copied from interface: ReportDefinition
Returns the list of groups for the report.

Specified by:
getRootGroup in interface ReportDefinition
Returns:
The list of groups.

setRootGroup

public void setRootGroup(Group rootGroup)

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.

Parameters:
key - the key.
value - the value.

getProperties

public ReportProperties getProperties()
Deprecated. Report-Properties should not be used anymore.

Returns the report properties collection for this report.

These properties are inherited to all ReportStates generated for this report.

Specified by:
getProperties in interface ReportDefinition
Returns:
the report properties.

getProperty

public Object getProperty(String key)
Deprecated. Do not use this method anymore. Use the master report's parameters instead.

Returns the value of the property with the specified key.

Parameters:
key - the key.
Returns:
the property value.

setReportHeader

public void setReportHeader(ReportHeader header)
Sets the report header.

Parameters:
header - the report header (null not permitted).

getReportHeader

public ReportHeader getReportHeader()
Returns the report header.

Specified by:
getReportHeader in interface ReportDefinition
Returns:
the report header (never null).

setReportFooter

public void setReportFooter(ReportFooter footer)
Sets the report footer.

Parameters:
footer - the report footer (null not permitted).

getReportFooter

public ReportFooter getReportFooter()
Returns the page footer.

Specified by:
getReportFooter in interface ReportDefinition
Returns:
the report footer (never null).

setPageHeader

public void setPageHeader(PageHeader header)
Sets the page header.

Parameters:
header - the page header (null not permitted).

getPageHeader

public PageHeader getPageHeader()
Returns the page header.

Specified by:
getPageHeader in interface ReportDefinition
Returns:
the page header (never null).

setPageFooter

public void setPageFooter(PageFooter footer)
Sets the page footer.

Parameters:
footer - the page footer (null not permitted).

getPageFooter

public PageFooter getPageFooter()
Returns the page footer.

Specified by:
getPageFooter in interface ReportDefinition
Returns:
the page footer (never null).

setWatermark

public void setWatermark(Watermark band)
Sets the watermark band for the report.

Parameters:
band - the new watermark band (null not permitted).

getNoDataBand

public NoDataBand getNoDataBand()
Returns the report's watermark band.

Specified by:
getNoDataBand in interface ReportDefinition
Returns:
the watermark band (never null).

setNoDataBand

public void setNoDataBand(NoDataBand band)
Sets the watermark band for the report.

Parameters:
band - the new watermark band (null not permitted).

getWatermark

public Watermark getWatermark()
Returns the report's watermark band.

Specified by:
getWatermark in interface ReportDefinition
Returns:
the watermark band (never null).

setItemBand

public void setItemBand(ItemBand band)
Sets the item band for the report.

Parameters:
band - the new item band (null not permitted).

getItemBand

public ItemBand getItemBand()
Returns the report's item band.

Specified by:
getItemBand in interface ReportDefinition
Returns:
the item band (never null).

setDetailsHeader

public void setDetailsHeader(DetailsHeader band)
Sets the item band for the report.

Parameters:
band - the new item band (null not permitted).

getDetailsHeader

public DetailsHeader getDetailsHeader()
Returns the details header band.

Specified by:
getDetailsHeader in interface ReportDefinition
Returns:
The details header band.

setDetailsFooter

public void setDetailsFooter(DetailsFooter band)
Sets the item band for the report.

Parameters:
band - the new item band (null not permitted).

getDetailsFooter

public DetailsFooter getDetailsFooter()
Returns the details header band.

Specified by:
getDetailsFooter in interface ReportDefinition
Returns:
The details header band.

addGroup

public void addGroup(RelationalGroup group)
Adds a group to the report. This replaces the group body on the group with a new data-group-body composed of the existing itemband and no-databand.

Parameters:
group - the group.

addGroup

public void addGroup(CrosstabGroup group)
Adds a crosstab group. This replaces any existing crosstabs and all the details sections.

Parameters:
group -

removeGroup

public void removeGroup(CrosstabGroup group)

removeGroup

public void removeGroup(RelationalGroup deleteGroup)

setGroups

public void setGroups(GroupList groupList)
Sets the groups for this report. If no list (null) or an empty list is given, an default group is created. This default group contains no elements and starts at the first record of the data and ends on the last record.

Parameters:
groupList - the list of groups.

getGroupCount

public int getGroupCount()
Returns the number of groups in this report.

Every report has at least one group defined.

Specified by:
getGroupCount in interface ReportDefinition
Returns:
the group count.

getGroup

public Group getGroup(int groupIndex)
Returns the group at the specified index or null, if there is no such group.

Specified by:
getGroup in interface ReportDefinition
Parameters:
groupIndex - the group index.
Returns:
the requested group.
Throws:
IllegalArgumentException - if the count is negative.
IndexOutOfBoundsException - if the count is greater than the number of defined groups.

getGroupByName

public RelationalGroup getGroupByName(String name)
Searches a group by its defined name. This method returns null, if the group was not found.

Parameters:
name - the name of the group.
Returns:
the group or null if not found.

addExpression

public void addExpression(Expression function)
Adds a function to the report's collection of expressions.

Parameters:
function - the function.

getQueryTimeout

public int getQueryTimeout()
Specified by:
getQueryTimeout in interface ReportDefinition

setQueryTimeout

public void setQueryTimeout(int queryTimeout)

getQueryLimit

public int getQueryLimit()
Specified by:
getQueryLimit in interface ReportDefinition

setQueryLimit

public void setQueryLimit(int queryLimit)

getQuery

public String getQuery()
Returns a new query or query-name that is used when retrieving the data from the data-factory.

Specified by:
getQuery in interface ReportDefinition
Returns:
the query-string.

setQuery

public void setQuery(String query)
Defines a new query or query-name that is used when retrieving the data from the data-factory.

Parameters:
query - the query-string.
See Also:
DataFactory.queryData(String,DataRow)

getStyleSheetCollection

public StyleSheetCollection getStyleSheetCollection()
Returns the stylesheet collection of this report. The stylesheet collection is fixed for the report and all elements of the report. When a band or group is added to the report it will get registered with this stylesheet collection and cannot be used in an different report.

Specified by:
getStyleSheetCollection in interface ReportDefinition
Returns:
the stylesheet collection of the report, never null.

getDataRow

public DataRow getDataRow()
Returns the current datarow assigned to this report definition. JFreeReport objects do not hold a working DataRow, as the final contents of the data cannot be known, until the reporting has started.

Returns:
the default implementation for non-processed reports.

getExpressions

public ExpressionCollection getExpressions()
Returns the expressions for the report. When adding or removing expressions on the list, make sure to call "notifyStructureChanged" afterwards when in design-mode.

Returns:
the expressions.

setExpressions

public void setExpressions(ExpressionCollection expressions)
Sets the expressions for the report.

Parameters:
expressions - the expressions (null not permitted).

clone

public Object clone()
             throws CloneNotSupportedException
Clones the report.

Specified by:
clone in interface DataTarget
Overrides:
clone in class Element
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 Element
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

setElementAt

public void setElementAt(int position,
                         Element element)
Specified by:
setElementAt in class Section

getElementCount

public int getElementCount()
Description copied from class: Section
Returns the number of elements in this section.

Specified by:
getElementCount in class Section
Returns:
the number of elements of this section.

getElement

public ReportElement getElement(int index)
Description copied from class: Section
Returns the element stored add the given index.

Specified by:
getElement in class Section
Parameters:
index - the element position within this section
Returns:
the element

setContentBase

public void setContentBase(org.pentaho.reporting.libraries.resourceloader.ResourceKey key)
Defines the content base for the report. The content base will be used to resolve relative URLs during the report generation and resource loading. If there is no content base defined, it will be impossible to resolve relative paths.

Parameters:
key - the content base or null.

getContentBase

public org.pentaho.reporting.libraries.resourceloader.ResourceKey getContentBase()
Returns the content base of this report. The content base is used to resolve relative URLs during the report generation and resource loading. If there is no content base defined, it will be impossible to resolve relative paths.

Overrides:
getContentBase in class Element
Returns:
the content base or null, if no content base is defined.

setDefinitionSource

public void setDefinitionSource(org.pentaho.reporting.libraries.resourceloader.ResourceKey key)

getDefinitionSource

public org.pentaho.reporting.libraries.resourceloader.ResourceKey getDefinitionSource()
Description copied from class: Element
Returns the resource-key of the file that defined this element. This method may return null if the whole report was created in memory.

Overrides:
getDefinitionSource in class Element
Returns:
the the definition source.

getReportDefinition

public ReportDefinition getReportDefinition()
Returns the currently assigned report definition.

Specified by:
getReportDefinition in interface ReportElement
Overrides:
getReportDefinition in class Element
Returns:
the report definition or null, if no report has been assigned.

getDataFactory

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

Returns:
the data factory.

setDataFactory

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

Parameters:
dataFactory - the data factory for the report, never null.

addReportModelListener

public void addReportModelListener(ReportModelListener listener)

removeReportModelListener

public void removeReportModelListener(ReportModelListener listener)

fireModelLayoutChanged

public void fireModelLayoutChanged(ReportElement node,
                                   int type,
                                   Object parameter)

getDatasourceChangeTracker

public long getDatasourceChangeTracker()

getNonVisualsChangeTracker

public long getNonVisualsChangeTracker()

removeExpression

public void removeExpression(Expression expression)

getDataSchemaDefinition

public DataSchemaDefinition getDataSchemaDefinition()

setDataSchemaDefinition

public void setDataSchemaDefinition(DataSchemaDefinition dataSchemaDefinition)

getResourceManager

public abstract org.pentaho.reporting.libraries.resourceloader.ResourceManager getResourceManager()

addStructureFunction

public void addStructureFunction(StructureFunction function)
Adds a structural function to the report. Structural functions perform content preparation and maintainance operations before elements are layouted or printed.

Structural function can live on their own processing level and are evaluated after the user expressions but before the layout expressions have been evaluated.

Parameters:
function - the structure function.

getStructureFunctionCount

public int getStructureFunctionCount()
Returns the number of structural functions added to the report.

Returns:
the function count.

getStructureFunction

public StructureFunction getStructureFunction(int index)
Returns the structure function at the given position.

Parameters:
index - the position of the function in the list.
Returns:
the function, never null.
Throws:
IndexOutOfBoundsException - if the index is invalid.

removeStructureFunction

public void removeStructureFunction(StructureFunction f)
Removes the given function from the collection of structure functions. This removes only the first occurence of the function, in case a function has been added twice.

Parameters:
f - the function to be removed.

getStructureFunctions

public StructureFunction[] getStructureFunctions()
Returns a copy of all structure functions contained in the report. Modifying the function instances will not alter the functions contained in the report.

Returns:
the functions.