planetj.database.report
Class ReportBreak

java.lang.Object
  extended byplanetj.database.report.ReportBreak
All Implemented Interfaces:
java.lang.Cloneable, java.io.Serializable
Direct Known Subclasses:
OverallReportBreak

public class ReportBreak
extends java.lang.Object
implements java.io.Serializable, java.lang.Cloneable

Defines how and where reports should be generated for a RowCollection.

A report contains the results of an operation (such as a summation or average) on one or more columns in a group of Rows. These reports are contained in ReportBreakRows (a subclass of Row) and placed in the same RowCollection as the original Row objects.

ReportBreakRow objects are always located immediately after the group of Rows which were used to generate the contained report. This group of Rows may be a subset of the Rows returned by an SQL query, and it may include Rows from more than one RowCollection (in cases where the number of Rows returned by a query exceeds the number of Rows allowed in a RowCollection). The "break" where a ReportBreakRow is inserted is specified by the BreakColumn property - whenever two adjacent Rows contain different values in that column a report is generated and a ReportBreakRow is placed between those two Rows in the RowCollection.

ReportBreaks are intended to be used in conjunction with the ORDER BY sql clause. The ORDER BY clause will sort Rows by a specific column or columns, and then reports can be generated for each group of values that was ordered.

See Also:
Serialized Form

Nested Class Summary
static class ReportBreak.ReportBreakSpacingRow
           
 
Constructor Summary
ReportBreak()
          ReportBreak constructor
ReportBreak(ReportBreakCollection prbc, java.lang.String pColumnFunctionToken, java.util.List pFieldNames, java.lang.String pBreakColumnName)
          Deprecated. Use the default constructor instead. Relying on this constructor makes subclassing more difficult
 
Method Summary
 java.lang.Object clone()
          Clones this ReportBreak
 ReportBreak cloneReportBreak()
          Clones this ReportBreak
 boolean equals(java.lang.Object o)
          Tests if this ReportBreak is equal to another ReportBreak.
protected  Row generateReport(java.util.List pFieldDescriptors)
          Deprecated. Use the method which takes in a RowCollection as well
protected  Row generateReport(java.util.List pFieldDescriptors, RowCollection rc)
          Generates a report containing the values of all this ReportBreak's column functions.
 java.lang.String getBreakColumn()
          Gets the name of the column which this ReportBreak will monitor for breaks.
protected  java.util.List getColumnFunctions()
          Sets the List ColumnFunctions which are used to generate ReportBreakRows for this ReportBreak.
 java.lang.String getColumnFunctionToken()
          Gets the column function token representing the function that will be used to generate this ReportBreak's reports
 java.util.List getFieldNames()
          Gets the List of field names identifying the columns which will be used by this ReportBreak for generating ReportBreakRows.
protected  java.util.List getFieldNamesInternal()
          Gets the List of field names identifying the columns which will be used by this ReportBreak for generating ReportBreakRows.
 int getIndex()
          Gets the index of this ReportBreak.
 java.lang.Object getLastValue()
          Gets the last value of the field which is being monitored for breaks
 OverallReportBreak getOverallReportBreak()
          If an OverallReportBreak with the same field descriptors and column function was created when this ReportBreak was created, then that OverallReportBreak is returned.
 ReportBreakCollection getReportBreakCollection()
          Gets the ReportBreakCollection which contains this ReportBreak
 java.util.List getRows()
          Gets a List of the ReportBreakRows which have been generated by this ReportBreak
 int hashCode()
          Returns a hashCode for this ReportBreak.
protected  void initialize(ReportBreak rb)
          Initializes this ReportBreak based on another ReportBreak (which must be compatible with this ReportBreak)
protected  void initialize(ReportBreakCollection prbc, java.lang.String pColumnFunctionToken, java.util.List pFieldNames, java.lang.String pBreakColumnName)
          Initializes a ReportBreak.
