Package com.day.cq.reporting
Class Data
java.lang.Object
com.day.cq.reporting.Data
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
IllegalStateExceptions.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddColumnTotal(Column col, CellValue total) Adds the specified column total.voidAdds the specified row of data.voidcompact()This class must called after the data has been calculated completely, no further changes have to be made and theabstract ChartDatacreateChartData(int limit) Creates a suitableChartDataobject for this report data.Gets an iterator over the columns of the report data.getColumnTotal(Column col) Gets the total value of the specified column.intGets the interal reporting version the report was created for.getRowAt(int rowIndex) Gets a row by its index.intGets the number of rows.booleanDetermines if the report data has of grouped columns.voidpostProcess(Processor processor) Use this method to process each data row with the specifiedProcessor.voidpostProcess(Processor[] processors) Use this method to process each data row with the specifiedProcessors.voidsortByColumn(Column sortingColumn, Sorting.Direction sortingDirection) Sorts the result data by the specified column.abstract voidwriteDataJSON(JSONWriter writer, Locale locale, Integer start, Integer limit) Writes the result to the specifiedJSONWriter.abstract voidwriteSortInfoJSON(JSONWriter writer) Writes the sort information for the report to the specifiedJSONWriter.abstract voidwriteTypesJSON(JSONWriter writer) Writes the type definition for each column to the specifiedJSONWriter.
-
Constructor Details
-
Data
-
-
Method Details
-
hasGroupedColumns
public boolean hasGroupedColumns()Determines if the report data has of grouped columns.- Returns:
trueif the report contains data from grouped columns
-
addRow
Adds the specified row of data.- Parameters:
rowToAdd- The row to add
-
getRowAt
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
Gets an iterator over the columns of the report data.- Returns:
- The iterator
-
addColumnTotal
Adds the specified column total.- Parameters:
col- The columntotal- The total value
-
getColumnTotal
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
Use this method to process each data row with the specifiedProcessors.- 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
Sorts the result data by the specified column.- Parameters:
sortingColumn- The column to sort bysortingDirection- The sorting direction
-
postProcess
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
Creates a suitableChartDataobject for this report data.- Parameters:
limit- Number of data to be returned for the chart- Returns:
- The corresponding chart data
-
writeTypesJSON
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
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;nullto stream from the beginninglimit- The maximum number of records to be streamed;nullto stream to the end- Throws:
JSONException- if writing the result has failed
-