summaryrefslogtreecommitdiffstats
path: root/base/common/src/com/netscape/certsrv/dbs/IDBVirtualList.java
blob: 919a82efb93399c26118a794746e12b03ed59c48 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
// --- BEGIN COPYRIGHT BLOCK ---
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; version 2 of the License.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along
// with this program; if not, write to the Free Software Foundation, Inc.,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
//
// (C) 2007 Red Hat, Inc.
// All rights reserved.
// --- END COPYRIGHT BLOCK ---
package com.netscape.certsrv.dbs;

import com.netscape.certsrv.base.EBaseException;

/**
 * A interface represents a virtual list of search results.
 * Note that this class must be used with DS4.0.
 * 
 * @version $Revision$, $Date$
 */
public interface IDBVirtualList<E> {

    /**
     * Sets the paging size of this virtual list.
     * The page size here is just a buffer size. A buffer is kept around
     * that is three times as large as the number of visible entries.
     * That way, you can scroll up/down several items(up to a page-full)
     * without refetching entries from the directory.
     * 
     * @param size the page size
     */
    public void setPageSize(int size);

    /**
     * Sets the sort key
     * 
     * @param sortKey the attribute to sort by
     * @exception EBaseException failed to set
     */
    public void setSortKey(String sortKey) throws EBaseException;

    /**
     * Sets the sort key
     * 
     * @param sortKeys the attributes to sort by
     * @exception EBaseException failed to set
     */
    public void setSortKey(String[] sortKeys) throws EBaseException;

    /**
     * Retrieves the size of this virtual list.
     * Recommend to call getSize() before getElementAt() or getElements()
     * since you'd better check if the index is out of bound first.
     * 
     * @return current size in list
     */
    public int getSize();

    /**
     * Returns current index.
     * 
     * @return current index
     */

    public int getSizeBeforeJumpTo();

    public int getSizeAfterJumpTo();

    public int getCurrentIndex();

    /**
     * Get a page starting at "first" (although we may also fetch
     * some preceding entries)
     * Recommend to call getSize() before getElementAt() or getElements()
     * since you'd better check if the index is out of bound first.
     * 
     * @param first the index of the first entry of the page you want to fetch
     */
    public boolean getPage(int first);

    /**
     * Called by application to scroll the list with initial letters.
     * Consider text to be an initial substring of the attribute of the
     * primary sorting key(the first one specified in the sort key array)
     * of an entry.
     * If no entries match, the one just before(or after, if none before)
     * will be returned as mSelectedIndex
     * 
     * @param text the prefix of the first entry of the page you want to fetch
     */
    public boolean getPage(String text);

    /**
     * Fetchs data of a single list item
     * Recommend to call getSize() before getElementAt() or getElements()
     * since you'd better check if the index is out of bound first.
     * If the index is out of range of the virtual list, an exception
     * will be thrown and return null
     * 
     * @param index the index of the element to fetch
     */
    public E getElementAt(int index);

    /**
     * Retrieves and jumps to element in the given position.
     * 
     * @param i position
     * @return object
     */
    public E getJumpToElementAt(int i);

    /**
     * Processes elements as soon as it arrives. It is
     * more memory-efficient.
     * 
     * @param startidx starting index
     * @param endidx ending index
     * @param ep object to call
     * @exception EBaseException failed to process elements
     */
    public void processElements(int startidx, int endidx, IElementProcessor ep)
            throws EBaseException;

    /**
     * Gets the virutal selected index
     * 
     * @return selected index
     */
    public int getSelectedIndex();

    /**
     * Gets the top of the buffer
     * 
     * @return first index
     */
    public int getFirstIndex();
}