Package org.apache.tapestry5.grid

## Interface GridDataSource

- All Known Implementing Classes:
    `CollectionGridDataSource`, `HibernateGridDataSource`, `JpaGridDataSource`, `NullDataSource`

      public interface GridDataSource

  Defines how a `Grid` component (and its sub-components) gain access to the row data that is displayed on the page. In many cases, this is just a wrapper around a simple List, but the abstractions exist to support access to a large data set that is accessible in sections.

- - ### Method Summary

    All Methods Instance Methods Abstract Methods Default Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `int` | `getAvailableRows()` | Returns the number of rows available in the data source.
    `default int` | `getAvailableRows​(int limit)` | Return the number of rows available in the data source with an upper limit.
    `java.lang.Class` | `getRowType()` | Returns the type of value in the rows, or null if not known.
    `java.lang.Object` | `getRowValue​(int index)` | Returns the row value at the provided index.
    `default boolean` | `isEmpty()` | Return whether the data source is empty, i.e.
    `void` | `prepare​(int startIndex, int endIndex, java.util.List<SortConstraint> sortConstraints)` | Invoked to allow the source to prepare to present values.

- - ### Method Detail

    - #### isEmpty

          default boolean isEmpty()

      Return whether the data source is empty, i.e. does not have any rows available.

    - #### getAvailableRows

          default int getAvailableRows​(int limit)

      Return the number of rows available in the data source with an upper limit. If determining the total number of rows is expensive, this method should be overridden to provide a more efficient implementation. Please note that the default Grid pager will still determine the total number of rows, so for this to have an effect, a custom pager should be used.
      Parameters:
        `limit` - the upper limit
      Returns:
        the number of rows or `limit`, whichever is lower

    - #### getAvailableRows

          int getAvailableRows()

      Returns the number of rows available in the data source.

    - #### prepare

          void prepare​(int startIndex,
                       int endIndex,
                       java.util.List<SortConstraint> sortConstraints)

      Invoked to allow the source to prepare to present values. This gives the source a chance to pre-fetch data (when appropriate) and informs the source of the desired sort order. Sorting comes first, then extraction by range.
      Parameters:
        `startIndex` - the starting index to be retrieved
        `endIndex` - the ending index to be retrieved
        `sortConstraints` - identify how data is to be sorted

    - #### getRowValue

          java.lang.Object getRowValue​(int index)

      Returns the row value at the provided index. This method will be invoked in sequential order. In rare instances, `getAvailableRows()` may return a different number of rows than are actually available (i.e., the database was changed between calls to `getAvailableRows()` and the call to `prepare(int, int, java.util.List)`). In that case, this method should return null for any out-of-range indexes.

    - #### getRowType

          java.lang.Class getRowType()

      Returns the type of value in the rows, or null if not known. This value is used to create a default `BeanModel` when no such model is explicitly provided.
      Returns:
        the row type, or null