KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > tools > verifier > web > TagDescriptor


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23
24 package com.sun.enterprise.tools.verifier.web;
25
26 import org.w3c.dom.NodeList JavaDoc;
27 import org.w3c.dom.Node JavaDoc;
28
29 /**
30  * This is the descriptor class for the tag element of the taglib root element
31  * for a .tld file used in a jsp.
32  */

33 public class TagDescriptor {
34     Node JavaDoc node;
35     public static final String JavaDoc TAG_CLASS_NAME = "tag-class"; // NOI18N
36
public static final String JavaDoc TAG_CLASS_1_1_NAME = "tagclass"; // NOI18N
37
public static final String JavaDoc DYNAMIC_ATTRIB = "dynamic-attributes"; // NOI18N
38
public static final String JavaDoc _FALSE = "false"; // NOI18N
39
public static final String JavaDoc TAG_NAME = "name"; // NOI18N
40

41     public TagDescriptor (Node JavaDoc n) {
42         this.node=n;
43     }
44
45     /**
46      * <tag-class>className<tag-class>
47      * @return class name as String
48      */

49     public String JavaDoc getTagClass() {
50         NodeList JavaDoc n1 = node.getChildNodes();
51         String JavaDoc className = null;
52         for (int k = 0; k < n1.getLength(); k++) {
53             String JavaDoc name = n1.item(k).getNodeName();
54             if (name == TAG_CLASS_NAME || name == TAG_CLASS_1_1_NAME) {
55                 className = n1.item(k).getFirstChild().getNodeValue();
56             }
57         }
58         return className;
59     }
60
61     /**
62      *
63      * @return dynamic-attributes value defined for a tag
64      */

65     public String JavaDoc getDynamicAttributes() {
66         NodeList JavaDoc n1 = node.getChildNodes();
67         String JavaDoc dynAttr = _FALSE;
68         for (int k = 0; k < n1.getLength(); k++) {
69             String JavaDoc name = n1.item(k).getNodeName();
70             if (name == DYNAMIC_ATTRIB) {
71                 dynAttr = n1.item(k).getFirstChild().getNodeValue();
72             }
73         }
74         return dynAttr;
75     }
76
77     /**
78      *
79      * @return name of the tag
80      */

81     public String JavaDoc getTagName() {
82         NodeList JavaDoc n1 = node.getChildNodes();
83         String JavaDoc tagName = null;
84         for (int k = 0; k < n1.getLength(); k++) {
85             String JavaDoc name = n1.item(k).getNodeName();
86             if (name == TAG_NAME) {
87                  tagName = n1.item(k).getFirstChild().getNodeValue();
88             }
89         }
90         return tagName;
91     }
92 }
93
Popular Tags