1 55 package org.jboss.axis.deployment.wsdd; 56 57 import org.jboss.axis.encoding.SerializationContext; 58 import org.jboss.axis.utils.Messages; 59 import org.w3c.dom.Element ; 60 import org.w3c.dom.Node ; 61 import org.w3c.dom.NodeList ; 62 63 import javax.xml.namespace.QName ; 64 import java.io.IOException ; 65 import java.util.Vector ; 66 67 68 71 public abstract class WSDDElement extends WSDDConstants 72 { 73 76 private WSDDDocumentation documentation = null; 77 78 private String name; 79 80 83 public WSDDElement() 84 { 85 } 86 87 93 public WSDDElement(Element e) 94 throws WSDDException 95 { 96 validateCandidateElement(e); 97 } 98 99 102 protected abstract QName getElementName(); 103 104 107 private void validateCandidateElement(Element e) 108 throws WSDDException 109 { 110 QName name = getElementName(); 111 112 if ((null == e) || (null == e.getNamespaceURI()) 113 || (null == e.getLocalName()) 114 || !e.getNamespaceURI().equals(name.getNamespaceURI()) 115 || !e.getLocalName().equals(name.getLocalPart())) 116 { 117 throw new WSDDException(Messages.getMessage("invalidWSDD00", 118 e.getLocalName(), 119 name.getLocalPart())); 120 } 121 } 122 123 public Element getChildElement(Element e, String name) 124 { 125 Element [] elements = getChildElements(e, name); 126 if (elements.length == 0) 127 return null; 128 return elements[0]; 129 } 130 131 public Element [] getChildElements(Element e, String name) 132 { 133 NodeList nl = e.getChildNodes(); 134 Vector els = new Vector (); 135 136 for (int i = 0; i < nl.getLength(); i++) 137 { 138 Node thisNode = nl.item(i); 139 if (!(thisNode instanceof Element )) 140 continue; 141 142 Element el = (Element )thisNode; 143 if (el.getLocalName().equals(name)) 144 { 145 els.add(el); 146 } 147 } 148 149 Element [] elements = new Element [els.size()]; 150 els.toArray(elements); 151 152 return elements; 153 } 154 155 161 public WSDDDocumentation getDocumentation() 162 { 163 return documentation; 164 } 165 166 169 public abstract void writeToContext(SerializationContext context) 170 throws IOException ; 171 } 172 | Popular Tags |