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.binding.InstanceParms;
20 import org.apache.juddi.util.xml.XMLUtils;
21 import org.w3c.dom.Element;
22
23 /***
24 * "Knows about the creation and populating of InstanceParms objects.
25 * Returns InstanceParms."
26 *
27 * @author Steve Viens (sviens@apache.org)
28 */
29 public class InstanceParmsHandler extends AbstractHandler
30 {
31 public static final String TAG_NAME = "instanceParms";
32
33 protected InstanceParmsHandler(HandlerMaker maker)
34 {
35 }
36
37 public RegistryObject unmarshal(Element element)
38 {
39 InstanceParms obj = new InstanceParms();
40
41
42
43
44
45 obj.setText(XMLUtils.getText(element));
46
47
48
49
50 return obj;
51 }
52
53 public void marshal(RegistryObject object,Element parent)
54 {
55 InstanceParms parms = (InstanceParms)object;
56 String generic = getGeneric(null);
57 String namespace = getUDDINamespace(generic);
58 Element element = parent.getOwnerDocument().createElementNS(namespace,TAG_NAME);
59
60 String parmsValue = parms.getValue();
61 if (parmsValue != null)
62 element.appendChild(parent.getOwnerDocument().createTextNode(parmsValue));
63
64 parent.appendChild(element);
65 }
66
67
68 /****************************************************************************/
69 /****************************** TEST DRIVER *********************************/
70 /****************************************************************************/
71
72
73 public static void main(String args[])
74 throws Exception
75 {
76 HandlerMaker maker = HandlerMaker.getInstance();
77 AbstractHandler handler = maker.lookup(InstanceParmsHandler.TAG_NAME);
78 Element parent = XMLUtils.newRootElement();
79 Element child = null;
80
81 InstanceParms instParms = new InstanceParms();
82 instParms.setText("iParms-whatever");
83
84 System.out.println();
85
86 RegistryObject regObject = instParms;
87 handler.marshal(regObject,parent);
88 child = (Element)parent.getFirstChild();
89 parent.removeChild(child);
90 XMLUtils.writeXML(child,System.out);
91
92 System.out.println();
93
94 regObject = handler.unmarshal(child);
95 handler.marshal(regObject,parent);
96 child = (Element)parent.getFirstChild();
97 parent.removeChild(child);
98 XMLUtils.writeXML(child,System.out);
99 }
100 }