KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > uddi4j > datatype > binding > InstanceDetails


1 /*
2  * The source code contained herein is licensed under the IBM Public License
3  * Version 1.0, which has been approved by the Open Source Initiative.
4  * Copyright (C) 2001, International Business Machines Corporation
5  * All Rights Reserved.
6  *
7  */

8
9 package org.uddi4j.datatype.binding;
10
11 import java.util.Vector JavaDoc;
12
13 import org.uddi4j.UDDIElement;
14 import org.uddi4j.UDDIException;
15 import org.uddi4j.datatype.Description;
16 import org.uddi4j.datatype.OverviewDoc;
17 import org.w3c.dom.Element JavaDoc;
18 import org.w3c.dom.NodeList JavaDoc;
19
20 /**
21  * Represents the instanceDetails element within the UDDI version 2.0 schema.
22  * This class contains the following types of methods:
23  *
24  * <ul>
25  * <li>Constructor passing required fields.
26  * <li>Constructor that will instantiate the object from an appropriate XML
27  * DOM element.
28  * <li>Get/set methods for each attribute that this element can contain.
29  * <li>A get/setVector method is provided for sets of attributes.
30  * <li>SaveToXML method. Serializes this class within a passed in element.
31  * </ul>
32  * Typically, this class is used to construct parameters for, or interpret
33  * responses from, methods in the UDDIProxy class.
34  *
35  * <p><b>Element description:</b>
36  * <p>Support element used to contain optional information about the way an
37  * instance of a web service is implemented, or varies from the general
38  * specifications outlined in a specific tModel.
39  *
40  * @author David Melgar (dmelgar@us.ibm.com)
41  */

42 public class InstanceDetails extends UDDIElement {
43    public static final String JavaDoc UDDI_TAG = "instanceDetails";
44
45    protected Element base = null;
46
47    OverviewDoc overviewDoc = null;
48    InstanceParms instanceParms = null;
49    // Vector of Description objects
50
Vector JavaDoc description = new Vector JavaDoc();
51
52    /**
53     * Default constructor.
54     * Avoid using the default constructor for validation. It does not validate
55     * required fields. Instead, use the required fields constructor to perform
56     * validation.
57     */

58    public InstanceDetails() {
59    }
60
61    /**
62     * Construct the object from a DOM tree. Used by
63     * UDDIProxy to construct object from received UDDI
64     * message.
65     *
66     * @param base Element with name appropriate for this class.
67     * @exception UDDIException
68     * Thrown if DOM tree contains a SOAP fault or
69     * disposition report indicating a UDDI error.
70     */

71    public InstanceDetails(Element base) throws UDDIException {
72       // Checks if it is a fault. Throw exception if it is a fault.
73
super(base);
74       NodeList JavaDoc nl = null;
75       nl = getChildElementsByTagName(base, OverviewDoc.UDDI_TAG);
76       if (nl.getLength() > 0) {
77          overviewDoc = new OverviewDoc((Element)nl.item(0));
78       }
79       nl = getChildElementsByTagName(base, InstanceParms.UDDI_TAG);
80       if (nl.getLength() > 0) {
81          instanceParms = new InstanceParms((Element)nl.item(0));
82       }
83       nl = getChildElementsByTagName(base, Description.UDDI_TAG);
84       for (int i=0; i < nl.getLength(); i++) {
85          description.addElement(new Description((Element)nl.item(i)));
86       }
87    }
88
89    public void setOverviewDoc(OverviewDoc s) {
90       overviewDoc = s;
91    }
92
93    public void setInstanceParms(InstanceParms s) {
94       instanceParms = s;
95    }
96
97    /**
98     * Set description vector.
99     *
100     * @param s Vector of <I>Description</I> objects.
101     */

102    public void setDescriptionVector(Vector JavaDoc s) {
103       description = s;
104    }
105
106    /**
107     * Set default (english) description string.
108     *
109     * @param s String
110     */

111    public void setDefaultDescriptionString(String JavaDoc s) {
112       if (description.size() > 0) {
113          description.setElementAt(new Description(s), 0);
114       } else {
115          description.addElement(new Description(s));
116       }
117    }
118
119    public OverviewDoc getOverviewDoc() {
120       return overviewDoc;
121    }
122
123
124    public InstanceParms getInstanceParms() {
125       return instanceParms;
126    }
127
128
129    /**
130     * Get description.
131     *
132     * @return s Vector of <I>Description</I> objects.
133     */

134    public Vector JavaDoc getDescriptionVector() {
135       return description;
136    }
137
138    /**
139     * Get default description string.
140     *
141     * @return s String
142     */

143    public String JavaDoc getDefaultDescriptionString() {
144       if ((description).size() > 0) {
145          Description t = (Description)description.elementAt(0);
146          return t.getText();
147       } else {
148          return null;
149       }
150    }
151
152    /**
153     * Save object to DOM tree. Used to serialize object
154     * to a DOM tree, usually to send a UDDI message.
155     *
156     * <BR>Used by UDDIProxy.
157     *
158     * @param parent Object will serialize as a child element under the
159     * passed in parent element.
160     */

161    public void saveToXML(Element parent) {
162       base = parent.getOwnerDocument().createElement(UDDI_TAG);
163       // Save attributes
164
if (description!=null) {
165         for (int i=0; i < description.size(); i++) {
166            ((Description)(description.elementAt(i))).saveToXML(base);
167         }
168       }
169       if (overviewDoc!=null) {
170          overviewDoc.saveToXML(base);
171       }
172       if (instanceParms!=null) {
173          instanceParms.saveToXML(base);
174       }
175       parent.appendChild(base);
176    }
177 }
178
Popular Tags