1 16 package org.apache.juddi.handler; 17 18 import java.util.Vector ; 19 20 import org.apache.juddi.datatype.Description; 21 import org.apache.juddi.datatype.RegistryObject; 22 import org.apache.juddi.datatype.binding.InstanceDetails; 23 import org.apache.juddi.datatype.binding.TModelInstanceInfo; 24 import org.apache.juddi.util.xml.XMLUtils; 25 import org.w3c.dom.Element ; 26 27 31 public class TModelInstanceInfoHandler extends AbstractHandler 32 { 33 public static final String TAG_NAME = "tModelInstanceInfo"; 34 35 private HandlerMaker maker = null; 36 37 protected TModelInstanceInfoHandler(HandlerMaker maker) 38 { 39 this.maker = maker; 40 } 41 42 public RegistryObject unmarshal(Element element) 43 { 44 TModelInstanceInfo obj = new TModelInstanceInfo(); 45 Vector nodeList = null; 46 AbstractHandler handler = null; 47 48 obj.setTModelKey(element.getAttribute("tModelKey")); 50 51 54 nodeList = XMLUtils.getChildElementsByTagName(element,DescriptionHandler.TAG_NAME); 56 for (int i=0; i<nodeList.size(); i++) 57 { 58 handler = maker.lookup(DescriptionHandler.TAG_NAME); 59 Description descr = (Description)handler.unmarshal((Element )nodeList.elementAt(i)); 60 if (descr != null) 61 obj.addDescription(descr); 62 } 63 64 nodeList = XMLUtils.getChildElementsByTagName(element,InstanceDetailsHandler.TAG_NAME); 65 for (int i=0; i<nodeList.size(); i++) 66 { 67 handler = maker.lookup(InstanceDetailsHandler.TAG_NAME); 68 obj.setInstanceDetails((InstanceDetails)handler.unmarshal((Element )nodeList.elementAt(i))); 69 } 70 71 return obj; 72 } 73 74 public void marshal(RegistryObject object,Element parent) 75 { 76 TModelInstanceInfo tModInstInfo = (TModelInstanceInfo)object; 77 Element element = parent.getOwnerDocument().createElementNS(null,TAG_NAME); 78 AbstractHandler handler = null; 79 80 String tModelKey = tModInstInfo.getTModelKey(); 81 if (tModelKey != null) 82 element.setAttribute("tModelKey",tModelKey); 83 84 Vector descrVector = tModInstInfo.getDescriptionVector(); 85 if ((descrVector!=null) && (descrVector.size() > 0)) 86 { 87 handler = maker.lookup(DescriptionHandler.TAG_NAME); 88 for (int i=0; i < descrVector.size(); i++) 89 handler.marshal((Description)descrVector.elementAt(i),element); 90 } 91 92 InstanceDetails instDet = tModInstInfo.getInstanceDetails(); 93 if (instDet != null) 94 { 95 handler = maker.lookup(InstanceDetailsHandler.TAG_NAME); 96 handler.marshal(instDet,element); 97 } 98 99 parent.appendChild(element); 100 } 101 102 103 104 105 106 107 108 public static void main(String args[]) 109 throws Exception 110 { 111 } 112 } | Popular Tags |