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