protected  boolean isAddReportBreakBefore(Row row)
          Tests if a report break row should be add to the RowCollection prior to the specified row You can use the getBreakColumn() method (which returns the name of the break column) and the getLastValue() method (which returns the value of the break column field in the previous row) to determine if a report break row should be added.

This method is not invoked unless there is at least one row already in the RowCollection
 boolean isGenerateReportForSingleRow()
          Should reports be generated for a single row?
 boolean isOverallReportBreak()
          This is not an OverallReportBreak
 Row processRow(Row pRow, RowCollection pRC)
          Passes a Row into to one or more column functions, and determines if a ReportBreakRow needs to be positioned prior to that Row
 void reset()
          Clears all values from all of the column functions
protected  void setBreakColumn(java.lang.String newBreakColumn)
          Sets the name of the column which this ReportBreak will monitor for breaks.
protected  void setColumnFunctions(java.util.List newColumnFunctions)
          Sets the List ColumnFunctions which are used to generate ReportBreakRows for this ReportBreak.
protected  void setFieldNames(java.util.List pFieldNames)
          Sets the column names for this ReportBreak
protected  void setGenerateReportForSingleRow(boolean val)
          Should reports be generated for a single row?
protected  void setLastValue(java.lang.Object newLastValue)
          Gets the last value of the field which is being monitored for breaks
protected  void setOverallReportBreak(OverallReportBreak pORB)
          Sets the OverallReportBreak associated with this ReportBreak
protected  void setReportBreakCollection(ReportBreakCollection newReportBreakCollection)
          Sets the ReportBreakCollection which contains this ReportBreak
protected  void setRows(java.util.List newRows)
          Sets a List of the ReportBreakRows which have been generated by this ReportBreak
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ReportBreak

public ReportBreak()
ReportBreak constructor


ReportBreak

public ReportBreak(ReportBreakCollection prbc,
                   java.lang.String pColumnFunctionToken,
                   java.util.List pFieldNames,
                   java.lang.String pBreakColumnName)
            throws DataEngineException
Deprecated. Use the default constructor instead. Relying on this constructor makes subclassing more difficult

ReportBreak constructor

Method Detail

clone

public java.lang.Object clone()
Clones this ReportBreak


cloneReportBreak

public ReportBreak cloneReportBreak()
Clones this ReportBreak


equals

public boolean equals(java.lang.Object o)
Tests if this ReportBreak is equal to another ReportBreak. Two ReportBreaks are equal if given the same RowCollection, they would produce the same report(s). The current states of their column functions are not compared


generateReport

protected Row generateReport(java.util.List pFieldDescriptors)
                      throws CMException
Deprecated. Use the method which takes in a RowCollection as well

Generates a report containing the values of all this ReportBreak's column functions. The report is returned in a ReportBreakRow.

Throws:
CMException

generateReport

protected Row generateReport(java.util.List pFieldDescriptors,
                             RowCollection rc)
                      throws CMException
Generates a report containing the values of all this ReportBreak's column functions. The report is returned in a ReportBreakRow.

Throws:
CMException

getBreakColumn

public java.lang.String getBreakColumn()
Gets the name of the column which this ReportBreak will monitor for breaks.


getColumnFunctions

protected java.util.List getColumnFunctions()
Sets the List ColumnFunctions which are used to generate ReportBreakRows for this ReportBreak. There is one ColumnFunction object in the List for each FieldDescriptor in this ReportBreak


getColumnFunctionToken

public java.lang.String getColumnFunctionToken()
Gets the column function token representing the function that will be used to generate this ReportBreak's reports


getFieldNames

public java.util.List getFieldNames()
Gets the List of field names identifying the columns which will be used by this ReportBreak for generating ReportBreakRows.


getFieldNamesInternal

protected java.util.List getFieldNamesInternal()
Gets the List of field names identifying the columns which will be used by this ReportBreak for generating ReportBreakRows.


getIndex

