1 16 package org.apache.juddi.handler; 17 18 import java.util.Vector ; 19 20 import org.apache.juddi.IRegistry; 21 import org.apache.juddi.datatype.RegistryObject; 22 import org.apache.juddi.datatype.response.ServiceInfos; 23 import org.apache.juddi.datatype.response.ServiceList; 24 import org.apache.juddi.util.xml.XMLUtils; 25 import org.w3c.dom.Element ; 26 27 33 public class ServiceListHandler extends AbstractHandler 34 { 35 public static final String TAG_NAME = "serviceList"; 36 37 private HandlerMaker maker = null; 38 39 protected ServiceListHandler(HandlerMaker maker) 40 { 41 this.maker = maker; 42 } 43 44 public RegistryObject unmarshal(Element element) 45 { 46 ServiceList obj = new ServiceList(); 47 Vector nodeList = null; 48 AbstractHandler handler = null; 49 50 54 obj.setGeneric(element.getAttribute("generic")); 56 obj.setOperator(element.getAttribute("operator")); 57 58 62 String truncValue = element.getAttribute("truncated"); 63 if (truncValue != null) 64 obj.setTruncated(truncValue.equalsIgnoreCase("true")); 65 66 69 nodeList = XMLUtils.getChildElementsByTagName(element,ServiceInfosHandler.TAG_NAME); 71 if (nodeList.size() > 0) 72 { 73 handler = maker.lookup(ServiceInfosHandler.TAG_NAME); 74 obj.setServiceInfos((ServiceInfos)handler.unmarshal((Element )nodeList.elementAt(0))); 75 } 76 77 return obj; 78 } 79 80 public void marshal(RegistryObject object,Element parent) 81 { 82 ServiceList list = (ServiceList)object; 83 Element element = parent.getOwnerDocument().createElementNS(null,TAG_NAME); 84 AbstractHandler handler = null; 85 86 String generic = list.getGeneric(); 87 if ((generic != null) && (generic.trim().length() > 0)) 88 { 89 element.setAttribute("generic",generic); 90 91 if (generic.equals(IRegistry.UDDI_V1_GENERIC)) 92 element.setAttribute("xmlns",IRegistry.UDDI_V1_NAMESPACE); 93 else if (generic.equals(IRegistry.UDDI_V2_GENERIC)) 94 element.setAttribute("xmlns",IRegistry.UDDI_V2_NAMESPACE); 95 else if (generic.equals(IRegistry.UDDI_V3_GENERIC)) 96 element.setAttribute("xmlns",IRegistry.UDDI_V3_NAMESPACE); 97 } 98 else { 100 element.setAttribute("generic",IRegistry.UDDI_V2_GENERIC); 101 element.setAttribute("xmlns",IRegistry.UDDI_V2_NAMESPACE); 102 } 103 104 String operator = list.getOperator(); 105 if (operator != null) 106 element.setAttribute("operator",operator); 107 else 108 element.setAttribute("operator",""); 109 110 boolean truncated = list.isTruncated(); 111 if (truncated) 112 element.setAttribute("truncated","true"); 113 114 ServiceInfos infos = list.getServiceInfos(); 115 if (infos != null) 116 { 117 handler = maker.lookup(ServiceInfosHandler.TAG_NAME); 118 handler.marshal(infos,element); 119 } 120 121 parent.appendChild(element); 122 } 123 124 125 126 127 128 129 130 public static void main(String args[]) 131 throws Exception 132 { 133 } 134 } | Popular Tags |