1 16 package org.apache.juddi.handler; 17 18 import org.apache.juddi.datatype.RegistryObject; 19 import org.apache.juddi.datatype.binding.InstanceParms; 20 import org.apache.juddi.util.xml.XMLUtils; 21 import org.w3c.dom.Element ; 22 23 29 public class InstanceParmsHandler extends AbstractHandler 30 { 31 public static final String TAG_NAME = "instanceParms"; 32 33 private HandlerMaker maker = null; 34 35 protected InstanceParmsHandler(HandlerMaker maker) 36 { 37 this.maker = maker; 38 } 39 40 public RegistryObject unmarshal(Element element) 41 { 42 InstanceParms obj = new InstanceParms(); 43 44 47 obj.setText(XMLUtils.getText(element)); 49 50 53 return obj; 54 } 55 56 public void marshal(RegistryObject object,Element parent) 57 { 58 InstanceParms parms = (InstanceParms)object; 59 Element element = parent.getOwnerDocument().createElementNS(null,TAG_NAME); 60 61 String parmsValue = parms.getValue(); 62 if (parmsValue != null) 63 element.appendChild(parent.getOwnerDocument().createTextNode(parmsValue)); 64 65 parent.appendChild(element); 66 } 67 68 69 70 71 72 73 74 public static void main(String args[]) 75 throws Exception 76 { 77 HandlerMaker maker = HandlerMaker.getInstance(); 78 AbstractHandler handler = maker.lookup(InstanceParmsHandler.TAG_NAME); 79 Element parent = XMLUtils.newRootElement(); 80 Element child = null; 81 82 InstanceParms instParms = new InstanceParms(); 83 instParms.setText("iParms-whatever"); 84 85 System.out.println(); 86 87 RegistryObject regObject = instParms; 88 handler.marshal(regObject,parent); 89 child = (Element )parent.getFirstChild(); 90 parent.removeChild(child); 91 XMLUtils.writeXML(child,System.out); 92 93 System.out.println(); 94 95 regObject = handler.unmarshal(child); 96 handler.marshal(regObject,parent); 97 child = (Element )parent.getFirstChild(); 98 parent.removeChild(child); 99 XMLUtils.writeXML(child,System.out); 100 } 101 } | Popular Tags |