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