KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > deployment > node > runtime > web > WebPropertyNode


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.web;
25
26 import org.w3c.dom.Node JavaDoc;
27 import org.w3c.dom.Element JavaDoc;
28
29 import com.sun.enterprise.deployment.runtime.web.WebProperty;
30 import com.sun.enterprise.deployment.xml.RuntimeTagNames;
31 import com.sun.enterprise.deployment.node.XMLElement;
32 import com.sun.enterprise.deployment.runtime.RuntimeDescriptor;
33
34
35 /**
36 * node for web property tag
37 *
38 * @author Jerome Dochez
39 */

40 public class WebPropertyNode extends WebRuntimeNode {
41
42     /**
43      * parsed an attribute of an element
44      *
45      * @param the element name
46      * @param the attribute name
47      * @param the attribute value
48      * @return true if the attribute was processed
49      */

50     protected boolean setAttributeValue(XMLElement elementName, XMLElement attributeName, String JavaDoc value) {
51         RuntimeDescriptor descriptor =
52             (RuntimeDescriptor) getRuntimeDescriptor();
53         if (descriptor==null) {
54             throw new RuntimeException JavaDoc(
55             "Trying to set values on a null descriptor");
56         }
57         if (attributeName.getQName().equals(RuntimeTagNames.NAME)) {
58             descriptor.setAttributeValue(WebProperty.NAME, value);
59             return true;
60         } else if (attributeName.getQName().equals(RuntimeTagNames.VALUE)) {
61             descriptor.setAttributeValue(WebProperty.VALUE, value);
62             return true;
63         }
64         return false;
65     }
66     
67     /**
68      * write the descriptor class to a DOM tree and return it
69      *
70      * @param parent node for the DOM tree
71      * @param node name for the descriptor
72      * @param the descriptor to write
73      * @return the DOM tree top node
74      */

75     public Node JavaDoc writeDescriptor(Node JavaDoc parent, String JavaDoc nodeName,
76         WebProperty property) {
77         Element JavaDoc propertyElement =
78             (Element JavaDoc) super.writeDescriptor(parent, nodeName, property);
79
80         // description?
81
appendTextChild(propertyElement, RuntimeTagNames.DESCRIPTION, property.getDescription());
82
83     setAttribute(propertyElement, RuntimeTagNames.NAME, (String JavaDoc) property.getAttributeValue(WebProperty.NAME));
84     setAttribute(propertyElement, RuntimeTagNames.VALUE, (String JavaDoc) property.getAttributeValue(WebProperty.VALUE));
85         return propertyElement;
86     }
87     
88     /**
89      * write the descriptor class to a DOM tree and return it
90      *
91      * @param parent node for the DOM tree
92      * @param node name for the descriptor
93      * @param the array of descriptors to write
94      */

95     public void writeDescriptor(Node JavaDoc parent, String JavaDoc nodeName, WebProperty[] properties) {
96     if (properties==null)
97         return;
98     for (int i=0;i<properties.length;i++) {
99         writeDescriptor(parent, nodeName, properties[i]);
100     }
101     }
102 }
103
104
Popular Tags