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