1 16 package org.apache.juddi.handler; 17 18 import org.apache.juddi.datatype.RegistryObject; 19 import org.apache.juddi.datatype.request.FindQualifier; 20 import org.apache.juddi.util.xml.XMLUtils; 21 import org.w3c.dom.Element ; 22 23 24 32 public class FindQualifierHandler extends AbstractHandler 33 { 34 public static final String TAG_NAME = "findQualifier"; 35 36 private HandlerMaker maker = null; 37 38 protected FindQualifierHandler(HandlerMaker maker) 39 { 40 this.maker = maker; 41 } 42 43 public RegistryObject unmarshal(Element element) 44 { 45 FindQualifier obj = new FindQualifier(); 46 47 50 obj.setValue(XMLUtils.getText(element)); 52 53 56 return obj; 57 } 58 59 public void marshal(RegistryObject object,Element parent) 60 { 61 FindQualifier qualifier = (FindQualifier)object; 62 Element element = parent.getOwnerDocument().createElementNS(null,TAG_NAME); 63 64 String qValue = qualifier.getValue(); 65 if (qValue != null) 66 element.appendChild(parent.getOwnerDocument().createTextNode(qValue)); 67 68 parent.appendChild(element); 69 } 70 71 72 73 74 75 76 77 public static void main(String args[]) 78 throws Exception 79 { 80 HandlerMaker maker = HandlerMaker.getInstance(); 81 AbstractHandler handler = maker.lookup(FindQualifierHandler.TAG_NAME); 82 83 Element parent = XMLUtils.newRootElement(); 84 Element child = null; 85 86 FindQualifier qualifier = new FindQualifier(FindQualifier.SORT_BY_NAME_ASC); 87 88 System.out.println(); 89 90 RegistryObject regObject = qualifier; 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 |