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.OverviewDoc; 22 import org.apache.juddi.datatype.RegistryObject; 23 import org.apache.juddi.datatype.binding.InstanceDetails; 24 import org.apache.juddi.datatype.binding.InstanceParms; 25 import org.apache.juddi.util.xml.XMLUtils; 26 import org.w3c.dom.Element ; 27 28 34 public class InstanceDetailsHandler extends AbstractHandler 35 { 36 public static final String TAG_NAME = "instanceDetails"; 37 38 private HandlerMaker maker = null; 39 40 protected InstanceDetailsHandler(HandlerMaker maker) 41 { 42 this.maker = maker; 43 } 44 45 public RegistryObject unmarshal(Element element) 46 { 47 InstanceDetails obj = new InstanceDetails(); 48 Vector nodeList = null; 49 AbstractHandler handler = null; 50 51 54 57 nodeList = XMLUtils.getChildElementsByTagName(element,DescriptionHandler.TAG_NAME); 59 for (int i=0; i<nodeList.size(); i++) 60 { 61 handler = maker.lookup(DescriptionHandler.TAG_NAME); 62 Description descr = (Description)handler.unmarshal((Element )nodeList.elementAt(i)); 63 if (descr != null) 64 obj.addDescription(descr); 65 } 66 67 nodeList = XMLUtils.getChildElementsByTagName(element,OverviewDocHandler.TAG_NAME); 68 if (nodeList.size() > 0) 69 { 70 handler = maker.lookup(OverviewDocHandler.TAG_NAME); 71 obj.setOverviewDoc((OverviewDoc)handler.unmarshal((Element )nodeList.elementAt(0))); 72 } 73 74 nodeList = XMLUtils.getChildElementsByTagName(element,InstanceParmsHandler.TAG_NAME); 75 if (nodeList.size() > 0) 76 { 77 handler = maker.lookup(InstanceParmsHandler.TAG_NAME); 78 obj.setInstanceParms((InstanceParms)handler.unmarshal((Element )nodeList.elementAt(0))); 79 } 80 81 return obj; 82 } 83 84 public void marshal(RegistryObject object,Element parent) 85 { 86 InstanceDetails instDet = (InstanceDetails)object; 87 Element element = parent.getOwnerDocument().createElementNS(null,TAG_NAME); 88 AbstractHandler handler = null; 89 90 Vector descrVector = instDet.getDescriptionVector(); 91 if ((descrVector!=null) && (descrVector.size() > 0)) 92 { 93 handler = maker.lookup(DescriptionHandler.TAG_NAME); 94 for (int i=0; i < descrVector.size(); i++) 95 handler.marshal((Description)descrVector.elementAt(i),element); 96 } 97 98 OverviewDoc overDoc = instDet.getOverviewDoc(); 99 if (overDoc != null) 100 { 101 handler = maker.lookup(OverviewDocHandler.TAG_NAME); 102 handler.marshal(overDoc,element); 103 } 104 105 InstanceParms instanceParms = instDet.getInstanceParms(); 106 if (instanceParms != null) 107 { 108 handler = maker.lookup(InstanceParmsHandler.TAG_NAME); 109 handler.marshal(instanceParms,element); 110 } 111 112 parent.appendChild(element); 113 } 114 115 116 117 118 119 120 121 public static void main(String args[]) 122 throws Exception 123 { 124 } 125 } | Popular Tags |