1 16 package org.apache.juddi.handler; 17 18 import java.util.Vector ; 19 20 import org.apache.juddi.datatype.RegistryObject; 21 import org.apache.juddi.datatype.request.GetRegistryInfo; 22 import org.apache.juddi.util.xml.XMLUtils; 23 import org.w3c.dom.Element ; 24 25 28 public class GetRegistryInfoHandler extends AbstractHandler 29 { 30 public static final String TAG_NAME = "get_registryInfo"; 31 32 private HandlerMaker maker = null; 33 34 protected GetRegistryInfoHandler(HandlerMaker maker) 35 { 36 this.maker = maker; 37 } 38 39 public RegistryObject unmarshal(Element element) 40 { 41 GetRegistryInfo obj = new GetRegistryInfo(); 42 Vector nodeList = null; 43 AbstractHandler handler = null; 44 45 String generic = element.getAttribute("generic"); 47 if ((generic != null && (generic.trim().length() > 0))) 48 obj.setGeneric(generic); 49 50 53 56 return obj; 57 } 58 59 public void marshal(RegistryObject object,Element parent) 60 { 61 GetRegistryInfo request = (GetRegistryInfo)object; 62 Element element = parent.getOwnerDocument().createElementNS(null,TAG_NAME); 63 AbstractHandler handler = null; 64 65 String generic = request.getGeneric(); 66 if (generic != null) 67 element.setAttribute("generic",generic); 68 69 parent.appendChild(element); 70 } 71 72 73 74 75 76 77 78 public static void main(String args[]) 79 throws Exception 80 { 81 HandlerMaker maker = HandlerMaker.getInstance(); 82 AbstractHandler handler = maker.lookup(GetRegistryInfoHandler.TAG_NAME); 83 84 Element parent = XMLUtils.newRootElement(); 85 Element child = null; 86 87 GetRegistryInfo service = new GetRegistryInfo(); 88 System.out.println(); 89 90 RegistryObject regObject = service; 91 handler.marshal(regObject,parent); 92 child = (Element )parent.getFirstChild(); 93 parent.removeChild(child); 94 XMLUtils.writeXML(child,System.out); 95 96 System.out.println(); 97 98 regObject = handler.unmarshal(child); 99 handler.marshal(regObject,parent); 100 child = (Element )parent.getFirstChild(); 101 parent.removeChild(child); 102 XMLUtils.writeXML(child,System.out); 103 } 104 } | Popular Tags |