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.OverviewURL; 23 import org.apache.juddi.datatype.RegistryObject; 24 import org.apache.juddi.util.xml.XMLUtils; 25 import org.w3c.dom.Element ; 26 27 33 public class OverviewDocHandler extends AbstractHandler 34 { 35 public static final String TAG_NAME = "overviewDoc"; 36 37 private HandlerMaker maker = null; 38 39 protected OverviewDocHandler(HandlerMaker maker) 40 { 41 this.maker = maker; 42 } 43 44 public RegistryObject unmarshal(Element element) 45 { 46 OverviewDoc obj = new OverviewDoc(); 47 Vector nodeList = null; 48 AbstractHandler handler = null; 49 50 53 56 nodeList = XMLUtils.getChildElementsByTagName(element,DescriptionHandler.TAG_NAME); 58 for (int i=0; i<nodeList.size(); i++) 59 { 60 handler = maker.lookup(DescriptionHandler.TAG_NAME); 61 Description descr = (Description)handler.unmarshal((Element )nodeList.elementAt(i)); 62 if (descr != null) 63 obj.addDescription(descr); 64 } 65 66 nodeList = XMLUtils.getChildElementsByTagName(element,OverviewURLHandler.TAG_NAME); 67 if (nodeList.size() > 0) 68 { 69 handler = maker.lookup(OverviewURLHandler.TAG_NAME); 70 obj.setOverviewURL((OverviewURL)handler.unmarshal((Element )nodeList.elementAt(0))); 71 } 72 73 return obj; 74 } 75 76 public void marshal(RegistryObject object,Element parent) 77 { 78 OverviewDoc overDoc = (OverviewDoc)object; 79 Element element = parent.getOwnerDocument().createElementNS(null,TAG_NAME); 80 AbstractHandler handler = null; 81 82 Vector descrVector = overDoc.getDescriptionVector(); 83 if ((descrVector!=null) && (descrVector.size() > 0)) 84 { 85 handler = maker.lookup(DescriptionHandler.TAG_NAME); 86 for (int i=0; i < descrVector.size(); i++) 87 handler.marshal((Description)descrVector.elementAt(i),element); 88 } 89 90 OverviewURL overURL = overDoc.getOverviewURL(); 91 if (overURL != null) 92 { 93 handler = maker.lookup(OverviewURLHandler.TAG_NAME); 94 handler.marshal(overURL,element); 95 } 96 97 parent.appendChild(element); 98 } 99 100 101 102 103 104 105 106 public static void main(String args[]) 107 throws Exception 108 { 109 } 110 } | Popular Tags |