KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mmbase > bridge > jsp > taglib > util > Notfound


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
11 package org.mmbase.bridge.jsp.taglib.util;
12
13 import java.util.*;
14
15 import javax.servlet.jsp.JspTagException JavaDoc;
16
17 import org.mmbase.bridge.jsp.taglib.ContextReferrerTag;
18 import org.mmbase.util.logging.*;
19
20 /**
21  * A helper class to implement notfound attribute
22  *
23  * @author Michiel Meeuwissen
24  * @version $Id: Notfound.java,v 1.2 2006/03/28 20:31:12 michiel Exp $
25  * @since MMBase-1.8
26  */

27 public abstract class Notfound {
28     private static final Logger log = Logging.getLoggerInstance(Notfound.class);
29
30     public final static int DEFAULT = -1;
31     public final static int THROW = 0;
32     public final static int SKIP = 1;
33     public final static int PROVIDENULL = 2;
34     public final static int MESSAGE = 3;
35
36
37     public static int get(Attribute notfound, ContextReferrerTag tag) throws JspTagException JavaDoc {
38         if (notfound == Attribute.NULL) {
39             return DEFAULT;
40         }
41         String JavaDoc is = notfound.getString(tag).toLowerCase();
42         if ("skip".equals(is)) {
43             return SKIP;
44         } else if ("skipbody".equals(is)) {
45             return SKIP;
46         } else if ("throw".equals(is)) {
47             return THROW;
48         } else if ("exception".equals(is)) {
49             return THROW;
50         } else if ("throwexception".equals(is)) {
51             return THROW;
52         } else if ("null".equals(is)) {
53             return PROVIDENULL;
54         } else if ("providenull".equals(is)) {
55             return PROVIDENULL;
56         } else if ("message".equals(is)) {
57             return MESSAGE;
58         } else {
59             throw new JspTagException JavaDoc("Invalid value for attribute 'notfound' " + is + "(" + notfound + ")");
60         }
61     }
62
63
64 }
65
Popular Tags