KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > taglibs > jndi > ListTEI


1 /*
2  * Copyright 1999,2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17 package org.apache.taglibs.jndi;
18
19 import javax.servlet.jsp.tagext.*;
20
21 /**
22  *
23  * @author Danno Ferrin <shemnon@earthlink.net>
24  * @version $Revision: 1.2 $
25  */

26 public class ListTEI extends TagExtraInfo {
27
28     /** Creates new UseContextTEI */
29     public ListTEI() {
30     }
31
32     public VariableInfo[] getVariableInfo(TagData data) {
33         String JavaDoc nameId, classId, objId;
34         nameId = data.getAttributeString("nameId");
35         classId = data.getAttributeString("classId");
36         objId = data.getAttributeString("objId");
37         // an unrolled loop will be quicker than a Vector or List
38
int size =
39               ((nameId == null)?0:1)
40             + ((classId == null)?0:1)
41             + ((objId == null)?0:1);
42         VariableInfo[] ret = new VariableInfo[size];
43         if (objId != null) {
44             ret[--size] = new VariableInfo(objId, "java.lang.Object", true,
45                     VariableInfo.NESTED);
46         }
47         if (classId != null) {
48             ret[--size] = new VariableInfo(classId, "java.lang.String", true,
49                     VariableInfo.NESTED);
50         }
51         if (nameId != null) {
52             ret[--size] = new VariableInfo(nameId, "java.lang.String", true,
53                     VariableInfo.NESTED);
54         }
55         return ret;
56     }
57     
58     public boolean isValid(TagData data) {
59         if (
60             (data.getAttribute("context") == null)
61          && (data.getAttribute("contextRef") == null)) {
62             return false;
63         }
64         return true;
65     }
66     
67 }
68
Popular Tags