1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.apache.juddi.handler;
17
18 import java.util.Vector;
19
20
21
22
23 import org.apache.juddi.datatype.RegistryObject;
24 import org.apache.juddi.datatype.response.KeysOwned;
25 import org.apache.juddi.util.xml.XMLUtils;
26 import org.w3c.dom.Element;
27
28 /***
29 * @author Steve Viens (sviens@apache.org)
30 */
31 public class KeysOwnedHandler extends AbstractHandler
32 {
33 public static final String TAG_NAME = "keysOwned";
34 private static final String FROM_KEY_TAG_NAME = "fromKey";
35 private static final String TO_KEY_TAG_NAME = "toKey";
36
37 protected KeysOwnedHandler(HandlerMaker maker)
38 {
39 }
40
41 public RegistryObject unmarshal(Element element)
42 {
43 KeysOwned obj = new KeysOwned();
44 Vector nodeList = null;
45
46
47
48
49
50
51
52
53 nodeList = XMLUtils.getChildElementsByTagName(element,FROM_KEY_TAG_NAME);
54 if (nodeList.size() > 0)
55 {
56 Element keyElement = (Element)nodeList.elementAt(0);
57 obj.setFromKey(XMLUtils.getText(keyElement));
58 }
59
60 nodeList = XMLUtils.getChildElementsByTagName(element,TO_KEY_TAG_NAME);
61 if (nodeList.size() > 0)
62 {
63 Element keyElement = (Element)nodeList.elementAt(0);
64 obj.setToKey(XMLUtils.getText(keyElement));
65 }
66
67 return obj;
68 }
69
70 public void marshal(RegistryObject object,Element parent)
71 {
72 KeysOwned keysOwned = (KeysOwned)object;
73 String generic = getGeneric(null);
74 String namespace = getUDDINamespace(generic);
75 Element element = parent.getOwnerDocument().createElementNS(namespace,TAG_NAME);
76
77 String fromKey = keysOwned.getFromKey();
78 if ((fromKey != null) && (fromKey.length() > 0))
79 {
80 Element keyElement = parent.getOwnerDocument().createElement(FROM_KEY_TAG_NAME);
81 keyElement.appendChild(parent.getOwnerDocument().createTextNode(fromKey));
82 element.appendChild(keyElement);
83 }
84
85 String toKey = keysOwned.getToKey();
86 if ((toKey != null) && (toKey.length() > 0))
87 {
88 Element keyElement = parent.getOwnerDocument().createElement(TO_KEY_TAG_NAME);
89 keyElement.appendChild(parent.getOwnerDocument().createTextNode(toKey));
90 element.appendChild(keyElement);
91 }
92
93 parent.appendChild(element);
94 }
95
96
97
98
99
100
101
102
103
104
105
106
107
108 /****************************************************************************/
109 /****************************** TEST DRIVER *********************************/
110 /****************************************************************************/
111
112
113 public static void main(String args[])
114 throws Exception
115 {
116 }
117 }