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   * Identifies a collection that is indexed by rowKeys.
23   * Data is accessed by setting a rowKey, and then accessing
24   * {@link #getRowData}.
25   */
26  public interface RowKeyIndex
27  {
28    /**
29     * Gets the number of values in this collection
30     * @return -1 if the number of values is not known.
31     */
32    public int getRowCount();
33    
34    /**
35     * Gets the index of the current value.
36     * The current value is returned by calling {link #getRowData}
37     * @return the zero-based index of the current value, or -1 if there
38     * is no current value
39     */
40    public int getRowIndex();
41    
42    /**
43     * Sets up a value at a particular index to be the current value.
44     * The current value is returned by calling {link #getRowData}
45     * @param rowIndex the zero-based index of the value to make current.
46     * Use -1 to clear the current value
47     */
48    public void setRowIndex(int rowIndex);
49  
50    /**
51     * Gets the rowKey of the current value.
52     * The current value is returned by calling {link #getRowData}
53     * @return the rowKey of the current value, or null if there
54     * is no current value
55     */
56    public Object getRowKey();
57    
58    /**
59     * Sets up a value at a particular rowKey to be the current value.
60     * The current value is returned by calling {link #getRowData}
61     * @param rowKey the rowKey of the value to make current.
62     * Use null to clear the current value
63     */
64    public void setRowKey(Object rowKey);
65    
66    /**
67     * Checks to make sure a value exists for the current index or rowKey.
68     * This is useful if the number of values in this collection is not known
69     * (See {@link #getRowCount}).
70     * @see #getRowKey
71     * @see #getRowIndex
72     * @return true if a value exists; false otherwise.
73     */
74    public boolean isRowAvailable();
75    
76    /**
77     * Gets the current value identified by the current index or rowKey.
78     * @see #getRowKey
79     * @see #getRowIndex
80     * @return null if the current value has been cleared.
81     */
82    public Object getRowData();
83  
84    /**
85     * Checks to make sure a value exists for the given index.
86     * @param rowIndex the index of the row to check.
87     * @return true if a value exists; false otherwise.
88     */
89    public boolean isRowAvailable(int rowIndex);
90  
91    /**
92     * Gets the row value at the given index.
93     * @param rowIndex the index of the row to get data from.
94     * @return null if the current value has been cleared.
95     */
96    public Object getRowData(int rowIndex);
97  
98  
99    /**
100    * Check for an available row by row key. 
101    * @param rowKey the row key for the row to check.
102    * @return true if a value exists; false otherwise.
103    */
104   public boolean isRowAvailable(Object rowKey);
105 
106 
107   /**
108    * Get row data by row key. 
109    * @param rowKey the row key for the row to get data.
110    * @return row data
111    */
112   public Object getRowData(Object rowKey); 
113 
114 
115   /**
116    * Check if a range of rows is available starting from the current position 
117    * @param rowsToCheck number of rows to check
118    * @return true if all rows in range are available
119    */
120   public boolean areRowsAvailable(int rowsToCheck);
121 
122   /**
123    * Check if a range of rows is available from a starting index without 
124    * requiring the client to iterate over the rows
125    * @param startIndex the starting index for the range
126    * @param rowsToCheck number of rows to check
127    * @return true if all rows in range are available
128    */
129   public boolean areRowsAvailable(int startIndex, int rowsToCheck) ;
130 
131 
132   /**
133    * Check if a range of rows is available from a starting row key without 
134    * requiring the client to iterate over the rows
135    * @param startRowKey the starting row key for the range
136    * @param rowsToCheck number of rows to check
137    * @return true if all rows in range are available
138    */
139   public boolean areRowsAvailable(Object startRowKey, int rowsToCheck) ;  
140 }