KickJava   Java API By Example, From Geeks To Geeks.

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


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
12 import org.mmbase.bridge.jsp.taglib.util.Attribute;
13 import org.mmbase.bridge.jsp.taglib.Condition;
14 import org.mmbase.bridge.NotFoundException;
15
16 import javax.servlet.jsp.JspTagException JavaDoc;
17
18
19 /**
20  * Straight-forward wrapper arround {@link org.mmbase.bridge.Cloud#hasNode}.
21  *
22  * @author Michiel Meeuwissen
23  * @version $Id: HasNodeTag.java,v 1.1 2005/08/25 11:05:51 michiel Exp $
24  * @since MMBase-1.8
25  */

26
27 public class HasNodeTag extends CloudReferrerTag implements Condition {
28
29     protected Attribute inverse = Attribute.NULL;
30     protected Attribute number = Attribute.NULL;
31
32     public void setInverse(String JavaDoc b) throws JspTagException JavaDoc {
33         inverse = getAttribute(b);
34     }
35     public void setNumber(String JavaDoc n) throws JspTagException JavaDoc {
36         number = getAttribute(n);
37     }
38
39
40     protected boolean getInverse() throws JspTagException JavaDoc {
41         return inverse.getBoolean(this, false);
42     }
43
44
45     public int doStartTag() throws JspTagException JavaDoc {
46         if (getCloudVar().hasNode(number.getString(this)) != getInverse()) {
47             return EVAL_BODY;
48         } else {
49             return SKIP_BODY;
50         }
51     }
52     public int doAfterBody() throws JspTagException JavaDoc {
53         if (EVAL_BODY == EVAL_BODY_BUFFERED) { // not needed if EVAL_BODY_INCLUDE
54
try{
55                 if(bodyContent != null) {
56                     bodyContent.writeOut(bodyContent.getEnclosingWriter());
57                 }
58             } catch(java.io.IOException JavaDoc e){
59                 throw new JspTagException JavaDoc("IO Error: " + e.getMessage());
60             }
61         }
62         return SKIP_BODY;
63     }
64 }
65
Popular Tags