KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > deployment > node > DisplayableComponentNode


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;
25
26
27 import java.util.Map JavaDoc;
28 import java.util.HashMap JavaDoc;
29 import java.util.Iterator JavaDoc;
30 import org.w3c.dom.Node JavaDoc;
31 import org.w3c.dom.Element JavaDoc;
32 import com.sun.enterprise.deployment.Descriptor;
33 import com.sun.enterprise.deployment.xml.TagNames;
34
35
36 /**
37  * This node class is responsible for handling all the information
38  * related to displayable elements like display-name or icons.
39  *
40  * @author Jerome Dochez
41  * @version
42  */

43 public abstract class DisplayableComponentNode extends DeploymentDescriptorNode {
44
45     public DisplayableComponentNode() {
46         super();
47         registerElementHandler(new XMLElement(TagNames.NAME), LocalizedInfoNode.class);
48         registerElementHandler(new XMLElement(TagNames.ICON), IconNode.class);
49         registerElementHandler(new XMLElement(TagNames.SMALL_ICON), IconNode.class);
50         registerElementHandler(new XMLElement(TagNames.LARGE_ICON), IconNode.class);
51     }
52     
53     /**
54      * write the descriptor class to a DOM tree and return it
55      *
56      * @param parent node for the DOM tree
57      * @param the descriptor to write
58      * @return the DOM tree top node
59      */

60     public Node JavaDoc writeDescriptor(Node JavaDoc parent, Descriptor descriptor) {
61         Node JavaDoc node = super.writeDescriptor(parent, descriptor);
62         
63         // description, display-name, icons...
64
writeDisplayableComponentInfo(node, descriptor);
65         return node;
66     }
67     
68     /**
69      * write the localized descriptions, display-names and icons info
70      *
71      * @param the node to write the info to
72      * @param the descriptor containing the displayable information
73      */

74     protected void writeDisplayableComponentInfo(Node JavaDoc node, Descriptor descriptor) {
75         LocalizedNode localizedNode = new LocalizedNode();
76         localizedNode.writeLocalizedMap(node, TagNames.DESCRIPTION, descriptor.getLocalizedDescriptions());
77         localizedNode.writeLocalizedMap(node, TagNames.NAME, descriptor.getLocalizedDisplayNames());
78         IconNode iconNode = new IconNode();
79         iconNode.writeLocalizedInfo(node, descriptor);
80         
81     }
82 }
83
Popular Tags