KickJava   Java API By Example, From Geeks To Geeks.

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


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 org.apache.juddi.datatype.Name;
21 import org.apache.juddi.datatype.RegistryObject;
22 import org.apache.juddi.datatype.response.TModelInfo;
23 import org.apache.juddi.util.xml.XMLUtils;
24 import org.w3c.dom.Element JavaDoc;
25
26 /**
27  * TModelInfosHandler
28  *
29  * @author Steve Viens (sviens@apache.org)
30  */

31 public class TModelInfoHandler extends AbstractHandler
32 {
33   public static final String JavaDoc TAG_NAME = "tModelInfo";
34
35   private HandlerMaker maker = null;
36
37   protected TModelInfoHandler(HandlerMaker maker)
38   {
39     this.maker = maker;
40   }
41
42   public RegistryObject unmarshal(Element JavaDoc element)
43   {
44     TModelInfo obj = new TModelInfo();
45     Vector JavaDoc nodeList = null;
46     AbstractHandler handler = null;
47
48     // Attributes
49
obj.setTModelKey(element.getAttribute("tModelKey"));
50
51     // Text Node Value
52
// [none]
53

54     // Child Elements
55
nodeList = XMLUtils.getChildElementsByTagName(element,NameHandler.TAG_NAME);
56     if (nodeList.size() > 0)
57     {
58       handler = maker.lookup(NameHandler.TAG_NAME);
59       Name name = (Name )handler.unmarshal((Element JavaDoc)nodeList.elementAt(0));
60       if (name != null)
61         obj.setName(name);
62     }
63
64     return obj;
65   }
66
67   public void marshal(RegistryObject object,Element JavaDoc parent)
68   {
69     TModelInfo info = (TModelInfo)object;
70     Element JavaDoc element = parent.getOwnerDocument().createElementNS(null,TAG_NAME);
71     AbstractHandler handler = null;
72
73     String JavaDoc tModelKey = info.getTModelKey();
74     if (tModelKey != null)
75       element.setAttribute("tModelKey",tModelKey);
76
77     Name name = info.getName();
78     if (name != null)
79     {
80       handler = maker.lookup(NameHandler.TAG_NAME);
81       handler.marshal(name,element);
82     }
83
84     parent.appendChild(element);
85   }
86
87
88   /***************************************************************************/
89   /***************************** TEST DRIVER *********************************/
90   /***************************************************************************/
91
92
93   public static void main(String JavaDoc args[])
94     throws Exception JavaDoc
95   {
96   }
97 }
Popular Tags