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.TModelInfos; 23 import org.apache.juddi.datatype.response.TModelList; 24 import org.apache.juddi.util.xml.XMLUtils; 25 import org.w3c.dom.Element ; 26 27 33 public class TModelListHandler extends AbstractHandler 34 { 35 public static final String TAG_NAME = "tModelList"; 36 37 private HandlerMaker maker = null; 38 39 protected TModelListHandler(HandlerMaker maker) 40 { 41 this.maker = maker; 42 } 43 44 public RegistryObject unmarshal(Element element) 45 { 46 TModelList obj = new TModelList(); 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,TModelInfosHandler.TAG_NAME); 71 if (nodeList.size() > 0) 72 { 73 handler = maker.lookup(TModelInfosHandler.TAG_NAME); 74 obj.setTModelInfos((TModelInfos)handler.unmarshal((Element )nodeList.elementAt(0))); 75 } 76 77 return obj; 78 } 79 80 public void marshal(RegistryObject object,Element parent) 81 { 82 TModelList list = (TModelList)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 TModelInfos infos = list.getTModelInfos(); 115 if (infos != null) 116 { 117 handler = maker.lookup(TModelInfosHandler.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 |