KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > juddi > handler > KeysOwnedHandler


1 /*
2  * Copyright 2001-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.apache.juddi.handler;
17
18 import java.util.Vector JavaDoc;
19
20 import javax.xml.soap.SOAPElement JavaDoc;
21 import javax.xml.soap.SOAPException JavaDoc;
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 JavaDoc;
27
28 /**
29  * @author Steve Viens (sviens@apache.org)
30  */

31 public class KeysOwnedHandler extends AbstractHandler
32 {
33   public static final String JavaDoc TAG_NAME = "keysOwned";
34   private static final String JavaDoc FROM_KEY_TAG_NAME = "fromKey";
35   private static final String JavaDoc TO_KEY_TAG_NAME = "toKey";
36
37   private HandlerMaker maker = null;
38
39   protected KeysOwnedHandler(HandlerMaker maker)
40   {
41     this.maker = maker;
42   }
43
44   public RegistryObject unmarshal(Element JavaDoc element)
45   {
46     KeysOwned obj = new KeysOwned();
47     Vector JavaDoc nodeList = null;
48     AbstractHandler handler = null;
49
50     // Attributes
51
// {none}
52

53     // Text Node Value
54
// {none}
55

56     // Child Elements
57
nodeList = XMLUtils.getChildElementsByTagName(element,FROM_KEY_TAG_NAME);
58     if (nodeList.size() > 0)
59     {
60       Element JavaDoc keyElement = (Element JavaDoc)nodeList.elementAt(0);
61       obj.setFromKey(XMLUtils.getText(keyElement));
62     }
63
64     nodeList = XMLUtils.getChildElementsByTagName(element,TO_KEY_TAG_NAME);
65     if (nodeList.size() > 0)
66     {
67       Element JavaDoc keyElement = (Element JavaDoc)nodeList.elementAt(0);
68       obj.setToKey(XMLUtils.getText(keyElement));
69     }
70
71     return obj;
72   }
73
74   public void marshal(RegistryObject object,Element JavaDoc parent)
75   {
76     KeysOwned keysOwned = (KeysOwned)object;
77     Element JavaDoc element = parent.getOwnerDocument().createElementNS(null,TAG_NAME);
78     AbstractHandler handler = null;
79
80     String JavaDoc fromKey = keysOwned.getFromKey();
81     if ((fromKey != null) && (fromKey.length() > 0))
82     {
83       Element JavaDoc keyElement = parent.getOwnerDocument().createElement(FROM_KEY_TAG_NAME);
84       keyElement.appendChild(parent.getOwnerDocument().createTextNode(fromKey));
85       element.appendChild(keyElement);
86     }
87
88     String JavaDoc toKey = keysOwned.getToKey();
89     if ((toKey != null) && (toKey.length() > 0))
90     {
91       Element JavaDoc keyElement = parent.getOwnerDocument().createElement(TO_KEY_TAG_NAME);
92       keyElement.appendChild(parent.getOwnerDocument().createTextNode(toKey));
93       element.appendChild(keyElement);
94     }
95
96     parent.appendChild(element);
97   }
98
99   public RegistryObject unmarshal(SOAPElement JavaDoc element)
100   {
101     return null;
102   }
103
104   public void marshal(RegistryObject object,SOAPElement JavaDoc parent)
105     throws SOAPException JavaDoc
106   {
107   }
108
109
110   /***************************************************************************/
111   /***************************** TEST DRIVER *********************************/
112   /***************************************************************************/
113
114
115   public static void main(String JavaDoc args[])
116     throws Exception JavaDoc
117   {
118   }
119 }
120
Popular Tags