org.apache.myfaces.trinidad.model
Class CollectionModelDecorator

java.lang.Object
  extended by javax.faces.model.DataModel
      extended by org.apache.myfaces.trinidad.model.CollectionModel
          extended by org.apache.myfaces.trinidad.model.CollectionModelDecorator
All Implemented Interfaces:
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()

Constructor Summary
CollectionModelDecorator()
           
 
Method Summary
 void addDataModelListener(javax.faces.model.DataModelListener listener)
           
protected abstract  CollectionModel getCollectionModel()
          This method returns the wrapped CollectionModel.
 javax.faces.model.DataModelListener[] getDataModelListeners()
           
 int getRowCount()
          Gets the number of values in this collection
 java.lang.Object getRowData()
          Gets the current value identified by the current index or rowKey.
 java.lang.Object getRowData(int rowIndex)
          Gets the rowData at the given index.
 int getRowIndex()
          Gets the index of the current value.
 java.lang.Object getRowKey()
          Gets the rowKey of the current row.
 java.util.List<SortCriterion> getSortCriteria()
          Gets the criteria that this collection is sorted by.
 java.lang.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 isSortable(java.lang.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(java.lang.Object key)
          Finds the row with the matching key and makes it current
 void setSortCriteria(java.util.List<SortCriterion> criteria)
          Sorts this collection by the given criteria.
 void setWrappedData(java.lang.Object object)
           
 
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 java.lang.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(java.lang.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.

getRowData

public java.lang.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.

isSortable

public boolean isSortable(java.lang.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 java.util.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(java.util.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

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 java.lang.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 java.lang.Object getWrappedData()
Specified by:
getWrappedData in class javax.faces.model.DataModel

setWrappedData

public void setWrappedData(java.lang.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-2009 The Apache Software Foundation. All Rights Reserved.