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 @Override
037 public boolean canHandleType(String doctype, Document root) {
038 if (doctype.indexOf("web-app") != -1) {
039 return true;
040 }
041 else {
042 return false;
043 }
044 }
045
046 @Override
047 public String[] getChildrenOrder(Element parentElement) {
048 String parentName = parentElement.getQName().getName();
049
050 String[] childrenOrder = _orderedChildren.get(parentName);
051
052 if (childrenOrder == null) {
053 childrenOrder = new String[0];
054 }
055
056 return childrenOrder;
057 }
058
059 @Override
060 public ElementIdentifier[] getElementsIdentifiedByAttribute() {
061 return _ELEMENTS_IDENTIFIED_BY_ATTR;
062 }
063
064 @Override
065 public ElementIdentifier[] getElementsIdentifiedByChild() {
066 return _ELEMENTS_IDENTIFIED_BY_CHILD;
067 }
068
069 @Override
070 public String[] getJoinableElements() {
071 return _JOINABLE_ELEMENTS;
072 }
073
074 @Override
075 public String[] getRootChildrenOrder() {
076 return _ROOT_ORDERED_CHILDREN;
077 }
078
079 @Override
080 public String[] getUniqueElements() {
081 return _UNIQUE_ELEMENTS;
082 }
083
084 private static final ElementIdentifier[] _ELEMENTS_IDENTIFIED_BY_ATTR = {
085 };
086
087 private static final ElementIdentifier[] _ELEMENTS_IDENTIFIED_BY_CHILD = {
088 new ElementIdentifier("context-param", "param-name"),
089 new ElementIdentifier("filter", "filter-name"),
090
091 new ElementIdentifier("servlet", "servlet-name"),
092
093 new ElementIdentifier("init-param", "param-name"),
094 new ElementIdentifier("taglib", "taglib-uri"),
095 new ElementIdentifier("resource-env-ref", "res-env-ref-name"),
096 new ElementIdentifier("resource-ref", "res-ref-name"),
097 new ElementIdentifier("ejb-local-ref", "ejb-ref-name")
098 };
099
100 private static final String[] _JOINABLE_ELEMENTS = {
101 "welcome-file-list", "jsp-config"
102 };
103
104 private static final String[] _ROOT_ORDERED_CHILDREN = {
105 "icon", "display-name", "description", "distributable", "context-param",
106 "filter", "filter-mapping", "listener", "servlet", "servlet-mapping",
107 "session-config", "mime-mapping", "welcome-file-list", "error-page",
108 "jsp-config", "resource-env-ref", "resource-ref", "security-constraint",
109 "login-config", "security-role", "env-entry", "ejb-ref", "ejb-local-ref"
110 };
111
112 private static final String[] _UNIQUE_ELEMENTS = {
113 "icon", "display-name", "description", "distributable",
114 "session-config", "welcome-file-list", "jsp-config", "login-config"
115 };
116
117 private Map<String, String[]> _orderedChildren =
118 new HashMap<String, String[]>();
119
120 }