KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > uddi4j > response > BindingDetail


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.response;
10
11 import java.util.Vector JavaDoc;
12
13 import org.uddi4j.UDDIElement;
14 import org.uddi4j.UDDIException;
15 import org.uddi4j.datatype.binding.BindingTemplate;
16 import org.w3c.dom.Element JavaDoc;
17 import org.w3c.dom.NodeList JavaDoc;
18
19 /**
20  * Represents the bindingDetail element within the UDDI version 2.0 schema.
21  * This class contains the following types of methods:
22  *
23  * <ul>
24  * <li>A constructor that passes the required fields.
25  * <li>A Constructor that will instantiate the object from an appropriate XML
26  * DOM element.
27  * <li>Get/set methods for each attribute that this element can contain.
28  * <li>A get/setVector method is provided for sets of attributes.
29  * <li>A SaveToXML method that serializes this class within a passed in
30  * element.
31  * </ul>
32  *
33  * Typically, this class is used to construct parameters for, or interpret
34  * responses from, methods in the UDDIProxy class.
35  *
36  * <p><b>Element description:</b>
37  * <p>This message is used to return a BindingDetail in response
38  * to a "get_bindingDetail" message.
39  *
40  * @author David Melgar (dmelgar@us.ibm.com)
41  * @author Ozzy (ozzy@hursley.ibm.com)
42  */

43 public class BindingDetail extends UDDIElement {
44    public static final String JavaDoc UDDI_TAG = "bindingDetail";
45
46    protected Element base = null;
47
48    String JavaDoc operator = null;
49    String JavaDoc truncated = null;
50    // Vector of BindingTemplate objects
51
Vector JavaDoc bindingTemplate = new Vector JavaDoc();
52
53    /**
54     * Default constructor.
55     * Avoid using the default constructor for validation. It does not validate
56     * required fields. Instead, use the required fields constructor to perform
57     * validation.
58     */

59
60    public BindingDetail() {
61    }
62
63    /**
64     * Construct the object with required fields.
65     *
66     * @param operator String
67     */

68    public BindingDetail(String JavaDoc operator) {
69       this.operator = operator;
70    }
71
72    /**
73     * Construct the object from a DOM tree. Used by
74     * UDDIProxy to construct an object from a received UDDI
75     * message.
76     *
77     * @param base Element with the name appropriate for this class.
78     *
79     * @exception UDDIException Thrown if DOM tree contains a SOAP fault
80     * or a disposition report indicating a UDDI error.
81     */

82
83    public BindingDetail(Element base) throws UDDIException {
84       // Check if it is a fault. Throws an exception if it is.
85
super(base);
86       operator = base.getAttribute("operator");
87       truncated = base.getAttribute("truncated");
88       NodeList JavaDoc nl = null;
89       nl = getChildElementsByTagName(base, BindingTemplate.UDDI_TAG);
90       for (int i=0; i < nl.getLength(); i++) {
91          bindingTemplate.addElement(new BindingTemplate((Element)nl.item(i)));
92       }
93    }
94
95    public void setOperator(String JavaDoc s) {
96       operator = s;
97    }
98
99    public void setTruncated(String JavaDoc s) {
100       truncated = s;
101    }
102    public void setTruncated(boolean s) {
103       if (s) {
104          truncated = "true";
105       } else {
106          truncated = "false";
107       }
108    }
109
110    /**
111     * Set bindingTemplate vector
112     *
113     * @param s Vector of <I>BindingTemplate</I> objects.
114     */

115    public void setBindingTemplateVector(Vector JavaDoc s) {
116       bindingTemplate = s;
117    }
118
119    public String JavaDoc getOperator() {
120       return operator;
121    }
122
123
124    public String JavaDoc getTruncated() {
125       return truncated;
126    }
127
128    public boolean getTruncatedBoolean() {
129       return "true".equals(truncated);
130    }
131
132    /**
133     * Get bindingTemplate
134     *
135     * @return s Vector of <I>BindingTemplate</I> objects.
136     */

137    public Vector JavaDoc getBindingTemplateVector() {
138       return bindingTemplate;
139    }
140
141    /**
142     * Save an object to the DOM tree. Used to serialize an object
143     * to a DOM tree, usually to send a UDDI message.
144     *
145     * <BR>Used by UDDIProxy.
146     *
147     * @param parent Object will serialize as a child element under the
148     * passed in parent element.
149     */

150
151    public void saveToXML(Element parent) {
152       base = parent.getOwnerDocument().createElement(UDDI_TAG);
153       // Save attributes
154
base.setAttribute("generic", UDDIElement.GENERIC);
155       base.setAttribute("xmlns", UDDIElement.XMLNS);
156       if (operator!=null) {
157          base.setAttribute("operator", operator);
158       }
159       if (truncated!=null) {
160          base.setAttribute("truncated", truncated);
161       }
162       if (bindingTemplate!=null) {
163          for (int i=0; i < bindingTemplate.size(); i++) {
164             ((BindingTemplate)(bindingTemplate.elementAt(i))).saveToXML(base);
165          }
166       }
167       parent.appendChild(base);
168    }
169 }
170
Popular Tags