KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > deployment > node > web > JspGroupNode


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.web;
25
26 import java.util.Map JavaDoc;
27 import java.util.Enumeration JavaDoc;
28 import org.w3c.dom.Node JavaDoc;
29
30 import com.sun.enterprise.deployment.JspGroupDescriptor;
31 import com.sun.enterprise.deployment.node.DeploymentDescriptorNode;
32 import com.sun.enterprise.deployment.node.LocalizedInfoNode;
33 import com.sun.enterprise.deployment.node.XMLElement;
34 import com.sun.enterprise.deployment.xml.TagNames;
35 import com.sun.enterprise.deployment.xml.WebTagNames;
36
37 /**
38  * This node is responsible for handling jsp-group xml tag
39  * @version
40  */

41 public class JspGroupNode extends DeploymentDescriptorNode {
42
43     public JspGroupNode() {
44         super();
45         registerElementHandler(new XMLElement(WebTagNames.NAME), LocalizedInfoNode.class);
46     }
47     
48     /**
49      * all sub-implementation of this class can use a dispatch table to map
50      * xml element to
51      * method name on the descriptor class for setting the element value.
52      *
53      * @return the map with the element name as a key, the setter method as a
54      * value
55      */

56     protected Map JavaDoc getDispatchTable() {
57         Map JavaDoc table = super.getDispatchTable();
58         table.put(WebTagNames.URL_PATTERN, "addUrlPattern");
59         table.put(TagNames.NAME, "setDisplayName");
60         table.put(WebTagNames.EL_IGNORED, "setElIgnored");
61         table.put(WebTagNames.PAGE_ENCODING, "setPageEncoding");
62         table.put(WebTagNames.SCRIPTING_INVALID, "setScriptingInvalid");
63         table.put(WebTagNames.INCLUDE_PRELUDE, "addIncludePrelude");
64         table.put(WebTagNames.INCLUDE_CODA, "addIncludeCoda");
65         table.put(WebTagNames.IS_XML, "setIsXml");
66         table.put(WebTagNames.DEFERRED_SYNTAX_ALLOWED_AS_LITERAL,
67             "setDeferredSyntaxAllowedAsLiteral");
68         table.put(WebTagNames.TRIM_DIRECTIVE_WHITESPACES,
69             "setTrimDirectiveWhitespaces");
70         return table;
71     }
72     
73     /**
74      * write the descriptor class to a DOM tree and return it
75      *
76      * @param parent node in the DOM tree
77      * @param node name for the root element of this xml fragment
78      * @param the descriptor to write
79      * @return the DOM tree top node
80      */

81     public Node JavaDoc writeDescriptor(Node JavaDoc parent, String JavaDoc nodeName, JspGroupDescriptor descriptor) {
82         Node JavaDoc myNode = appendChild(parent, nodeName);
83
84         LocalizedInfoNode localizedNode = new LocalizedInfoNode();
85         writeLocalizedDescriptions(myNode, descriptor);
86         localizedNode.writeLocalizedMap(myNode, TagNames.NAME, descriptor.getLocalizedDisplayNames());
87         
88         // url-pattern*
89
for (Enumeration JavaDoc urlPatterns = descriptor.getUrlPatterns(); urlPatterns.hasMoreElements();) {
90             appendTextChild(myNode, WebTagNames.URL_PATTERN, (String JavaDoc) urlPatterns.nextElement());
91         }
92         appendTextChild(myNode, WebTagNames.EL_IGNORED, descriptor.getElIgnored());
93         appendTextChild(myNode, WebTagNames.PAGE_ENCODING, descriptor.getPageEncoding());
94         appendTextChild(myNode, WebTagNames.SCRIPTING_INVALID, descriptor.getScriptingInvalid());
95         appendTextChild(myNode, WebTagNames.IS_XML, descriptor.getIsXml());
96         // include-prelude*
97
for (Enumeration JavaDoc includePreludes = descriptor.getIncludePreludes(); includePreludes.hasMoreElements();) {
98             appendTextChild(myNode, WebTagNames.INCLUDE_PRELUDE, (String JavaDoc) includePreludes.nextElement());
99         }
100         // include-coda*
101
for (Enumeration JavaDoc includeCodas = descriptor.getIncludeCodas(); includeCodas.hasMoreElements();) {
102             appendTextChild(myNode, WebTagNames.INCLUDE_CODA, (String JavaDoc) includeCodas.nextElement());
103         }
104         appendTextChild(myNode, WebTagNames.DEFERRED_SYNTAX_ALLOWED_AS_LITERAL, descriptor.getDeferredSyntaxAllowedAsLiteral());
105         appendTextChild(myNode, WebTagNames.TRIM_DIRECTIVE_WHITESPACES, descriptor.getTrimDirectiveWhitespaces());
106         return myNode;
107     }
108 }
109
Popular Tags