org.apache.myfaces.trinidad.model
Class TreeModelDecorator

java.lang.Object
  extended by javax.faces.model.DataModel
      extended by org.apache.myfaces.trinidad.model.CollectionModel
          extended by org.apache.myfaces.trinidad.model.TreeModel
              extended by org.apache.myfaces.trinidad.model.TreeModelDecorator
All Implemented Interfaces:
Iterable, LocalRowKeyIndex, RowKeyIndex, TreeLocalRowKeyIndex

public abstract class TreeModelDecorator
extends TreeModel


Nested Class Summary
 
Nested classes/interfaces inherited from interface org.apache.myfaces.trinidad.model.LocalRowKeyIndex
LocalRowKeyIndex.Confidence, LocalRowKeyIndex.LocalCachingStrategy
 
Constructor Summary
TreeModelDecorator()
           
 
Method Summary
 void enterContainer()
          This Collection changes to reflect the children of the current rowData, and the current rowData changes to be null.
 void exitContainer()
          Pops back up to the parent collection.
 Object getContainerRowKey(Object childRowKey)
          Gets the rowKey of a given child row's container row.
 int getRowCount()
          Gets the number of values in this collection
 Object getRowData()
          Gets the current value identified by the current index or rowKey.
 int getRowIndex()
          Gets the index of the current value.
 Object getRowKey()
          Gets the rowKey of the current row.
protected abstract  TreeModel getTreeModel()
          This method returns the wrapped TreeModel.
 Object getWrappedData()
           
 boolean isContainer()
          Tests to see if the row identified by getRowData() is a container element.
 boolean isRowAvailable()
          Checks to make sure a value exists for the current index or rowKey.
 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 setWrappedData(Object object)
           
 
Methods inherited from class org.apache.myfaces.trinidad.model.TreeModel
areRowsLocallyAvailable, areRowsLocallyAvailable, areRowsLocallyAvailable, getAllAncestorContainerRowKeys, getContainerRowKey, getDepth, getDepth, isChildCollectionLocallyAvailable, isChildCollectionLocallyAvailable, isChildCollectionLocallyAvailable, isContainerEmpty
 
Methods inherited from class org.apache.myfaces.trinidad.model.CollectionModel
addRowKeyChangeListener, areRowsAvailable, areRowsAvailable, areRowsAvailable, areRowsLocallyAvailable, areRowsLocallyAvailable, areRowsLocallyAvailable, clearCachedRow, clearCachedRow, clearCachedRows, clearCachedRows, clearLocalCache, fireRowKeyChange, getCachingStrategy, getEstimatedRowCount, getEstimatedRowCountConfidence, getRowData, getRowData, getSortCriteria, isRowAvailable, isRowAvailable, isRowLocallyAvailable, isRowLocallyAvailable, isSortable, removeRowKeyChangeListener, setSortCriteria
 
Methods inherited from class javax.faces.model.DataModel
addDataModelListener, getDataModelListeners, iterator, removeDataModelListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TreeModelDecorator

public TreeModelDecorator()
Method Detail

enterContainer

public void enterContainer()
Description copied from class: TreeModel
This Collection changes to reflect the children of the current rowData, and the current rowData changes to be null. The current rowIndex becomes -1. This method should only be called if TreeModel.isContainer() returns true. DataModel.getRowCount() can be used to get the number of children.

Specified by:
enterContainer in class TreeModel

exitContainer

public void exitContainer()
Description copied from class: TreeModel
Pops back up to the parent collection. The current rowData becomes the rowData of the parent. This Collection will change to include the children of the new rowData.

Specified by:
exitContainer in class TreeModel

getContainerRowKey

public Object getContainerRowKey(Object childRowKey)
Description copied from class: TreeModel
Gets the rowKey of a given child row's container row.
 |-Root1 (rowKey="r1", containerRowKey=null)
 |  |-Folder1 (rowKey="r1f1", containerRowKey="r1")
 |  |  |-Node1 (rowKey="r1f1n1", containerRowKey="r1f1")
 |  |  |-Node2 (rowKey="r1f1n2", containerRowKey="r1f1")
 

Specified by:
getContainerRowKey in class TreeModel
Parameters:
childRowKey - the rowKey of the child row.
Returns:
the rowKey of the container, or null if the child is a root row.

isContainer

public boolean isContainer()
Description copied from class: TreeModel
Tests to see if the row identified by getRowData() is a container element. Use TreeModel.isContainerEmpty() to see if the current container element actually has children, or is an empty container.

Specified by:
isContainer in class TreeModel
Returns:
true if the current element may contain children.

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().

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

getWrappedData

public Object getWrappedData()
Specified by:
getWrappedData in class javax.faces.model.DataModel

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()

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

setWrappedData

public void setWrappedData(Object object)
Specified by:
setWrappedData in class javax.faces.model.DataModel

getTreeModel

protected abstract TreeModel getTreeModel()
This method returns the wrapped TreeModel.

Returns:
the wrapped TreeModel


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