KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > deployment > node > runtime > common > PrincipalNameNode


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.deployment.node.runtime.common;
25
26 import com.sun.enterprise.deployment.node.runtime.RuntimeDescriptorNode;
27 import com.sun.enterprise.deployment.node.XMLElement;
28 import com.sun.enterprise.deployment.runtime.common.PrincipalNameDescriptor;
29 import com.sun.enterprise.deployment.xml.RuntimeTagNames;
30 import org.w3c.dom.Element JavaDoc;
31 import org.w3c.dom.Node JavaDoc;
32
33 /**
34  * This node handles principal-name information
35  *
36  * @author deployment dev team
37  */

38 public class PrincipalNameNode extends RuntimeDescriptorNode {
39
40     /**
41      * receives notiification of the value for a particular tag
42      *
43      * @param element the xml element
44      * @param value it's associated value
45      */

46     public void setElementValue(XMLElement element, String JavaDoc value) {
47         PrincipalNameDescriptor principal =
48                 (PrincipalNameDescriptor) getDescriptor();
49         if (RuntimeTagNames.PRINCIPAL_NAME.equals(element.getQName())) {
50             principal.setName(value);
51         } else super.setElementValue(element, value);
52     }
53
54     /**
55      * parsed an attribute of an element
56      *
57      * @param the element name
58      * @param the attribute name
59      * @param the attribute value
60      * @return true if the attribute was processed
61      */

62     protected boolean setAttributeValue(
63             XMLElement element, XMLElement attribute, String JavaDoc value) {
64
65         PrincipalNameDescriptor principal =
66                             (PrincipalNameDescriptor) getDescriptor();
67         if (attribute.getQName().equals(RuntimeTagNames.CLASS_NAME)) {
68             principal.setClassName(value);
69             return true;
70         }
71         return false;
72     }
73
74     /**
75      * write the descriptor class to a DOM tree and return it
76      *
77      * @param parent node for the DOM tree
78      * @param node name for
79      * @param the descriptor to write
80      * @return the DOM tree top node
81      */

82     public Node writeDescriptor(
83             Node parent, String JavaDoc nodeName, PrincipalNameDescriptor descriptor) {
84
85         //principal-name
86
Element principal = (Element) appendTextChild(
87                 parent, RuntimeTagNames.PRINCIPAL_NAME, descriptor.getName());
88
89         // class-name
90
setAttribute(principal, RuntimeTagNames.CLASS_NAME, descriptor.getClassName());
91
92         return principal;
93     }
94 }
95
Popular Tags