1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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 /***
24 * @author Steve Viens (sviens@apache.org)
25 */
26 public class CompletionStatusHandler extends AbstractHandler
27 {
28 public static final String TAG_NAME = "completionStatus";
29
30 protected CompletionStatusHandler(HandlerMaker maker)
31 {
32 }
33
34 public RegistryObject unmarshal(Element element)
35 {
36 CompletionStatus obj = new CompletionStatus();
37
38
39
40
41
42 obj.setValue(XMLUtils.getText(element));
43
44
45
46
47 return obj;
48 }
49
50 public void marshal(RegistryObject object,Element parent)
51 {
52 CompletionStatus status = (CompletionStatus)object;
53 String generic = getGeneric(null);
54 String namespace = getUDDINamespace(generic);
55 Element element = parent.getOwnerDocument().createElementNS(namespace,TAG_NAME);
56
57 String statusValue = status.getValue();
58 if (statusValue != null)
59 element.appendChild(parent.getOwnerDocument().createTextNode(statusValue));
60
61 parent.appendChild(element);
62 }
63
64
65 /****************************************************************************/
66 /****************************** TEST DRIVER *********************************/
67 /****************************************************************************/
68
69
70 public static void main(String args[])
71 throws Exception
72 {
73 HandlerMaker maker = HandlerMaker.getInstance();
74 AbstractHandler handler = maker.lookup(CompletionStatusHandler.TAG_NAME);
75
76 Element parent = XMLUtils.newRootElement();
77 Element child = null;
78
79 CompletionStatus status = new CompletionStatus();
80 status.setValue(CompletionStatus.FROMKEY_INCOMPLETE);
81
82 System.out.println();
83
84 RegistryObject regObject = status;
85 handler.marshal(regObject,parent);
86 child = (Element)parent.getFirstChild();
87 parent.removeChild(child);
88 XMLUtils.writeXML(child,System.out);
89
90 System.out.println();
91
92 regObject = handler.unmarshal(child);
93 handler.marshal(regObject,parent);
94 child = (Element)parent.getFirstChild();
95 parent.removeChild(child);
96 XMLUtils.writeXML(child,System.out);
97 }
98 }