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.business.BusinessEntityExt; 23 import org.apache.juddi.datatype.response.BusinessDetailExt; 24 import org.apache.juddi.util.xml.XMLUtils; 25 import org.w3c.dom.Element ; 26 27 32 public class BusinessDetailExtHandler extends AbstractHandler 33 { 34 public static final String TAG_NAME = "businessDetailExt"; 35 36 private HandlerMaker maker = null; 37 38 protected BusinessDetailExtHandler(HandlerMaker maker) 39 { 40 this.maker = maker; 41 } 42 43 public RegistryObject unmarshal(Element element) 44 { 45 BusinessDetailExt obj = new BusinessDetailExt(); 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,BusinessEntityExtHandler.TAG_NAME); 70 for (int i=0; i<nodeList.size(); i++) 71 { 72 handler = maker.lookup(BusinessEntityExtHandler.TAG_NAME); 73 obj.addBusinessEntityExt((BusinessEntityExt)handler.unmarshal((Element )nodeList.elementAt(i))); 74 } 75 76 return obj; 77 } 78 79 public void marshal(RegistryObject object,Element parent) 80 { 81 BusinessDetailExt detail = (BusinessDetailExt)object; 82 Element element = parent.getOwnerDocument().createElementNS(null,TAG_NAME); 83 AbstractHandler handler = null; 84 85 String generic = detail.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 = detail.getOperator(); 104 if (operator != null) 105 element.setAttribute("operator",operator); 106 else 107 element.setAttribute("operator",""); 108 109 boolean truncated = detail.isTruncated(); 110 if (truncated) 111 element.setAttribute("truncated","true"); 112 113 Vector vector = detail.getBusinessEntityExtVector(); 114 if ((vector!=null) && (vector.size() > 0)) 115 { 116 handler = maker.lookup(BusinessEntityExtHandler.TAG_NAME); 117 for (int i=0; i < vector.size(); i++) 118 handler.marshal((BusinessEntityExt)vector.elementAt(i),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 |