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