1 9 10 package org.uddi4j; 11 12 import java.io.Serializable ; 13 import java.util.Vector ; 14 15 import org.w3c.dom.Element ; 16 import org.w3c.dom.Node ; 17 import org.w3c.dom.NodeList ; 18 19 25 public abstract class UDDIElement implements Serializable { 26 27 public static String GENERIC = "2.0"; 28 public static String XMLNS = "urn:uddi-org:api_v2"; 29 public static String SOAPNS = "http://schemas.xmlsoap.org/soap/envelope/"; 30 31 public UDDIElement() { 32 } 33 34 public UDDIElement(Element el) throws UDDIException { 35 if (UDDIException.isValidElement(el)) { 37 throw new UDDIException(el, true); 39 } 40 } 41 42 abstract public void saveToXML(Element base); 43 44 52 protected String getText(Node el) { 53 NodeList nl = el.getChildNodes(); 54 String result = ""; 55 for (int i = 0; i < nl.getLength(); i++) { 56 if (nl.item(i).getNodeType()==Element.TEXT_NODE) { 57 result += nl.item(i).getNodeValue(); 58 } 59 } 60 return result.trim(); 62 } 63 64 public NodeList getChildElementsByTagName(Element el, String tag) { 65 NodeList children = el.getChildNodes(); 68 Vector result = new Vector (); 69 for (int i = 0; i < children.getLength(); i++) { 70 Node node = children.item(i); 71 if (node.getNodeType() == Node.ELEMENT_NODE && 72 node.getNodeName().equals(tag)) { 73 result.addElement(node); 75 } 76 } 77 return new VectorNodeList(result); 78 } 79 80 protected Element base = null; 81 82 } 83 | Popular Tags |