org.apache.myfaces.trinidad.model

## Class ModelUtils

- java.lang.Object
- - org.apache.myfaces.trinidad.model.ModelUtils

-     public final class ModelUtils
      extends Object

  Provides convenience methods for converting objects into models, and working with models.

- - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static int` | `findLastIndex(RowKeyIndex table, int startIndex, int endIndex)` finds the last index in the given RowKeyIndex that has data and returns the next index.
    `static int` | `getRowCount(RowKeyIndex model)` finds the last index in the given RowKeyIndex that has data and returns the next index.
    `static Iterator<Object>` | `getRowKeyIterator(CollectionModel model)` Gets an iteration of all the rowKeys in a collection.
    `static CollectionModel` | `toCollectionModel(Object value)` Converts an instance into a CollectionModel.
    `static javax.faces.model.DataModel` | `toDataModel(Object value)` Converts an instance into a DataModel.
    `static MenuModel` | `toMenuModel(Object value)` Converts an instance into a MenuModel
    `static TreeModel` | `toTreeModel(Object value)` Converts an instance into a TreeModel

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

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

- - ### Method Detail

    - #### getRowKeyIterator

          public static Iterator<Object> getRowKeyIterator(CollectionModel model)

      Gets an iteration of all the rowKeys in a collection. The collection must not be modified while this iterator is being used. The Iterator is not modifiable.

    - #### getRowCount

          public static int getRowCount(RowKeyIndex model)

      finds the last index in the given RowKeyIndex that has data and returns the next index. This is useful when the `RowKeyIndex.getRowCount()` of the RowKeyIndex is not known.
      Returns:
        a positive number if there is data. Returns zero if there is no data. Note that -1 is never returned.

    - #### findLastIndex

          public static int findLastIndex(RowKeyIndex table,
                          int startIndex,
                          int endIndex)

      finds the last index in the given RowKeyIndex that has data and returns the next index. This is useful when the `RowKeyIndex.getRowCount()` of the RowKeyIndex is not known.
      Parameters:
        `startIndex` - starts the search from this index. Use zero to start from the beginning.
        `endIndex` - the search will stop just before this index.
      Returns:
        a number >= startIndex. Note that -1 is never returned.

    - #### toTreeModel

          public static TreeModel toTreeModel(Object value)

      Converts an instance into a TreeModel

    - #### toMenuModel

          public static MenuModel toMenuModel(Object value)

      Converts an instance into a MenuModel

    - #### toCollectionModel

          public static CollectionModel toCollectionModel(Object value)

      Converts an instance into a CollectionModel.
      Parameters:
        `value` - This can be a DataModel, List, Array or other CollectionModel.

    - #### toDataModel

          public static javax.faces.model.DataModel toDataModel(Object value)

      Converts an instance into a DataModel.
      Parameters:
        `value` - Supported instances include java.util.List and arrays.

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