001
014
015 package com.liferay.util.xml.descriptor;
016
017 import com.liferay.util.xml.ElementIdentifier;
018
019 import java.util.HashMap;
020 import java.util.Map;
021
022 import org.dom4j.Document;
023 import org.dom4j.Element;
024
025
029 public class WebXML24Descriptor extends SimpleXMLDescriptor {
030
031 public WebXML24Descriptor() {
032 _orderedChildren.put(
033 "jsp-config", new String[] {"taglib", "jsp-property-group"});
034 }
035
036 public boolean canHandleType(String doctype, Document root) {
037 if (doctype.indexOf("web-app") != -1) {
038 return true;
039 }
040 else {
041 return false;
042 }
043 }
044
045 public String[] getRootChildrenOrder() {
046 return _ROOT_ORDERED_CHILDREN;
047 }
048
049 public String[] getChildrenOrder(Element parentElement) {
050 String parentName = parentElement.getQName().getName();
051
052 if (_orderedChildren.containsKey(parentName)) {
053 return _orderedChildren.get(parentName);
054 }
055
056 return new String[0];
057 }
058
059 public ElementIdentifier[] getElementsIdentifiedByAttribute() {
060 return _ELEMENTS_IDENTIFIED_BY_ATTR;
061 }
062
063 public ElementIdentifier[] getElementsIdentifiedByChild() {
064 return _ELEMENTS_IDENTIFIED_BY_CHILD;
065 }
066
067 public String[] getUniqueElements() {
068 return _UNIQUE_ELEMENTS;
069 }
070
071 public String[] getJoinableElements() {
072 return _JOINABLE_ELEMENTS;
073 }
074
075 private static final String[] _ROOT_ORDERED_CHILDREN = {
076 "icon", "display-name", "description", "distributable", "context-param",
077 "filter", "filter-mapping", "listener", "servlet", "servlet-mapping",
078 "session-config", "mime-mapping", "welcome-file-list", "error-page",
079 "jsp-config", "resource-env-ref", "resource-ref", "security-constraint",
080 "login-config", "security-role", "env-entry", "ejb-ref", "ejb-local-ref"
081 };
082
083 private static final ElementIdentifier[] _ELEMENTS_IDENTIFIED_BY_ATTR = {
084 };
085
086 private static final ElementIdentifier[] _ELEMENTS_IDENTIFIED_BY_CHILD = {
087 new ElementIdentifier("context-param", "param-name"),
088 new ElementIdentifier("filter", "filter-name"),
089
090 new ElementIdentifier("servlet", "servlet-name"),
091
092 new ElementIdentifier("init-param", "param-name"),
093 new ElementIdentifier("taglib", "taglib-uri"),
094 new ElementIdentifier("resource-env-ref", "res-env-ref-name"),
095 new ElementIdentifier("resource-ref", "res-ref-name"),
096 new ElementIdentifier("ejb-local-ref", "ejb-ref-name")
097 };
098
099 private static final String[] _UNIQUE_ELEMENTS = {
100 "icon", "display-name", "description", "distributable",
101 "session-config", "welcome-file-list", "jsp-config", "login-config"
102 };
103
104 private static final String[] _JOINABLE_ELEMENTS = {
105 "welcome-file-list", "jsp-config"
106 };
107
108 private Map<String, String[]> _orderedChildren =
109 new HashMap<String, String[]>();
110
111 }