KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mmbase > bridge > jsp > taglib > tree > GrowTag


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.tree;
11
12 import java.io.*;
13 import javax.servlet.jsp.JspTagException JavaDoc;
14 import javax.servlet.jsp.JspException JavaDoc;
15 import org.mmbase.bridge.jsp.taglib.TaglibException;
16
17 import org.mmbase.util.logging.*;
18
19 /**
20  * @author Michiel Meeuwissen
21  * @since MMBase-1.7
22  * @version $Id: GrowTag.java,v 1.1 2003/12/24 00:31:38 michiel Exp $
23  */

24 public class GrowTag extends AbstractTreeReferrerListTag {
25
26     private static final Logger log = Logging.getLoggerInstance(GrowTag.class);
27
28     protected int startDepth;
29     protected int endDepth ;
30
31
32
33     public int size() {
34         return endDepth - startDepth;
35     }
36
37     public int doStartTag() throws JspException JavaDoc {
38         doStartTagHelper();
39
40         startDepth = tree.getPreviousDepth();
41         endDepth = tree.getDepth();
42         depth = startDepth;
43
44         log.debug("while " + depth + " < " + endDepth);
45         if (depth < endDepth) {
46             return EVAL_BODY_BUFFERED;
47         } else {
48             return SKIP_BODY;
49         }
50     }
51
52
53     protected final int doAfterBodyHelper() throws JspTagException JavaDoc {
54         collector.doAfterBody();
55         depth++;
56         if (depth < endDepth) {
57             index++;
58             return EVAL_BODY_AGAIN;
59         } else {
60             return SKIP_BODY;
61         }
62     }
63
64     public int doAfterBody() throws JspException JavaDoc {
65         int result = doAfterBodyHelper();
66         if (result == SKIP_BODY) {
67             if (bodyContent != null) {
68                 try {
69                     bodyContent.writeOut(bodyContent.getEnclosingWriter());
70                 } catch (IOException ioe){
71                     throw new TaglibException(ioe);
72                 }
73             }
74         }
75         return result;
76
77     }
78
79
80
81
82 }
83
84
Popular Tags