Class Data


  • public abstract class Data
    extends java.lang.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 IllegalStateExceptions.
    • 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 java.util.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,
                                           java.util.Locale locale,
                                           java.lang.Integer start,
                                           java.lang.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