KickJava   Java API By Example, From Geeks To Geeks.

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


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.Description;
21 import org.apache.juddi.datatype.OverviewDoc;
22 import org.apache.juddi.datatype.OverviewURL;
23 import org.apache.juddi.datatype.RegistryObject;
24 import org.apache.juddi.util.xml.XMLUtils;
25 import org.w3c.dom.Element JavaDoc;
26
27 /**
28  * "Knows about the creation and populating of OverviewDoc objects.
29  * Returns OverviewDoc."
30  *
31  * @author Steve Viens (sviens@apache.org)
32  */

33 public class OverviewDocHandler extends AbstractHandler
34 {
35   public static final String JavaDoc TAG_NAME = "overviewDoc";
36
37   private HandlerMaker maker = null;
38
39   protected OverviewDocHandler(HandlerMaker maker)
40   {
41     this.maker = maker;
42   }
43
44   public RegistryObject unmarshal(Element JavaDoc element)
45   {
46     OverviewDoc obj = new OverviewDoc();
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,DescriptionHandler.TAG_NAME);
58     for (int i=0; i<nodeList.size(); i++)
59     {
60       handler = maker.lookup(DescriptionHandler.TAG_NAME);
61       Description descr = (Description)handler.unmarshal((Element JavaDoc)nodeList.elementAt(i));
62       if (descr != null)
63         obj.addDescription(descr);
64     }
65
66     nodeList = XMLUtils.getChildElementsByTagName(element,OverviewURLHandler.TAG_NAME);
67     if (nodeList.size() > 0)
68     {
69       handler = maker.lookup(OverviewURLHandler.TAG_NAME);
70       obj.setOverviewURL((OverviewURL)handler.unmarshal((Element JavaDoc)nodeList.elementAt(0)));
71     }
72
73     return obj;
74   }
75
76   public void marshal(RegistryObject object,Element JavaDoc parent)
77   {
78     OverviewDoc overDoc = (OverviewDoc)object;
79     Element JavaDoc element = parent.getOwnerDocument().createElementNS(null,TAG_NAME);
80     AbstractHandler handler = null;
81
82     Vector JavaDoc descrVector = overDoc.getDescriptionVector();
83     if ((descrVector!=null) && (descrVector.size() > 0))
84     {
85       handler = maker.lookup(DescriptionHandler.TAG_NAME);
86       for (int i=0; i < descrVector.size(); i++)
87         handler.marshal((Description)descrVector.elementAt(i),element);
88     }
89
90     OverviewURL overURL = overDoc.getOverviewURL();
91     if (overURL != null)
92     {
93       handler = maker.lookup(OverviewURLHandler.TAG_NAME);
94       handler.marshal(overURL,element);
95     }
96
97     parent.appendChild(element);
98   }
99
100
101   /***************************************************************************/
102   /***************************** TEST DRIVER *********************************/
103   /***************************************************************************/
104
105
106   public static void main(String JavaDoc args[])
107     throws Exception JavaDoc
108   {
109   }
110 }
Popular Tags