public int getIndex()
Gets the index of this ReportBreak. When multiple ReportBreakRows are placed in a single break in a RowCollection they are ordered according to their indices. The smallest index is 0.


getLastValue

public java.lang.Object getLastValue()
Gets the last value of the field which is being monitored for breaks


getOverallReportBreak

public OverallReportBreak getOverallReportBreak()
If an OverallReportBreak with the same field descriptors and column function was created when this ReportBreak was created, then that OverallReportBreak is returned. Otherwise, null is returned.


getReportBreakCollection

public ReportBreakCollection getReportBreakCollection()
Gets the ReportBreakCollection which contains this ReportBreak


getRows

public java.util.List getRows()
Gets a List of the ReportBreakRows which have been generated by this ReportBreak


hashCode

public int hashCode()
Returns a hashCode for this ReportBreak. The current state of the column functions are not taken into account in the hashCode


initialize

protected void initialize(ReportBreak rb)
                   throws CMException
Initializes this ReportBreak based on another ReportBreak (which must be compatible with this ReportBreak)

Throws:
CMException

initialize

protected void initialize(ReportBreakCollection prbc,
                          java.lang.String pColumnFunctionToken,
                          java.util.List pFieldNames,
                          java.lang.String pBreakColumnName)
                   throws DataEngineException
Initializes a ReportBreak. This method should be invoked before this ReportBreak is used

Throws:
DataEngineException

isAddReportBreakBefore

protected boolean isAddReportBreakBefore(Row row)
                                  throws DataEngineException
Tests if a report break row should be add to the RowCollection prior to the specified row You can use the getBreakColumn() method (which returns the name of the break column) and the getLastValue() method (which returns the value of the break column field in the previous row) to determine if a report break row should be added.

This method is not invoked unless there is at least one row already in the RowCollection

Parameters:
row - The row about to be added to the RowCollection
Returns:
If a report break should first be added to the RowCollection before the specified row
Throws:
DataEngineException

isGenerateReportForSingleRow

public boolean isGenerateReportForSingleRow()
Should reports be generated for a single row?


isOverallReportBreak

public boolean isOverallReportBreak()
This is not an OverallReportBreak


processRow

public Row processRow(Row pRow,
                      RowCollection pRC)
               throws CMException
Passes a Row into to one or more column functions, and determines if a ReportBreakRow needs to be positioned prior to that Row

Parameters:
pRow - A Row that was just added to a RowCollection
Returns:
A Row that should be inserted into the RowCollection prior to pRow, or null if no such ReportBreakRow exists.
Throws:
CMException

reset

public void reset()
Clears all values from all of the column functions


setBreakColumn

protected void setBreakColumn(java.lang.String newBreakColumn)
Sets the name of the column which this ReportBreak will monitor for breaks.


setColumnFunctions

protected void setColumnFunctions(java.util.List newColumnFunctions)
Sets the List ColumnFunctions which are used to generate ReportBreakRows for this ReportBreak. There is one ColumnFunction object in the List for each FieldDescriptor in this ReportBreak


setFieldNames

protected void setFieldNames(java.util.List pFieldNames)
                      throws DataEngineException
Sets the column names for this ReportBreak

Throws:
DataEngineException

setGenerateReportForSingleRow

protected void setGenerateReportForSingleRow(boolean val)
Should reports be generated for a single row?


setLastValue

protected void setLastValue(java.lang.Object newLastValue)
Gets the last value of the field which is being monitored for breaks


setOverallReportBreak

protected void setOverallReportBreak(OverallReportBreak pORB)
Sets the OverallReportBreak associated with this ReportBreak


setReportBreakCollection

protected void setReportBreakCollection(ReportBreakCollection newReportBreakCollection)
Sets the ReportBreakCollection which contains this ReportBreak


setRows

protected void setRows(java.util.List newRows)
Sets a List of the ReportBreakRows which have been generated by this ReportBreak