1 16 package org.apache.juddi.handler; 17 18 import java.util.Vector ; 19 20 import org.apache.juddi.datatype.Name; 21 import org.apache.juddi.datatype.RegistryObject; 22 import org.apache.juddi.datatype.response.ServiceInfo; 23 import org.apache.juddi.util.xml.XMLUtils; 24 import org.w3c.dom.Element ; 25 26 32 public class ServiceInfoHandler extends AbstractHandler 33 { 34 public static final String TAG_NAME = "serviceInfo"; 35 36 private HandlerMaker maker = null; 37 38 protected ServiceInfoHandler(HandlerMaker maker) 39 { 40 this.maker = maker; 41 } 42 43 public RegistryObject unmarshal(Element element) 44 { 45 ServiceInfo obj = new ServiceInfo(); 46 Vector nodeList = null; 47 AbstractHandler handler = null; 48 49 obj.setServiceKey(element.getAttribute("serviceKey")); 51 obj.setBusinessKey(element.getAttribute("businessKey")); 52 53 56 nodeList = XMLUtils.getChildElementsByTagName(element,NameHandler.TAG_NAME); 58 for (int i=0; i<nodeList.size(); i++) 59 { 60 handler = maker.lookup(NameHandler.TAG_NAME); 61 Name name = (Name )handler.unmarshal((Element )nodeList.elementAt(i)); 62 if (name != null) 63 obj.addName(name); 64 } 65 66 return obj; 67 } 68 69 public void marshal(RegistryObject object,Element parent) 70 { 71 ServiceInfo info = (ServiceInfo)object; 72 Element element = parent.getOwnerDocument().createElementNS(null,TAG_NAME); 73 AbstractHandler handler = null; 74 75 String serviceKey = info.getServiceKey(); 77 element.setAttribute("serviceKey",(serviceKey != null) ? serviceKey : ""); 78 79 String businessKey = info.getBusinessKey(); 81 element.setAttribute("businessKey",(businessKey != null) ? businessKey : ""); 82 83 Vector vector = info.getNameVector(); 84 if ((vector!=null) && (vector.size() > 0)) 85 { 86 handler = maker.lookup(NameHandler.TAG_NAME); 87 for (int i=0; i < vector.size(); i++) 88 handler.marshal((Name)vector.elementAt(i),element); 89 } 90 91 parent.appendChild(element); 92 } 93 94 95 96 97 98 99 100 public static void main(String args[]) 101 throws Exception 102 { 103 } 104 } | Popular Tags |