You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by ar...@apache.org on 2009/11/09 18:39:58 UTC
svn commit: r834156 - in /myfaces/trinidad/branches/1.2.12.2-branch: ./
trinidad-api/src/main/java-templates/org/apache/myfaces/trinidad/component/
trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/
trinidad-api/src/main/java/org/apache/...
Author: arobinson74
Date: Mon Nov 9 17:39:53 2009
New Revision: 834156
URL: http://svn.apache.org/viewvc?rev=834156&view=rev
Log:
TRINIDAD-1620
Commit patch from Kamran
Added:
myfaces/trinidad/branches/1.2.12.2-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/model/LocalRowKeyIndex.java
- copied unchanged from r834147, myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/model/LocalRowKeyIndex.java
Modified:
myfaces/trinidad/branches/1.2.12.2-branch/ (props changed)
myfaces/trinidad/branches/1.2.12.2-branch/trinidad-api/src/main/java-templates/org/apache/myfaces/trinidad/component/UIXIteratorTemplate.java
myfaces/trinidad/branches/1.2.12.2-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXCollection.java
myfaces/trinidad/branches/1.2.12.2-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXHierarchy.java
myfaces/trinidad/branches/1.2.12.2-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/model/CollectionModel.java
myfaces/trinidad/branches/1.2.12.2-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/model/CollectionModelDecorator.java
myfaces/trinidad/branches/1.2.12.2-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/model/RowKeyIndex.java
myfaces/trinidad/branches/1.2.12.2-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/model/TreeModel.java
myfaces/trinidad/branches/1.2.12.2-branch/trinidad-sandbox/sandbox-api/src/main/java-templates/org/apache/myfaces/trinidad/sandbox/component/ (props changed)
myfaces/trinidad/branches/1.2.12.2-branch/trinidad-sandbox/sandbox-api/src/main/java/org/apache/myfaces/trinidad/sandbox/event/ (props changed)
Propchange: myfaces/trinidad/branches/1.2.12.2-branch/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Nov 9 17:39:53 2009
@@ -3,4 +3,4 @@
/myfaces/trinidad/branches/1.2.9.1-branch:697924,699406,699496
/myfaces/trinidad/branches/TRINIDAD-1402:745675
/myfaces/trinidad/branches/jwaldman_StyleMap:754977-770778
-/myfaces/trinidad/trunk:819601,819622
+/myfaces/trinidad/trunk:819601,819622,834147
Modified: myfaces/trinidad/branches/1.2.12.2-branch/trinidad-api/src/main/java-templates/org/apache/myfaces/trinidad/component/UIXIteratorTemplate.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.12.2-branch/trinidad-api/src/main/java-templates/org/apache/myfaces/trinidad/component/UIXIteratorTemplate.java?rev=834156&r1=834155&r2=834156&view=diff
==============================================================================
--- myfaces/trinidad/branches/1.2.12.2-branch/trinidad-api/src/main/java-templates/org/apache/myfaces/trinidad/component/UIXIteratorTemplate.java (original)
+++ myfaces/trinidad/branches/1.2.12.2-branch/trinidad-api/src/main/java-templates/org/apache/myfaces/trinidad/component/UIXIteratorTemplate.java Mon Nov 9 17:39:53 2009
@@ -31,6 +31,7 @@
import javax.faces.render.Renderer;
import org.apache.myfaces.trinidad.model.CollectionModel;
+import org.apache.myfaces.trinidad.model.LocalRowKeyIndex;
import org.apache.myfaces.trinidad.model.ModelUtils;
/**
@@ -41,7 +42,7 @@
* If {@link #getRows()} returns 0, then the iteration continues until
* there are no more elements in the underlying data.
*/
-public abstract class UIXIteratorTemplate extends UIXCollection implements FlattenedComponent
+public abstract class UIXIteratorTemplate extends UIXCollection implements FlattenedComponent, LocalRowKeyIndex
{
/**/ abstract public int getFirst();
Modified: myfaces/trinidad/branches/1.2.12.2-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXCollection.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.12.2-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXCollection.java?rev=834156&r1=834155&r2=834156&view=diff
==============================================================================
--- myfaces/trinidad/branches/1.2.12.2-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXCollection.java (original)
+++ myfaces/trinidad/branches/1.2.12.2-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXCollection.java Mon Nov 9 17:39:53 2009
@@ -43,6 +43,7 @@
import org.apache.myfaces.trinidad.event.SelectionEvent;
import org.apache.myfaces.trinidad.logging.TrinidadLogger;
import org.apache.myfaces.trinidad.model.CollectionModel;
+import org.apache.myfaces.trinidad.model.LocalRowKeyIndex;
import org.apache.myfaces.trinidad.model.SortCriterion;
import org.apache.myfaces.trinidad.render.ClientRowKeyManager;
import org.apache.myfaces.trinidad.render.ClientRowKeyManagerFactory;
@@ -328,6 +329,62 @@
}
/**
+ * Check for an available row by row key.
+ * @param rowKey the row key for the row to check.
+ * @return true if a value exists; false otherwise.
+ */
+ public final boolean isRowAvailable(Object rowKey)
+ {
+ return getCollectionModel().isRowAvailable(rowKey);
+ }
+
+ /**
+ * Get row data by row key.
+ * @param rowKey the row key for the row to get data.
+ * @return row data
+ */
+ public final Object getRowData(Object rowKey)
+ {
+ return getCollectionModel().getRowData(rowKey);
+ }
+
+ /**
+ * Check if a range of rows is available starting from the current position
+ * @param rowCount number of rows to check
+ * @return true if all rows in range are available
+ */
+ public final boolean areRowsAvailable(int rowCount)
+ {
+ return getCollectionModel().areRowsAvailable(rowCount);
+ }
+
+ /**
+ * Check if a range of rows is available from a starting index without
+ * requiring the client to iterate over the rows
+ * @param startIndex the starting index for the range
+ * @param rowCount number of rows to check
+ * @return true if all rows in range are available
+ */
+ public final boolean areRowsAvailable(int startIndex, int rowCount)
+ {
+ return getCollectionModel().areRowsAvailable(startIndex, rowCount);
+ }
+
+ /**
+ * Check if a range of rows is available from a starting row key without
+ * requiring the client to iterate over the rows
+ * @param startRowKey the starting row key for the range
+ * @param rowCount number of rows to check
+ * @return true if all rows in range are available
+ */
+ public final boolean areRowsAvailable(Object startRowKey, int rowCount)
+ {
+ return getCollectionModel().areRowsAvailable(startRowKey, rowCount);
+ }
+
+
+
+ /**
* Gets the total number of rows in this table.
* @see CollectionModel#getRowCount
* @return -1 if the total number is not known.
@@ -1176,6 +1233,130 @@
}
};
}
+
+
+ //
+ // LocalRowKeyIndex implementation
+ //
+
+ /**
+ * Given a row index, check if a row is locally available
+ * @param rowIndex index of row to check
+ * @return true if row is locally available
+ */
+ public boolean isRowLocallyAvailable(int rowIndex)
+ {
+ return getCollectionModel().isRowLocallyAvailable(rowIndex);
+ }
+
+ /**
+ * Given a row key, check if a row is locally available
+ * @param rowKey row key for the row to check
+ * @return true if row is locally available
+ */
+ public boolean isRowLocallyAvailable(Object rowKey)
+ {
+ return getCollectionModel().isRowLocallyAvailable(rowKey);
+ }
+
+ /**
+ * Check if a range of rows is locally available starting from a row index
+ * @param startIndex staring index for the range
+ * @param rowCount number of rows in the range
+ * @return true if range of rows is locally available
+ */
+ public boolean areRowsLocallyAvailable(int startIndex, int rowCount)
+ {
+ return getCollectionModel().areRowsLocallyAvailable(startIndex, rowCount);
+ }
+
+ /**
+ * Check if a range of rows is locally available starting from a row key
+ * @param startRowKey staring row key for the range
+ * @param rowCount number of rows in the range
+ * @return true if range of rows is locally available
+ */
+ public boolean areRowsLocallyAvailable(Object startRowKey, int rowCount)
+ {
+ return getCollectionModel().areRowsLocallyAvailable(startRowKey, rowCount);
+ }
+
+ /**
+ * Convenient API to return a row count estimate. This method can be optimized
+ * to avoid a data fetch which may be required to return an exact row count
+ * @return estimated row count
+ */
+ public int getEstimatedRowCount()
+ {
+ return getCollectionModel().getEstimatedRowCount();
+ }
+
+
+ /**
+ * Helper API to determine if the row count returned from {@link #getEstimatedRowCount}
+ * is EXACT, or an ESTIMATE
+ */
+ public LocalRowKeyIndex.Confidence getEstimatedRowCountConfidence()
+ {
+ return getCollectionModel().getEstimatedRowCountConfidence();
+ }
+
+ /**
+ * clear all rows from the local cache
+ */
+ public void clearLocalCache()
+ {
+ getCollectionModel().clearLocalCache();
+ }
+
+ /**
+ * Clear the requested range of rows from the local cache
+ * @param startingIndex starting row index for the range to clear
+ * @param rowsToClear number of rows to clear from the cache
+ */
+ public void clearCachedRows(int startingIndex, int rowsToClear)
+ {
+ getCollectionModel().clearCachedRows(startingIndex, rowsToClear);
+ }
+
+ /**
+ * Clear the requested range of rows from the local cache
+ * @param startingRowKey starting row key for the range to clear
+ * @param rowsToClear number of rows to clear from the cache
+ */
+ public void clearCachedRows(Object startingRowKey, int rowsToClear)
+ {
+ getCollectionModel().clearCachedRows(startingRowKey, rowsToClear);
+ }
+
+ /**
+ * Clear a row from the local cache by row index
+ * @param index row index for the row to clear from the cache
+ */
+ public void clearCachedRow(int index)
+ {
+ getCollectionModel().clearCachedRow(index);
+ }
+
+ /**
+ * Clear a row from the local cache by row key
+ * @param rowKey row key for the row to clear from the cache
+ */
+ public void clearCachedRow(Object rowKey)
+ {
+ getCollectionModel().clearCachedRow(rowKey);
+ }
+
+ /**
+ * Indicates the caching strategy supported by the model
+ * @see LocalCachingStrategy
+ * @return caching strategy supported by the model
+ */
+ public LocalRowKeyIndex.LocalCachingStrategy getCachingStrategy()
+ {
+ return getCollectionModel().getCachingStrategy();
+ }
+
/**
* override this method to place initialization code that must run
Modified: myfaces/trinidad/branches/1.2.12.2-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXHierarchy.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.12.2-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXHierarchy.java?rev=834156&r1=834155&r2=834156&view=diff
==============================================================================
--- myfaces/trinidad/branches/1.2.12.2-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXHierarchy.java (original)
+++ myfaces/trinidad/branches/1.2.12.2-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXHierarchy.java Mon Nov 9 17:39:53 2009
@@ -25,6 +25,7 @@
import javax.faces.component.UIComponent;
import org.apache.myfaces.trinidad.model.CollectionModel;
+import org.apache.myfaces.trinidad.model.LocalRowKeyIndex;
import org.apache.myfaces.trinidad.model.ModelUtils;
import org.apache.myfaces.trinidad.model.TreeModel;
@@ -34,7 +35,7 @@
*
* @version $Name: $ ($Revision: adfrt/faces/adf-faces-api/src/main/java/oracle/adf/view/faces/component/UIXHierarchy.java#0 $) $Date: 10-nov-2005.19:09:52 $
*/
-abstract public class UIXHierarchy extends UIXCollection implements CollectionComponent
+abstract public class UIXHierarchy extends UIXCollection implements CollectionComponent, LocalRowKeyIndex
{
/**
* Create a Page component with the given render-type
Modified: myfaces/trinidad/branches/1.2.12.2-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/model/CollectionModel.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.12.2-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/model/CollectionModel.java?rev=834156&r1=834155&r2=834156&view=diff
==============================================================================
--- myfaces/trinidad/branches/1.2.12.2-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/model/CollectionModel.java (original)
+++ myfaces/trinidad/branches/1.2.12.2-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/model/CollectionModel.java Mon Nov 9 17:39:53 2009
@@ -46,7 +46,7 @@
* <p>
*/
public abstract class CollectionModel extends DataModel
- implements RowKeyIndex
+ implements RowKeyIndex, LocalRowKeyIndex
{
/**
@@ -75,6 +75,7 @@
* {@link #isRowAvailable()}.
* Finally, the row that was current before this method was called
* is made current again.
+ * @see CollectionModel#isRowAvailable()
* @param rowIndex the index of the row to check.
* @return true if data for the row exists.
*/
@@ -93,13 +94,42 @@
}
/**
+ * Check for an available row by row key.
+ * This method makes the given row current and calls
+ * {@link #isRowAvailable()}.
+ * Finally, the row that was current before this method was called
+ * is made current again.
+ * @see CollectionModel#isRowAvailable()
+ * @param rowKey the row key for the row to check.
+ * @return true if data for the row exists otherwise return false if the
+ * row data does not exist or the rowKey is null
+ */
+ public boolean isRowAvailable(Object rowKey)
+ {
+ Object oldKey = getRowKey();
+ try
+ {
+ setRowKey(rowKey);
+ return isRowAvailable();
+ }
+ finally
+ {
+ setRowKey(oldKey);
+ }
+ }
+
+ /**
* Gets the rowData at the given index.
* This method makes the given row current and calls
* {@link #getRowData()}.
* Finally, the row that was current before this method was called
* is made current again.
+ * @see CollectionModel#getRowData()
* @param rowIndex the index of the row to get data from.
- * @return the data for the given row.
+ * @return the data for the given row. The {@link #getRowData()} call
+ * may throw <code>IllegalArgumentException</code> if the rowIndex is
+ * less than zero or grater than row count or row data at the given index
+ * is not available
*/
public Object getRowData(int rowIndex)
{
@@ -116,6 +146,32 @@
}
/**
+ * Gets the rowData at the given row key.
+ * This method makes the given row current and calls
+ * {@link #getRowData()}.
+ * Finally, the row that was current before this method was called
+ * is made current again.
+ * @see CollectionModel#getRowData()
+ * @param rowKey the row key of the row to get data from.
+ * @return the data for the given row. The {@link #getRowData()} implementation
+ * may throw <code>IllegalArgumentException</code> if the rowKey is
+ * null or data for the given rowKey is unavailable
+ */
+ public Object getRowData(Object rowKey)
+ {
+ Object oldKey = getRowKey();
+ try
+ {
+ setRowKey(rowKey);
+ return getRowData();
+ }
+ finally
+ {
+ setRowKey(oldKey);
+ }
+ }
+
+ /**
* Return true if this collection is sortable by the given property.
* This implementation always returns false;
*/
@@ -148,4 +204,249 @@
{
}
+ /**
+ * Check if a range of rows is available from a starting index.
+ * The current row does not change after this call
+ * @param startIndex the starting index for the range
+ * @param rowsToCheck 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)
+ * @return true if rows are available otherwise return <code>false</code>
+ * if startIndex < 0 or > rowCount or rows in range are not available
+ */
+ public boolean areRowsAvailable(int startIndex, int rowsToCheck)
+ {
+ int oldIndex = getRowIndex();
+ try
+ {
+ if (rowsToCheck < 0)
+ {
+ rowsToCheck = Math.abs(rowsToCheck);
+ startIndex = startIndex - rowsToCheck + 1;
+ }
+ setRowIndex(startIndex);
+ return areRowsAvailable(rowsToCheck);
+ }
+ finally
+ {
+ setRowIndex(oldIndex);
+ }
+ }
+
+ /**
+ * Check if a range of rows is available from a starting row key
+ * This method make the row with the given row key current and calls
+ * {@link #areRowsAvailable(rowsToCheck)}.
+ * The current row does not change after this call
+ * @see CollectionModel#areRowsAvailable(int).
+ * @param startRowKey the starting row key for the range
+ * @param rowsToCheck number of rows to check
+ * @return true if rows are available otherwise return
+ * false if rowKey is null or rows in range are not available
+ */
+ public boolean areRowsAvailable(Object startRowKey, int rowsToCheck)
+ {
+ Object oldKey = getRowKey();
+ try
+ {
+ setRowKey(startRowKey);
+ return areRowsAvailable(rowsToCheck);
+ }
+ finally
+ {
+ setRowKey(oldKey);
+ }
+ }
+
+ /**
+ * 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. The current row does not change after this call
+ * @param rowsToCheck number of rows to check
+ * @return true if start and end rows in range are available otherwise return
+ * false if start and end rows are not available or rowsToCheck <= 0 or the current
+ * rowIndex < 0
+ */
+ public boolean areRowsAvailable(int rowsToCheck)
+ {
+ int startIndex = getRowIndex();
+
+ if (startIndex < 0 || rowsToCheck <= 0)
+ return false;
+
+
+ long count = getRowCount();
+ if (count != -1)
+ {
+ if (startIndex >= count)
+ return false;
+
+ if (startIndex + rowsToCheck > count)
+ rowsToCheck = (int)count - startIndex;
+ }
+ int last = startIndex + rowsToCheck - 1;
+
+ try
+ {
+ // check start index
+ if (!isRowAvailable())
+ return false;
+
+ // check end index
+ setRowIndex(last);
+ return isRowAvailable();
+ }
+ finally
+ {
+ setRowIndex(startIndex);
+ }
+ }
+
+ //
+ // Below is the default implemenation for the LocalRowKeyIndex interface.
+ // This implemenation delegates to the corresponding non-local APIs
+ //
+
+ /**
+ * Check if a range of rows is locally available starting from a row index.
+ * This implementation delegates to the corresponding non-local API
+ * @see CollectionModel#areRowsAvailable(int, int)
+ * @param startIndex
+ * @param rowsToCheck
+ * @return
+ */
+ public boolean areRowsLocallyAvailable(int startIndex, int rowsToCheck)
+ {
+ return areRowsAvailable(startIndex, rowsToCheck);
+ }
+
+ /**
+ * Check if a range of rows is locally available starting from a row key.
+ * This implementation delegates to the corresponsding non-local API
+ * @see CollectionModel#areRowsAvailable(Object, int)
+ * @param startRowKey
+ * @param rowsToCheck
+ * @return
+ */
+ public boolean areRowsLocallyAvailable(Object startRowKey, int rowsToCheck)
+ {
+ return areRowsAvailable(startRowKey, rowsToCheck);
+ }
+
+
+ /**
+ * Given a row index, check if the row is locally available. This
+ * implementation delegates to the non-local API
+ * @see CollectionModel#isRowAvailable(int)
+ * @param rowIndex
+ * @return true if row is available; false otherwise.
+ */
+ public boolean isRowLocallyAvailable(int rowIndex)
+ {
+ return isRowAvailable(rowIndex);
+ }
+
+ /**
+ * Given a row key, check if the row is locally available. This
+ * implementation delegates to the non-local API
+ * @see CollectionModel#isRowAvailable(Object)
+ * @param rowKey
+ * @return true if row is available; false otherwise.
+ */
+ public boolean isRowLocallyAvailable(Object rowKey)
+ {
+ return isRowAvailable(rowKey);
+ }
+
+ /**
+ * Convenient API to return a row count estimate. This implementation
+ * always returns exact row count
+ * @see CollectionModel#getRowCount
+ * @return estimated row count
+ */
+ public int getEstimatedRowCount()
+ {
+ return getRowCount();
+ }
+
+ /**
+ * Helper API to determine if the row count returned from {@link #getEstimatedRowCount}
+ * is EXACT, or an ESTIMATE. This implemetation always returns exact row count
+ * @see CollectionModel#getRowCount
+ */
+ public LocalRowKeyIndex.Confidence getEstimatedRowCountConfidence()
+ {
+ return LocalRowKeyIndex.Confidence.EXACT;
+ }
+
+ /**
+ * Clears the row with the given index from local cache.
+ * This is a do nothing implementaion which delegates to the
+ * correcsponding range based api
+ * @see #clearCachedRows(int, int)
+ * @param index row index for the row to remove from cache
+ */
+ public void clearCachedRow(int index)
+ {
+ clearCachedRows(index, 1);
+ }
+
+ /**
+ * Clears the row with the given row key from local cache.
+ * This is a do nothing implementaion which delegates to the
+ * correcsponding range based api
+ * @see #clearCachedRows(Object, int)
+ * @param rowKey row key for the row to remove from cache
+ */
+ public void clearCachedRow(Object rowKey)
+ {
+ clearCachedRows(rowKey, 1);
+ }
+
+ /**
+ * Clears a range of rows from local cache starting from a row index.
+ * This is a do nothing implemenation.
+ * @see #clearLocalCache
+ * @param startingIndex starting row index to clear the local cache from
+ * @param rowsToClear number of rows to clear
+ */
+ public void clearCachedRows(int startingIndex, int rowsToClear)
+ {
+ clearLocalCache();
+ }
+
+ /**
+ * Clears a range of rows from local cache starting from a row key
+ * This is a do nothing implemenation.
+ * @see #clearLocalCache
+ * @param startingRowKey starting row key to clear the local cache from
+ * @param rowsToClear number of rows to clear
+ */
+ public void clearCachedRows(Object startingRowKey, int rowsToClear)
+ {
+ clearLocalCache();
+ }
+
+ /**
+ * Clears the local cache.
+ * This is a do nothing implementation
+ */
+ public void clearLocalCache()
+ {
+ // do nothing
+ }
+
+ /**
+ * Returns the row caching strategy used by this implemenation. Default
+ * implementation indicates no caching supported
+ * @see LocalRowKeyIndex.LocalCachingStrategy
+ * @return caching strategy none
+ */
+ public LocalRowKeyIndex.LocalCachingStrategy getCachingStrategy()
+ {
+ return LocalRowKeyIndex.LocalCachingStrategy.NONE;
+ }
+
}
Modified: myfaces/trinidad/branches/1.2.12.2-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/model/CollectionModelDecorator.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.12.2-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/model/CollectionModelDecorator.java?rev=834156&r1=834155&r2=834156&view=diff
==============================================================================
--- myfaces/trinidad/branches/1.2.12.2-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/model/CollectionModelDecorator.java (original)
+++ myfaces/trinidad/branches/1.2.12.2-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/model/CollectionModelDecorator.java Mon Nov 9 17:39:53 2009
@@ -49,11 +49,21 @@
return getCollectionModel().isRowAvailable(rowIndex);
}
+ public boolean isRowAvailable(Object rowKey)
+ {
+ return getCollectionModel().isRowAvailable(rowKey);
+ }
+
public Object getRowData(int rowIndex)
{
return getCollectionModel().getRowData(rowIndex);
}
+ public Object getRowData(Object rowKey)
+ {
+ return getCollectionModel().getRowData(rowKey);
+ }
+
public boolean isSortable(String property)
{
return getCollectionModel().isSortable(property);
@@ -69,6 +79,111 @@
getCollectionModel().setSortCriteria(criteria);
}
+ public boolean areRowsAvailable(int startIndex, int rowCount)
+ {
+ return getCollectionModel().areRowsAvailable(startIndex, rowCount);
+ }
+
+ public boolean areRowsAvailable(Object startRowKey, int rowCount)
+ {
+ return getCollectionModel().areRowsAvailable(startRowKey, rowCount);
+ }
+
+ public boolean areRowsAvailable(int rowCount)
+ {
+ return getCollectionModel().areRowsAvailable(rowCount);
+ }
+
+ //
+ // below are the LocalRowKeyIndex APIs
+ //
+
+ public boolean areRowsLocallyAvailable(int startIndex, int rowCount)
+ {
+ return getCollectionModel().areRowsLocallyAvailable(startIndex, rowCount);
+ }
+
+ public boolean areRowsLocallyAvailable(Object startRowKey, int rowCount)
+ {
+ return getCollectionModel().areRowsLocallyAvailable(startRowKey, rowCount);
+ }
+
+ public boolean isRowLocallyAvailable(int rowIndex)
+ {
+ return getCollectionModel().isRowLocallyAvailable(rowIndex);
+ }
+
+ public boolean isRowLocallyAvailable(Object rowKey)
+ {
+ return getCollectionModel().isRowLocallyAvailable(rowKey);
+ }
+
+ public int getEstimatedRowCount()
+ {
+ return getCollectionModel().getEstimatedRowCount();
+ }
+
+ public LocalRowKeyIndex.Confidence getEstimatedRowCountConfidence()
+ {
+ return getCollectionModel().getEstimatedRowCountConfidence();
+ }
+
+ /**
+ * clear all rows from the local cache
+ */
+ public void clearLocalCache()
+ {
+ getCollectionModel().clearLocalCache();
+ }
+
+ /**
+ * Clear the requested range of rows from the local cache
+ * @param startingIndex starting row index for the range to clear
+ * @param rowsToClear number of rows to clear from the cache
+ */
+ public void clearCachedRows(int startingIndex, int rowsToClear)
+ {
+ getCollectionModel().clearCachedRows(startingIndex, rowsToClear);
+ }
+
+ /**
+ * Clear the requested range of rows from the local cache
+ * @param startingRowKey starting row key for the range to clear
+ * @param rowsToClear number of rows to clear from the cache
+ */
+ public void clearCachedRows(Object startingRowKey, int rowsToClear)
+ {
+ getCollectionModel().clearCachedRows(startingRowKey, rowsToClear);
+ }
+
+ /**
+ * Clear a row from the local cache by row index
+ * @param index row index for the row to clear from the cache
+ */
+ public void clearCachedRow(int index)
+ {
+ getCollectionModel().clearCachedRow(index);
+ }
+
+ /**
+ * Clear a row from the local cache by row key
+ * @param rowKey row key for the row to clear from the cache
+ */
+ public void clearCachedRow(Object rowKey)
+ {
+ getCollectionModel().clearCachedRow(rowKey);
+ }
+
+ /**
+ * Indicates the caching strategy supported by the model
+ * @see LocalCachingStrategy
+ * @return caching strategy supported by the model
+ */
+ public LocalRowKeyIndex.LocalCachingStrategy getCachingStrategy()
+ {
+ return getCollectionModel().getCachingStrategy();
+ }
+
//
// below are the DataModel public APIs
//
Modified: myfaces/trinidad/branches/1.2.12.2-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/model/RowKeyIndex.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.12.2-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/model/RowKeyIndex.java?rev=834156&r1=834155&r2=834156&view=diff
==============================================================================
--- myfaces/trinidad/branches/1.2.12.2-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/model/RowKeyIndex.java (original)
+++ myfaces/trinidad/branches/1.2.12.2-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/model/RowKeyIndex.java Mon Nov 9 17:39:53 2009
@@ -95,4 +95,46 @@
*/
public Object getRowData(int rowIndex);
+
+ /**
+ * Check for an available row by row key.
+ * @param rowKey the row key for the row to check.
+ * @return true if a value exists; false otherwise.
+ */
+ public boolean isRowAvailable(Object rowKey);
+
+
+ /**
+ * Get row data by row key.
+ * @param rowKey the row key for the row to get data.
+ * @return row data
+ */
+ public Object getRowData(Object rowKey);
+
+
+ /**
+ * Check if a range of rows is available starting from the current position
+ * @param rowsToCheck number of rows to check
+ * @return true if all rows in range are available
+ */
+ public boolean areRowsAvailable(int rowsToCheck);
+
+ /**
+ * Check if a range of rows is available from a starting index without
+ * requiring the client to iterate over the rows
+ * @param startIndex the starting index for the range
+ * @param rowsToCheck number of rows to check
+ * @return true if all rows in range are available
+ */
+ public boolean areRowsAvailable(int startIndex, int rowsToCheck) ;
+
+
+ /**
+ * Check if a range of rows is available from a starting row key without
+ * requiring the client to iterate over the rows
+ * @param startRowKey the starting row key for the range
+ * @param rowsToCheck number of rows to check
+ * @return true if all rows in range are available
+ */
+ public boolean areRowsAvailable(Object startRowKey, int rowsToCheck) ;
}
Modified: myfaces/trinidad/branches/1.2.12.2-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/model/TreeModel.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.12.2-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/model/TreeModel.java?rev=834156&r1=834155&r2=834156&view=diff
==============================================================================
--- myfaces/trinidad/branches/1.2.12.2-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/model/TreeModel.java (original)
+++ myfaces/trinidad/branches/1.2.12.2-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/model/TreeModel.java Mon Nov 9 17:39:53 2009
@@ -293,4 +293,80 @@
}
return depth;
}
+
+ /**
+ * Indicates whether data for a child model (children of the current node) is
+ * locally available. Locally available means no data fetch is required
+ * as a result of a call to {@link #enterContainer}. The default
+ * implementation returns true if the current node is a container.
+ * Override to optimize for the case where child data is not locally available
+ * @return true if child data is locally available
+ */
+ public boolean isChildCollectionLocallyAvailable()
+ {
+ return isContainer();
+ }
+
+ /**
+ * Indicates whether child data for the node with the given index is
+ * locally available. This method first checks to see if the parent node
+ * at the given index is locally available by calling {@link #isRowLocallyAvailable(int}.
+ * If the parent node is locally available, this method moves the model to the
+ * parent node and calls {@link #isChildCollectionLocallyAvailable()}
+ * The current row does not change after this call
+ * @param index
+ * @return true if child data is available, false otherwise
+ */
+ public boolean isChildCollectionLocallyAvailable(int index)
+ {
+ if (isRowLocallyAvailable(index))
+ {
+ int oldIndex = getRowIndex();
+ try
+ {
+ setRowIndex(index);
+ return isChildCollectionLocallyAvailable();
+ }
+ finally
+ {
+ setRowIndex(oldIndex);
+ }
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ /**
+ * Indicates whether child data for the node with the given row key is
+ * locally available. This method first checks to see if the parent node
+ * with the given row key is locally available by calling {@link #isRowLocallyAvailable(Object)}.
+ * If the parent node is locally available, this method moves the model to the
+ * parent node and calls {@link #isChildCollectionLocallyAvailable()}
+ * The current row does not change after this call
+ * @param rowKey
+ * @return true if child data is available, false otherwise
+ */
+ public boolean isChildCollectionLocallyAvailable(Object rowKey)
+ {
+ if (isRowLocallyAvailable(rowKey))
+ {
+ Object oldKey = getRowKey();
+ try
+ {
+ setRowKey(rowKey);
+ return isChildCollectionLocallyAvailable();
+ }
+ finally
+ {
+ setRowKey(oldKey);
+ }
+ }
+ else
+ {
+ return false;
+ }
+ }
+
}
Propchange: myfaces/trinidad/branches/1.2.12.2-branch/trinidad-sandbox/sandbox-api/src/main/java-templates/org/apache/myfaces/trinidad/sandbox/component/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Nov 9 17:39:53 2009
@@ -2,4 +2,4 @@
/myfaces/trinidad/branches/1.2.11.4-branch/trinidad-sandbox/sandbox-api/src/main/java-templates/org/apache/myfaces/trinidad/sandbox/component:794062,794792,798299
/myfaces/trinidad/branches/1.2.9.1-branch/trinidad-sandbox/sandbox-api/src/main/java-templates/org/apache/myfaces/trinidad/sandbox/component:699406,699496
/myfaces/trinidad/branches/TRINIDAD-1402/trinidad-sandbox/sandbox-api/src/main/java-templates/org/apache/myfaces/trinidad/sandbox/component:745675
-/myfaces/trinidad/trunk/trinidad-sandbox/sandbox-api/src/main/java-templates/org/apache/myfaces/trinidad/sandbox/component:819601,819622
+/myfaces/trinidad/trunk/trinidad-sandbox/sandbox-api/src/main/java-templates/org/apache/myfaces/trinidad/sandbox/component:819601,819622,834147
Propchange: myfaces/trinidad/branches/1.2.12.2-branch/trinidad-sandbox/sandbox-api/src/main/java/org/apache/myfaces/trinidad/sandbox/event/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Nov 9 17:39:53 2009
@@ -2,4 +2,4 @@
/myfaces/trinidad/branches/1.2.11.4-branch/trinidad-sandbox/sandbox-api/src/main/java/org/apache/myfaces/trinidad/sandbox/event:794062,794792,798299
/myfaces/trinidad/branches/1.2.9.1-branch/trinidad-sandbox/sandbox-api/src/main/java/org/apache/myfaces/trinidad/sandbox/event:699406,699496
/myfaces/trinidad/branches/TRINIDAD-1402/trinidad-sandbox/sandbox-api/src/main/java/org/apache/myfaces/trinidad/sandbox/event:745675
-/myfaces/trinidad/trunk/trinidad-sandbox/sandbox-api/src/main/java/org/apache/myfaces/trinidad/sandbox/event:819601,819622
+/myfaces/trinidad/trunk/trinidad-sandbox/sandbox-api/src/main/java/org/apache/myfaces/trinidad/sandbox/event:819601,819622,834147