View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.myfaces.trinidad.model;
20  
21  /**
22   * Defines a set of "local" APIs for a TreeModel.
23   * The "local" APIs allow a client to query the tree model and determine if a 
24   * set of rows are locally available. "Locally available" can mean the 
25   * model has the given set of rows in a local cache and can honor a fetch request
26   * efficiently (for example, without performing a SQL query).
27   */
28  public interface TreeLocalRowKeyIndex
29  {
30    /**
31     * Indicates whether data for a child model (children of the current node) is 
32     * locally available. Locally available means no data fetch is required 
33     * as a result of a call to  <code>enterContainer</code>. 
34     * @return true if child data is locally available
35     */
36    public boolean isChildCollectionLocallyAvailable();
37  
38    /**
39     * Indicates whether child data for the node with the given index is
40     * locally available.   
41     * @param index row index to check
42     * @return true if child data is available, false otherwise
43     */
44    public boolean isChildCollectionLocallyAvailable(int index);
45  
46    /**
47     * Indicates whether child data for the node with the given row key is
48     * locally available.   
49     * @param rowKey row key to check
50     * @return true if child data is available, false otherwise
51     */
52    public boolean isChildCollectionLocallyAvailable(Object rowKey);
53  
54    /**
55     * Check if a range of rows is locally available starting from a row index.  The range
56     * can include child nodes in any expanded nodes within the range.
57     * @param startIndex staring index for the range  
58     * @param rowCount number of rows in the range
59     * @param disclosedRowKeys set of expanded nodes which may fall within the range to check for
60     * availability
61     * @return <code>true</code> if range of rows is locally available <code>flase</code> otherwise
62     */
63    public boolean areRowsLocallyAvailable(int startIndex, int rowCount, RowKeySet disclosedRowKeys);
64  
65    /**
66     * Check if a range of rows is locally available starting from a row key.   The range
67     * can include child nodes in any expanded nodes within the range.
68     * @param startRowKey staring row key for the range  
69     * @param rowCount number of rows in the range
70     * @param disclosedRowKeys set of expanded nodes which may fall within the range to check for
71     * availability
72     * @return <code>true</code> if range of rows is locally available <code>flase</code> otherwise
73     */
74    public boolean areRowsLocallyAvailable(Object startRowKey, int rowCount, RowKeySet disclosedRowKeys);
75    
76    /**
77     * Check if a range of rows is locally available starting from current position.   The range
78     * can include child nodes  in any expanded nodes within the range.
79     * @param rowCount number of rows in the range
80     * @param disclosedRowKeys set of expanded nodes which may fall within the range to check for
81     * availability
82     * @return <code>true</code> if range of rows is locally available <code>flase</code> otherwise
83     */
84    public boolean areRowsLocallyAvailable(int rowCount, RowKeySet disclosedRowKeys);
85  
86  }