KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mmbase > bridge > jsp > taglib > ListProvider


1 /*
2
3 This software is OSI Certified Open Source Software.
4 OSI Certified is a certification mark of the Open Source Initiative.
5
6 The license (Mozilla version 1.0) can be read at the MMBase site.
7 See http://www.MMBase.org/license
8
9 */

10 package org.mmbase.bridge.jsp.taglib;
11 import javax.servlet.jsp.JspTagException JavaDoc;
12 import javax.servlet.jsp.jstl.core.*;
13 import org.mmbase.util.logging.*;
14
15 /**
16  * Basic interface that parent should implement if they provide Lists.
17  * For example the several NodeListTag's provide a List.
18  *
19  * @author Michiel Meeuwissen
20  * @version $Id: ListProvider.java,v 1.13 2005/12/15 21:47:27 michiel Exp $
21  */

22 public interface ListProvider extends ContextProvider, LoopTag {
23     /**
24      * @return the size of the list
25      */

26     public int size();
27
28     /**
29      * @return the index of the current item in a list
30      *
31      */

32     public int getIndex();
33
34
35     /**
36      * @return The offset of the index (normally this will return 1)
37      * @since MMBase-1.7
38      */

39     public int getIndexOffset();
40
41     /**
42      * @return the current item in a list
43      */

44
45     public Object JavaDoc getCurrent();
46
47
48     /**
49      * @return a boolean indicating wether the field on which was
50      * sorted is changed.
51      *
52      */

53     public boolean isChanged();
54
55     /**
56      * Removes the current item from the list.
57      * @since MMBase-1.7
58      */

59     public void remove();
60
61
62     /**
63      * @since MMBase-1.8
64      */

65     public class ListProviderLoopTagStatus implements LoopTagStatus {
66         private static final Logger log = Logging.getLoggerInstance(ListProviderLoopTagStatus.class);
67
68         private final ListProvider prov;
69         public ListProviderLoopTagStatus(ListProvider l) {
70             prov = l;
71         }
72         public Object JavaDoc getCurrent() {
73             return prov.getCurrent();
74         }
75         public int getIndex() {
76             return prov.getIndex();// - prov.getIndexOffset();
77
}
78
79         public int getCount() {
80             return prov.size();
81         }
82
83         public boolean isFirst() {
84             return getIndex() == 0;
85         }
86         public boolean isLast() {
87             return getCount() == getIndex() + 1;
88         }
89         public Integer JavaDoc getBegin() {
90             return null;
91         }
92         public Integer JavaDoc getEnd() {
93             return null;
94         }
95         public Integer JavaDoc getStep() {
96             return null;
97         }
98     }
99
100
101 }
102
Popular Tags