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