KickJava   Java API By Example, From Geeks To Geeks.

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


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.node.XMLElement;
30 import com.sun.enterprise.deployment.xml.RuntimeTagNames;
31 import com.sun.enterprise.deployment.runtime.RuntimeDescriptor;
32 import com.sun.enterprise.deployment.runtime.web.LocaleCharsetMap;
33 /**
34 * node for web property tag
35 *
36 * @author Jerome Dochez
37 */

38 public class LocaleCharsetMapNode extends WebRuntimeNode {
39     
40     /**
41      * receives notification 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     RuntimeDescriptor descriptor = getRuntimeDescriptor();
48     if (descriptor==null) {
49         throw new RuntimeException JavaDoc("Trying to set name or value on null property");
50     }
51     if (element.getQName().equals(RuntimeTagNames.LOCALE)) {
52         descriptor.setAttributeValue(LocaleCharsetMap.LOCALE, value);
53     } else
54     if (element.getQName().equals(RuntimeTagNames.AGENT)) {
55         descriptor.setAttributeValue(LocaleCharsetMap.AGENT, value);
56     }
57     if (element.getQName().equals(RuntimeTagNames.CHARSET)) {
58         descriptor.setAttributeValue(LocaleCharsetMap.CHARSET, value);
59     }
60     }
61     
62     /**
63      * write the descriptor class to a DOM tree and return it
64      *
65      * @param parent node for the DOM tree
66      * @param node name for the descriptor
67      * @param the descriptor to write
68      * @return the DOM tree top node
69      */

70     public Node JavaDoc writeDescriptor(Node JavaDoc parent, String JavaDoc nodeName, LocaleCharsetMap descriptor) {
71     
72     Element JavaDoc locale = (Element JavaDoc) super.writeDescriptor(parent, nodeName, descriptor);
73     
74     // description?
75
appendTextChild(locale, RuntimeTagNames.DESCRIPTION, descriptor.getDescription());
76     
77     // locale, agent, charset attributes
78
setAttribute(locale, RuntimeTagNames.LOCALE, (String JavaDoc) descriptor.getAttributeValue(LocaleCharsetMap.LOCALE));
79     setAttribute(locale, RuntimeTagNames.AGENT, (String JavaDoc) descriptor.getAttributeValue(LocaleCharsetMap.AGENT));
80     setAttribute(locale, RuntimeTagNames.CHARSET, (String JavaDoc) descriptor.getAttributeValue(LocaleCharsetMap.CHARSET));
81     
82     return locale;
83     }
84 }
85
Popular Tags