Package com.day.cq.reporting
Class Data
- java.lang.Object
-
- 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:
- During the creation of a report, the class must only be used from a single thread.
- After the data has been completely retrieved (and before adding it to a cache), it
must be "compacted" (using
compact()
). - After being compacted, the data object is considered immutable. All methods
that change state are then considered to throw
IllegalStateException
s.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description 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 theabstract ChartData
createChartData(int limit)
Creates a suitableChartData
object for this report data.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 specifiedProcessor
.void
postProcess(Processor[] processors)
Use this method to process each data row with the specifiedProcessor
s.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 specifiedJSONWriter
.abstract void
writeSortInfoJSON(JSONWriter writer)
Writes the sort information for the report to the specifiedJSONWriter
.abstract void
writeTypesJSON(JSONWriter writer)
Writes the type definition for each column to the specifiedJSONWriter
.
-
-
-
Constructor Detail
-
Data
public Data(Report report)
-
-
Method Detail
-
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 columntotal
- 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 specifiedProcessor
s.- 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 bysortingDirection
- The sorting direction
-
postProcess
public void postProcess(Processor processor)
Use this method to process each data row with the specifiedProcessor
.- 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 suitableChartData
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 specifiedJSONWriter
.- 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 specifiedJSONWriter
.- 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 specifiedJSONWriter
.- Parameters:
writer
- The writer to stream the data tolocale
- The locale to be used for formatting datastart
- The first record to be streamed;null
to stream from the beginninglimit
- The maximum number of records to be streamed;null
to stream to the end- Throws:
JSONException
- if writing the result has failed
-
-