01: /**
02: * Copyright (c) 2000-2008 Liferay, Inc. All rights reserved.
03: *
04: * Permission is hereby granted, free of charge, to any person obtaining a copy
05: * of this software and associated documentation files (the "Software"), to deal
06: * in the Software without restriction, including without limitation the rights
07: * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
08: * copies of the Software, and to permit persons to whom the Software is
09: * furnished to do so, subject to the following conditions:
10: *
11: * The above copyright notice and this permission notice shall be included in
12: * all copies or substantial portions of the Software.
13: *
14: * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15: * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16: * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17: * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18: * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19: * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20: * SOFTWARE.
21: */package com.liferay.util.xml.descriptor;
22:
23: import com.liferay.util.xml.ElementIdentifier;
24:
25: import org.dom4j.Document;
26:
27: /**
28: * <a href="WebXML24Descriptor.java.html"><b><i>View Source</i></b></a>
29: *
30: * @author Jorge Ferrer
31: * @author Brian Wing Shun Chan
32: *
33: */
34: public class WebXML24Descriptor extends SimpleXMLDescriptor {
35:
36: public boolean canHandleType(String doctype, Document root) {
37: if (doctype.indexOf("web-app") != -1) {
38: return true;
39: } else {
40: return false;
41: }
42: }
43:
44: public String[] getRootChildrenOrder() {
45: return _ROOT_ORDERED_CHILDREN;
46: }
47:
48: public ElementIdentifier[] getElementsIdentifiedByAttribute() {
49: return _ELEMENTS_IDENTIFIED_BY_ATTR;
50: }
51:
52: public ElementIdentifier[] getElementsIdentifiedByChild() {
53: return _ELEMENTS_IDENTIFIED_BY_CHILD;
54: }
55:
56: public String[] getUniqueElements() {
57: return _UNIQUE_ELEMENTS;
58: }
59:
60: public String[] getJoinableElements() {
61: return _JOINABLE_ELEMENTS;
62: }
63:
64: private static final String[] _ROOT_ORDERED_CHILDREN = { "icon",
65: "display-name", "description", "distributable",
66: "context-param", "filter", "filter-mapping", "listener",
67: "servlet", "servlet-mapping", "session-config",
68: "mime-mapping", "welcome-file-list", "error-page",
69: "jsp-config", "resource-env-ref", "resource-ref",
70: "security-constraint", "login-config", "security-role",
71: "env-entry", "ejb-ref", "ejb-local-ref" };
72:
73: private static final ElementIdentifier[] _ELEMENTS_IDENTIFIED_BY_ATTR = {};
74:
75: private static final ElementIdentifier[] _ELEMENTS_IDENTIFIED_BY_CHILD = {
76: new ElementIdentifier("context-param", "param-name"),
77: new ElementIdentifier("filter", "filter-name"),
78: //new ElementIdentifier("filter-mapping", "filter-name"),
79: new ElementIdentifier("servlet", "servlet-name"),
80: //new ElementIdentifier("servlet-mapping", "servlet-name"),
81: new ElementIdentifier("init-param", "param-name"),
82: new ElementIdentifier("taglib", "taglib-uri"),
83: new ElementIdentifier("resource-env-ref",
84: "res-env-ref-name"),
85: new ElementIdentifier("resource-ref", "res-ref-name"),
86: new ElementIdentifier("ejb-local-ref", "ejb-ref-name") };
87:
88: private static final String[] _UNIQUE_ELEMENTS = { "icon",
89: "display-name", "description", "distributable",
90: "session-config", "welcome-file-list", "jsp-config",
91: "login-config" };
92:
93: private static final String[] _JOINABLE_ELEMENTS = {
94: "welcome-file-list", "jsp-config" };
95:
96: }
|