org.apache.myfaces.trinidad.model

## Class CollectionModelDecorator

- java.lang.Object
- - javax.faces.model.DataModel
  - - org.apache.myfaces.trinidad.model.CollectionModel
    - - org.apache.myfaces.trinidad.model.CollectionModelDecorator

- All Implemented Interfaces:
    Iterable, LocalRowKeyIndex, RowKeyIndex

      public abstract class CollectionModelDecorator
      extends CollectionModel

  Used by anybody who wants to wrap the `CollectionModel` class.

  This class simply delegates all the CollectionModel functionalities to the wrapped class.

  The wrapped CollectionModel is returned by the `getCollectionModel` method. And that method needs to be overriden by the subclasses.
  See Also:
    `getCollectionModel()`

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from interface org.apache.myfaces.trinidad.model.LocalRowKeyIndex

      `LocalRowKeyIndex.Confidence, LocalRowKeyIndex.LocalCachingStrategy`

  - ### Field Summary

    - ### Fields inherited from class org.apache.myfaces.trinidad.model.CollectionModel

      `UNKNOWN_ROW_LIMIT, UNLIMITED_ROW`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `CollectionModelDecorator()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addDataModelListener(javax.faces.model.DataModelListener listener)`
    `boolean` | `areRowsAvailable(int rowCount)` Check if a range of rows is available starting from the current row.
    `boolean` | `areRowsAvailable(int startIndex, int rowCount)` Check if a range of rows is available from a starting index.
    `boolean` | `areRowsAvailable(Object startRowKey, int rowCount)` Check if a range of rows is available from a starting row key This method makes the row with the given row key current and calls `#areRowsAvailable(rowsToCheck)`.
    `boolean` | `areRowsLocallyAvailable(int rowCount)` Check if a range of rows is locally available starting from current position.
    `boolean` | `areRowsLocallyAvailable(int startIndex, int rowCount)` Check if a range of rows is locally available starting from a row index.
    `boolean` | `areRowsLocallyAvailable(Object startRowKey, int rowCount)` Check if a range of rows is locally available starting from a row key.
    `void` | `clearCachedRow(int index)` Clear a row from the local cache by row index
    `void` | `clearCachedRow(Object rowKey)` Clear a row from the local cache by row key
    `void` | `clearCachedRows(int startingIndex, int rowsToClear)` Clear the requested range of rows from the local cache
    `void` | `clearCachedRows(Object startingRowKey, int rowsToClear)` Clear the requested range of rows from the local cache
    `void` | `clearLocalCache()` clear all rows from the local cache
    `LocalRowKeyIndex.LocalCachingStrategy` | `getCachingStrategy()` Indicates the caching strategy supported by the model
    `protected abstract CollectionModel` | `getCollectionModel()` This method returns the wrapped `CollectionModel`.
    `javax.faces.model.DataModelListener[]` | `getDataModelListeners()`
    `int` | `getEstimatedRowCount()` Convenient API to return a row count estimate.
    `LocalRowKeyIndex.Confidence` | `getEstimatedRowCountConfidence()` Helper API to determine if the row count returned from `CollectionModel.getEstimatedRowCount()` is EXACT, or an ESTIMATE.
    `int` | `getRowCount()` Gets the number of values in this collection
    `Object` | `getRowData()` Gets the current value identified by the current index or rowKey.
    `Object` | `getRowData(int rowIndex)` Gets the rowData at the given index.
    `Object` | `getRowData(Object rowKey)` Returns the rowData for the given rowKey without changing model currency.
    `int` | `getRowIndex()` Gets the index of the current value.
    `Object` | `getRowKey()` Gets the rowKey of the current row.
    `List<SortCriterion>` | `getSortCriteria()` Gets the criteria that this collection is sorted by.
    `Object` | `getWrappedData()`
    `boolean` | `isRowAvailable()` Checks to make sure a value exists for the current index or rowKey.
    `boolean` | `isRowAvailable(int rowIndex)` Checks to see if the row at the given index is available.
    `boolean` | `isRowAvailable(Object rowKey)` Check for an available row by row key.
    `boolean` | `isRowLocallyAvailable(int rowIndex)` Given a row index, check if the row is locally available.
    `boolean` | `isRowLocallyAvailable(Object rowKey)` Given a row key, check if the row is locally available.
    `boolean` | `isSortable(String property)` Return true if this collection is sortable by the given property.
    `void` | `removeDataModelListener(javax.faces.model.DataModelListener listener)`
    `void` | `setRowIndex(int i)` Sets up a value at a particular index to be the current value.
    `void` | `setRowKey(Object key)` Finds the row with the matching key and makes it current
    `void` | `setSortCriteria(List<SortCriterion> criteria)` Sorts this collection by the given criteria.
    `void` | `setWrappedData(Object object)`

    - ### Methods inherited from class org.apache.myfaces.trinidad.model.CollectionModel

      `addRowKeyChangeListener, ensureRowsAvailable, fireRowKeyChange, getRowLimit, removeRowKeyChangeListener`

    - ### Methods inherited from class javax.faces.model.DataModel

      `iterator`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### CollectionModelDecorator

          public CollectionModelDecorator()

  - ### Method Detail

    - #### getRowKey

          public Object getRowKey()

      Description copied from class: `CollectionModel`
      Gets the rowKey of the current row. rowKeys are safer to use than row indices because rowKeys are unaffected by mutations to this collection. rowKeys should have efficient implementations of `Object.equals(java.lang.Object)` and `Object.hashCode()` as they will be used as keys in hashtables. rowKeys should also be Serializable, so that the application can run under all JSF state-saving schemes.
      Specified by:
        `getRowKey` in interface `RowKeyIndex`
      Specified by:
        `getRowKey` in class `CollectionModel`
      Returns:
        this key should be Serializable and immutable.
      See Also:
        `CollectionModel.setRowKey(java.lang.Object)`

    - #### setRowKey

          public void setRowKey(Object key)

      Description copied from class: `CollectionModel`
      Finds the row with the matching key and makes it current
      Specified by:
        `setRowKey` in interface `RowKeyIndex`
      Specified by:
        `setRowKey` in class `CollectionModel`
      Parameters:
        `key` - the rowKey, previously obtained from `CollectionModel.getRowKey()`.

    - #### isRowAvailable

          public boolean isRowAvailable(int rowIndex)

      Description copied from class: `CollectionModel`
      Checks to see if the row at the given index is available. This method makes the given row current and calls `DataModel.isRowAvailable()`. Finally, the row that was current before this method was called is made current again.
      Specified by:
        `isRowAvailable` in interface `RowKeyIndex`
      Overrides:
        `isRowAvailable` in class `CollectionModel`
      Parameters:
        `rowIndex` - the index of the row to check.
      Returns:
        true if data for the row exists.
      See Also:
        `DataModel.isRowAvailable()`

    - #### isRowAvailable

          public boolean isRowAvailable(Object rowKey)

      Description copied from class: `CollectionModel`
      Check for an available row by row key. This method makes the given row current and calls `DataModel.isRowAvailable()`. Finally, the row that was current before this method was called is made current again.
      Specified by:
        `isRowAvailable` in interface `RowKeyIndex`
      Overrides:
        `isRowAvailable` in class `CollectionModel`
      Parameters:
        `rowKey` - the row key for the row to check.
      Returns:
        true if data for the row exists otherwise return false
      See Also:
        `DataModel.isRowAvailable()`

    - #### getRowData

          public Object getRowData(int rowIndex)

      Description copied from class: `CollectionModel`
      Gets the rowData at the given index. This method makes the given row current and calls `DataModel.getRowData()`. Finally, the row that was current before this method was called is made current again.
      Specified by:
        `getRowData` in interface `RowKeyIndex`
      Overrides:
        `getRowData` in class `CollectionModel`
      Parameters:
        `rowIndex` - the index of the row to get data from.
      Returns:
        the data for the given row.
      See Also:
        `DataModel.getRowData()`

    - #### getRowData

          public Object getRowData(Object rowKey)

      Description copied from class: `CollectionModel`
      Returns the rowData for the given rowKey without changing model currency. Implementations may choose to implement this behavior by saving and restoring the currency.
      Specified by:
        `getRowData` in interface `RowKeyIndex`
      Overrides:
        `getRowData` in class `CollectionModel`
      Parameters:
        `rowKey` - the row key of the row to get data from.
      Returns:
        the data for the given row.
      See Also:
        `DataModel.getRowData()`

    - #### isSortable

          public boolean isSortable(String property)

      Description copied from class: `CollectionModel`
      Return true if this collection is sortable by the given property. This implementation always returns false;
      Overrides:
        `isSortable` in class `CollectionModel`

    - #### getSortCriteria

          public List<SortCriterion> getSortCriteria()

      Description copied from class: `CollectionModel`
      Gets the criteria that this collection is sorted by. This method should never return null. This implementation always returns an empty List.
      Overrides:
        `getSortCriteria` in class `CollectionModel`
      Returns:
        each element in this List is of type SortCriterion. An empty list is returned if this collection is not sorted.
      See Also:
        `SortCriterion`

    - #### setSortCriteria

          public void setSortCriteria(List<SortCriterion> criteria)

      Description copied from class: `CollectionModel`
      Sorts this collection by the given criteria.
      Overrides:
        `setSortCriteria` in class `CollectionModel`
      Parameters:
        `criteria` - Each element in this List must be of type SortCriterion. The empty list may be used to cancel any sort order. null should be treated the same as an empty list.
      See Also:
        `SortCriterion`

    - #### areRowsAvailable

          public boolean areRowsAvailable(int startIndex,
                                 int rowCount)

      Description copied from class: `CollectionModel`
      Check if a range of rows is available from a starting index. The current row does not change after this call
      Specified by:
        `areRowsAvailable` in interface `RowKeyIndex`
      Overrides:
        `areRowsAvailable` in class `CollectionModel`
      Parameters:
        `startIndex` - the starting index for the range
        `rowCount` - number of rows to check. If rowsToCheck < 0 set startIndex = startIndex - abs(rowsToCheck) + 1. This allows for checking for row availability from the end position. For example to check for availability of n rows from the end, call isRangeAvailable(getRowCount()-1, -n)
      Returns:
        true if rows are available otherwise return `false`

    - #### areRowsAvailable

          public boolean areRowsAvailable(Object startRowKey,
                                 int rowCount)

      Description copied from class: `CollectionModel`
      Check if a range of rows is available from a starting row key This method makes the row with the given row key current and calls `#areRowsAvailable(rowsToCheck)`. The current row does not change after this call
      Specified by:
        `areRowsAvailable` in interface `RowKeyIndex`
      Overrides:
        `areRowsAvailable` in class `CollectionModel`
      Parameters:
        `startRowKey` - the starting row key for the range
        `rowCount` - number of rows to check
      Returns:
        true if rows are available otherwise return false
      See Also:
        `CollectionModel.areRowsAvailable(int).`

    - #### areRowsAvailable

          public boolean areRowsAvailable(int rowCount)

      Description copied from class: `CollectionModel`
      Check if a range of rows is available starting from the current row. This implementation checks the start and end rows in the range for availability. If the number of requested rows is greater than the total row count, this implementation checks for available rows up to the row count. The current row does not change after this call
      Specified by:
        `areRowsAvailable` in interface `RowKeyIndex`
      Overrides:
        `areRowsAvailable` in class `CollectionModel`
      Parameters:
        `rowCount` - number of rows to check
      Returns:
        true rows are available otherwise return false

    - #### areRowsLocallyAvailable

          public boolean areRowsLocallyAvailable(int startIndex,
                                        int rowCount)

      Description copied from class: `CollectionModel`
      Check if a range of rows is locally available starting from a row index.
      Specified by:
        `areRowsLocallyAvailable` in interface `LocalRowKeyIndex`
      Overrides:
        `areRowsLocallyAvailable` in class `CollectionModel`
      Parameters:
        `startIndex` - starting row index to check
        `rowCount` - number of rows to check
      Returns:
        default implementation returns `false`
      See Also:
        `CollectionModel.areRowsAvailable(int, int)`

    - #### areRowsLocallyAvailable

          public boolean areRowsLocallyAvailable(Object startRowKey,
                                        int rowCount)

      Description copied from class: `CollectionModel`
      Check if a range of rows is locally available starting from a row key.
      Specified by:
        `areRowsLocallyAvailable` in interface `LocalRowKeyIndex`
      Overrides:
        `areRowsLocallyAvailable` in class `CollectionModel`
      Parameters:
        `startRowKey` - starting row key to check
        `rowCount` - number of rows to check
      Returns:
        default implementation returns `false`
      See Also:
        `CollectionModel.areRowsAvailable(Object, int)`

    - #### areRowsLocallyAvailable

          public boolean areRowsLocallyAvailable(int rowCount)

      Description copied from class: `CollectionModel`
      Check if a range of rows is locally available starting from current position. This implementation checks for a valid current index and delegates to `areRowsLocallyAvailable(startIndex, rowsToCheck)`
      Specified by:
        `areRowsLocallyAvailable` in interface `LocalRowKeyIndex`
      Overrides:
        `areRowsLocallyAvailable` in class `CollectionModel`
      Parameters:
        `rowCount` - number of rows to check
      Returns:
        default implementation returns `false`
      See Also:
        `areRowsLocallyAvailable(startIndex, rowsToCheck)`

    - #### isRowLocallyAvailable

          public boolean isRowLocallyAvailable(int rowIndex)

      Description copied from class: `CollectionModel`
      Given a row index, check if the row is locally available.
      Specified by:
        `isRowLocallyAvailable` in interface `LocalRowKeyIndex`
      Overrides:
        `isRowLocallyAvailable` in class `CollectionModel`
      Parameters:
        `rowIndex` - row index to check
      Returns:
        default implementation returns `false`

    - #### isRowLocallyAvailable

          public boolean isRowLocallyAvailable(Object rowKey)

      Description copied from class: `CollectionModel`
      Given a row key, check if the row is locally available.
      Specified by:
        `isRowLocallyAvailable` in interface `LocalRowKeyIndex`
      Overrides:
        `isRowLocallyAvailable` in class `CollectionModel`
      Parameters:
        `rowKey` - row key to check
      Returns:
        default implementation returns `false`

    - #### getEstimatedRowCount

          public int getEstimatedRowCount()

      Description copied from class: `CollectionModel`
      Convenient API to return a row count estimate.
      Specified by:
        `getEstimatedRowCount` in interface `LocalRowKeyIndex`
      Overrides:
        `getEstimatedRowCount` in class `CollectionModel`
      Returns:
        This implementation returns exact row count
      See Also:
        `DataModel.getRowCount()`

    - #### getEstimatedRowCountConfidence

          public LocalRowKeyIndex.Confidence getEstimatedRowCountConfidence()

      Description copied from class: `CollectionModel`
      Helper API to determine if the row count returned from `CollectionModel.getEstimatedRowCount()` is EXACT, or an ESTIMATE.
      Specified by:
        `getEstimatedRowCountConfidence` in interface `LocalRowKeyIndex`
      Overrides:
        `getEstimatedRowCountConfidence` in class `CollectionModel`
      Returns:
        This implementation returns exact row count
      See Also:
        `DataModel.getRowCount()`

    - #### clearLocalCache

          public void clearLocalCache()

      clear all rows from the local cache
      Specified by:
        `clearLocalCache` in interface `LocalRowKeyIndex`
      Overrides:
        `clearLocalCache` in class `CollectionModel`

    - #### clearCachedRows

          public void clearCachedRows(int startingIndex,
                             int rowsToClear)

      Clear the requested range of rows from the local cache
      Specified by:
        `clearCachedRows` in interface `LocalRowKeyIndex`
      Overrides:
        `clearCachedRows` in class `CollectionModel`
      Parameters:
        `startingIndex` - starting row index for the range to clear
        `rowsToClear` - number of rows to clear from the cache
      See Also:
        `CollectionModel.clearLocalCache()`

    - #### clearCachedRows

          public void clearCachedRows(Object startingRowKey,
                             int rowsToClear)

      Clear the requested range of rows from the local cache
      Specified by:
        `clearCachedRows` in interface `LocalRowKeyIndex`
      Overrides:
        `clearCachedRows` in class `CollectionModel`
      Parameters:
        `startingRowKey` - starting row key for the range to clear
        `rowsToClear` - number of rows to clear from the cache
      See Also:
        `CollectionModel.clearLocalCache()`

    - #### clearCachedRow

          public void clearCachedRow(int index)

      Clear a row from the local cache by row index
      Specified by:
        `clearCachedRow` in interface `LocalRowKeyIndex`
      Overrides:
        `clearCachedRow` in class `CollectionModel`
      Parameters:
        `index` - row index for the row to clear from the cache
      See Also:
        `CollectionModel.clearCachedRows(int, int)`

    - #### clearCachedRow

          public void clearCachedRow(Object rowKey)

      Clear a row from the local cache by row key
      Specified by:
        `clearCachedRow` in interface `LocalRowKeyIndex`
      Overrides:
        `clearCachedRow` in class `CollectionModel`
      Parameters:
        `rowKey` - row key for the row to clear from the cache
      See Also:
        `CollectionModel.clearCachedRows(Object, int)`

    - #### getCachingStrategy

          public LocalRowKeyIndex.LocalCachingStrategy getCachingStrategy()

      Indicates the caching strategy supported by the model
      Specified by:
        `getCachingStrategy` in interface `LocalRowKeyIndex`
      Overrides:
        `getCachingStrategy` in class `CollectionModel`
      Returns:
        caching strategy supported by the model
      See Also:
        `LocalCachingStrategy`

    - #### isRowAvailable

          public boolean isRowAvailable()

      Description copied from interface: `RowKeyIndex`
      Checks to make sure a value exists for the current index or rowKey. This is useful if the number of values in this collection is not known (See `RowKeyIndex.getRowCount()`).
      Specified by:
        `isRowAvailable` in interface `RowKeyIndex`
      Specified by:
        `isRowAvailable` in class `javax.faces.model.DataModel`
      Returns:
        true if a value exists; false otherwise.
      See Also:
        `RowKeyIndex.getRowKey()`, `RowKeyIndex.getRowIndex()`

    - #### getRowCount

          public int getRowCount()

      Description copied from interface: `RowKeyIndex`
      Gets the number of values in this collection
      Specified by:
        `getRowCount` in interface `RowKeyIndex`
      Specified by:
        `getRowCount` in class `javax.faces.model.DataModel`
      Returns:
        -1 if the number of values is not known.

    - #### getRowData

          public Object getRowData()

      Description copied from interface: `RowKeyIndex`
      Gets the current value identified by the current index or rowKey.
      Specified by:
        `getRowData` in interface `RowKeyIndex`
      Specified by:
        `getRowData` in class `javax.faces.model.DataModel`
      Returns:
        null if the current value has been cleared.
      See Also:
        `RowKeyIndex.getRowKey()`, `RowKeyIndex.getRowIndex()`

    - #### getRowIndex

          public int getRowIndex()

      Description copied from interface: `RowKeyIndex`
      Gets the index of the current value. The current value is returned by calling {link #getRowData}
      Specified by:
        `getRowIndex` in interface `RowKeyIndex`
      Specified by:
        `getRowIndex` in class `javax.faces.model.DataModel`
      Returns:
        the zero-based index of the current value, or -1 if there is no current value

    - #### setRowIndex

          public void setRowIndex(int i)

      Description copied from interface: `RowKeyIndex`
      Sets up a value at a particular index to be the current value. The current value is returned by calling {link #getRowData}
      Specified by:
        `setRowIndex` in interface `RowKeyIndex`
      Specified by:
        `setRowIndex` in class `javax.faces.model.DataModel`
      Parameters:
        `i` - the zero-based index of the value to make current. Use -1 to clear the current value

    - #### getWrappedData

          public Object getWrappedData()

      Specified by:
        `getWrappedData` in class `javax.faces.model.DataModel`

    - #### setWrappedData

          public void setWrappedData(Object object)

      Specified by:
        `setWrappedData` in class `javax.faces.model.DataModel`

    - #### addDataModelListener

          public void addDataModelListener(javax.faces.model.DataModelListener listener)

      Overrides:
        `addDataModelListener` in class `javax.faces.model.DataModel`

    - #### getDataModelListeners

          public javax.faces.model.DataModelListener[] getDataModelListeners()

      Overrides:
        `getDataModelListeners` in class `javax.faces.model.DataModel`

    - #### removeDataModelListener

          public void removeDataModelListener(javax.faces.model.DataModelListener listener)

      Overrides:
        `removeDataModelListener` in class `javax.faces.model.DataModel`

    - #### getCollectionModel

          protected abstract CollectionModel getCollectionModel()

      This method returns the wrapped `CollectionModel`.
      Returns:
        the wrapped CollectionModel

Copyright © 2001-2017 The Apache Software Foundation. All Rights Reserved.