1
14
15 package com.liferay.util.xml.descriptor;
16
17 import com.liferay.util.xml.ElementIdentifier;
18
19 import java.util.HashMap;
20 import java.util.Map;
21
22 import org.dom4j.Document;
23 import org.dom4j.Element;
24
25
31 public class WebXML24Descriptor extends SimpleXMLDescriptor {
32
33 public WebXML24Descriptor() {
34 _orderedChildren.put(
35 "jsp-config", new String[] {"taglib", "jsp-property-group"});
36 }
37
38 public boolean canHandleType(String doctype, Document root) {
39 if (doctype.indexOf("web-app") != -1) {
40 return true;
41 }
42 else {
43 return false;
44 }
45 }
46
47 public String[] getRootChildrenOrder() {
48 return _ROOT_ORDERED_CHILDREN;
49 }
50
51 public String[] getChildrenOrder(Element parentElement) {
52 String parentName = parentElement.getQName().getName();
53
54 if (_orderedChildren.containsKey(parentName)) {
55 return _orderedChildren.get(parentName);
56 }
57
58 return new String[0];
59 }
60
61 public ElementIdentifier[] getElementsIdentifiedByAttribute() {
62 return _ELEMENTS_IDENTIFIED_BY_ATTR;
63 }
64
65 public ElementIdentifier[] getElementsIdentifiedByChild() {
66 return _ELEMENTS_IDENTIFIED_BY_CHILD;
67 }
68
69 public String[] getUniqueElements() {
70 return _UNIQUE_ELEMENTS;
71 }
72
73 public String[] getJoinableElements() {
74 return _JOINABLE_ELEMENTS;
75 }
76
77 private static final String[] _ROOT_ORDERED_CHILDREN = {
78 "icon", "display-name", "description", "distributable", "context-param",
79 "filter", "filter-mapping", "listener", "servlet", "servlet-mapping",
80 "session-config", "mime-mapping", "welcome-file-list", "error-page",
81 "jsp-config", "resource-env-ref", "resource-ref", "security-constraint",
82 "login-config", "security-role", "env-entry", "ejb-ref", "ejb-local-ref"
83 };
84
85 private static final ElementIdentifier[] _ELEMENTS_IDENTIFIED_BY_ATTR = {
86 };
87
88 private static final ElementIdentifier[] _ELEMENTS_IDENTIFIED_BY_CHILD = {
89 new ElementIdentifier("context-param", "param-name"),
90 new ElementIdentifier("filter", "filter-name"),
91 new ElementIdentifier("servlet", "servlet-name"),
93 new ElementIdentifier("init-param", "param-name"),
95 new ElementIdentifier("taglib", "taglib-uri"),
96 new ElementIdentifier("resource-env-ref", "res-env-ref-name"),
97 new ElementIdentifier("resource-ref", "res-ref-name"),
98 new ElementIdentifier("ejb-local-ref", "ejb-ref-name")
99 };
100
101 private static final String[] _UNIQUE_ELEMENTS = {
102 "icon", "display-name", "description", "distributable",
103 "session-config", "welcome-file-list", "jsp-config", "login-config"
104 };
105
106 private static final String[] _JOINABLE_ELEMENTS = {
107 "welcome-file-list", "jsp-config"
108 };
109
110 private Map<String, String[]> _orderedChildren =
111 new HashMap<String, String[]>();
112
113 }