com.day.cq.reporting
Class Data

java.lang.Object
  extended by com.day.cq.reporting.Data

public abstract class Data
extends Object

This class represents the data of a report.

Instances of this class may be used concurrently (through caches), so the following policy must be followed:


Field Summary
protected  List<Column> columns
          List of the report's column (available after compacting)
protected  Map<Column,CellValue> columnTotals
          Column totals
protected  boolean hasGroupedColumns
          Flag that determines if the data has grouped columns
protected  boolean isCompacted
          Flag that determines if the data has already been compacted.
protected static org.slf4j.Logger log
          Logger
protected  Report report
          The report
protected  int reportingVersion
          Version of report data (0 - CQ 5.4; 1 - CQ 5.5)
protected  List<DataRow> rows
          Data rows
 
Constructor Summary
Data(Report report)
           
 
Method Summary
 void addColumnTotal(Column col, CellValue total)
          Adds the specified column total.
 void addRow(DataRow rowToAdd)
          Adds the specified row of data.
 void compact()
          This class must called after the data has been calculated completely, no further changes have to be made and the
abstract  ChartData createChartData(int limit)
          Creates a suitable ChartData object for this report data.
protected  void ensureImmutable()
          Ensures that the report data is immutable; throws an IllegalStateException otherwise.
protected  void ensureMutable()
          Ensures that the data is still mutable.
 Iterator<Column> getColumns()
          Gets an iterator over the columns of the report data.
 CellValue getColumnTotal(Column col)
          Gets the total value of the specified column.
 int getReportingVersion()
          Gets the interal reporting version the report was created for.
 DataRow getRowAt(int rowIndex)
          Gets a row by its index.
 int getRowCnt()
          Gets the number of rows.
 boolean hasGroupedColumns()
          Determines if the report data has of grouped columns.
 void postProcess(Processor processor)
          Use this method to process each data row with the specified Processor.
 void postProcess(Processor[] processors)
          Use this method to process each data row with the specified Processors.
 void sortByColumn(Column sortingColumn, Sorting.Direction sortingDirection)
          Sorts the result data by the specified column.
abstract  void writeDataJSON(JSONWriter writer, Locale locale, Integer start, Integer limit)
          Writes the result to the specified JSONWriter.
abstract  void writeSortInfoJSON(JSONWriter writer)
          Writes the sort information for the report to the specified JSONWriter.
abstract  void writeTypesJSON(JSONWriter writer)
          Writes the type definition for each column to the specified JSONWriter.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected static final org.slf4j.Logger log
Logger


report

protected Report report
The report


rows

protected final List<DataRow> rows
Data rows


columnTotals

protected final Map<Column,CellValue> columnTotals
Column totals


hasGroupedColumns

protected final boolean hasGroupedColumns
Flag that determines if the data has grouped columns


isCompacted

protected boolean isCompacted
Flag that determines if the data has already been compacted.


columns

protected List<Column> columns
List of the report's column (available after compacting)


reportingVersion

protected int reportingVersion
Version of report data (0 - CQ 5.4; 1 - CQ 5.5)

Constructor Detail

Data

public Data(Report report)
Method Detail

ensureMutable

protected void ensureMutable()
Ensures that the data is still mutable. Throws an IllegalStateException otherwise.


ensureImmutable

protected void ensureImmutable()
Ensures that the report data is immutable; throws an IllegalStateException otherwise.


hasGroupedColumns

public boolean hasGroupedColumns()
Determines if the report data has of grouped columns.

Returns:
true if the report contains data from grouped columns

addRow

public void addRow(DataRow rowToAdd)
Adds the specified row of data.

Parameters:
rowToAdd - The row to add

getRowAt

public DataRow getRowAt(int rowIndex)
Gets a row by its index.

Parameters:
rowIndex - The index
Returns:
The row

getRowCnt

public int getRowCnt()
Gets the number of rows.

Returns:
Number of rows

getColumns

public Iterator<Column> getColumns()
Gets an iterator over the columns of the report data.

Returns:
The iterator

addColumnTotal

public void addColumnTotal(Column col,
                           CellValue total)
Adds the specified column total.

Parameters:
col - The column
total - The total value

getColumnTotal

public CellValue getColumnTotal(Column col)
Gets the total value of the specified column.

Parameters:
col - The (aggregated) column to determine the total value for
Returns:
The total value of the specified column

compact

public void compact()
This class must called after the data has been calculated completely, no further changes have to be made and the


postProcess

public void postProcess(Processor[] processors)
Use this method to process each data row with the specified Processors.

Parameters:
processors - The array of processing modules to execute. Note that if one of the modules declares a row to be deleted, the modules specified at higher array indices will not be executed on that row.

sortByColumn

public void sortByColumn(Column sortingColumn,
                         Sorting.Direction sortingDirection)
Sorts the result data by the specified column.

Parameters:
sortingColumn - The column to sort by
sortingDirection - The sorting direction

postProcess

public void postProcess(Processor processor)
Use this method to process each data row with the specified Processor.

Parameters:
processor - The processing module

getReportingVersion

public int getReportingVersion()

Gets the interal reporting version the report was created for.

This can be used to ensure backwards compatibility with reports that were created for different CQ versions if some default behaviour had to be changed.

Returns:
The version of reporting the report has been created for (0 - CQ 5.4; 1 - CQ 5.5)
Since:
5.5

createChartData

public abstract ChartData createChartData(int limit)
Creates a suitable ChartData object for this report data.

Parameters:
limit - Number of data to be returned for the chart
Returns:
The corresponding chart data

writeTypesJSON

public abstract void writeTypesJSON(JSONWriter writer)
                             throws JSONException
Writes the type definition for each column to the specified JSONWriter.

Parameters:
writer - The writer to stream the data to
Throws:
JSONException - if writing the type definition has failed

writeSortInfoJSON

public abstract void writeSortInfoJSON(JSONWriter writer)
                                throws JSONException
Writes the sort information for the report to the specified JSONWriter.

Parameters:
writer - The writer to stream the data to
Throws:
JSONException - if writing the sort info has failed

writeDataJSON

public abstract void writeDataJSON(JSONWriter writer,
                                   Locale locale,
                                   Integer start,
                                   Integer limit)
                            throws JSONException
Writes the result to the specified JSONWriter.

Parameters:
writer - The writer to stream the data to
locale - The locale to be used for formatting data
start - The first record to be streamed; null to stream from the beginning
limit - The maximum number of records to be streamed; null to stream to the end
Throws:
JSONException - if writing the result has failed


Copyright © 2011-2013 Adobe Systems Incorporated. All Rights Reserved.