1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.apache.geronimo.ews.ws4j2ee.context.webservices.server;
17
18 import org.apache.geronimo.ews.ws4j2ee.context.webservices.server.interfaces.WSCFConstants;
19 import org.w3c.dom.Element;
20 import org.w3c.dom.Node;
21 import org.w3c.dom.NodeList;
22
23 import java.util.Vector;
24
25 /***
26 * This will represent an Element in the WebService.xml configuration file.
27 * EVERY concrete Element class in the configuration file will directly or indirectlt
28 * will extend this class and will show the polymorphic behavior defined here.
29 * The class has been taken from the axis WSDDElement class
30 */
31 public abstract class WSCFElement implements WSCFConstants {
32
33 public WSCFElement() {
34 }
35
36 public WSCFElement(Element e) throws WSCFException {
37
38 }
39
40 /***
41 * Gets the child element of name <code>name<\code> from the element passed <code>e</code>
42 *
43 * @param e Element
44 * @param name name of the child element to be searched
45 * @return child Element
46 */
47 public Element getChildElement(Element e, String name) {
48 Element[] elements = getChildElements(e, name);
49 if (elements.length == 0)
50 return null;
51 return elements[0];
52 }
53
54 /***
55 * Gets the child elements of name <code>name<\code> from the element passed <code>e</code>
56 *
57 * @param e Element
58 * @param name name of the child element to be searched
59 * @return child Elements
60 */
61 public Element[] getChildElements(Element e, String name) {
62 NodeList nl = e.getChildNodes();
63 Vector els = new Vector();
64 for (int i = 0; i < nl.getLength(); i++) {
65 Node thisNode = nl.item(i);
66 if (!(thisNode instanceof Element))
67 continue;
68 Element el = (Element) thisNode;
69 if (el.getLocalName().equals(name)) {
70 els.add(el);
71 }
72 }
73 Element[] elements = new Element[els.size()];
74 els.toArray(elements);
75 return elements;
76 }
77 }