KickJava   Java API By Example, From Geeks To Geeks.

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


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

40 public class RegisteredInfo extends UDDIElement {
41    public static final String JavaDoc UDDI_TAG = "registeredInfo";
42
43    protected Element base = null;
44
45    String JavaDoc operator = null;
46    String JavaDoc truncated = null;
47    BusinessInfos businessInfos = null;
48    TModelInfos tModelInfos = null;
49
50    /**
51     * Default constructor.
52     * Avoid using the default constructor for validation. It does not validate
53     * required fields. Instead, use the required fields constructor to perform
54     * validation.
55     */

56
57    public RegisteredInfo() {
58    }
59
60    /**
61     * Construct the object with required fields.
62     *
63     * @param operator String
64     * @param businessInfos BusinessInfos object
65     * @param tModelInfos TModelInfos object
66     */

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

85
86    public RegisteredInfo(Element base) throws UDDIException {
87       // Check if it is a fault. Throws an exception if it is.
88
super(base);
89       operator = base.getAttribute("operator");
90       truncated = base.getAttribute("truncated");
91       NodeList JavaDoc nl = null;
92       nl = getChildElementsByTagName(base, BusinessInfos.UDDI_TAG);
93       if (nl.getLength() > 0) {
94          businessInfos = new BusinessInfos((Element)nl.item(0));
95       }
96       nl = getChildElementsByTagName(base, TModelInfos.UDDI_TAG);
97       if (nl.getLength() > 0) {
98          tModelInfos = new TModelInfos((Element)nl.item(0));
99       }
100    }
101
102    public void setOperator(String JavaDoc s) {
103       operator = s;
104    }
105
106    public void setTruncated(String JavaDoc s) {
107       truncated = s;
108    }
109    public void setTruncated(boolean s) {
110       if (s) {
111          truncated = "true";
112       } else {
113          truncated = "false";
114       }
115    }
116
117    public void setBusinessInfos(BusinessInfos s) {
118       businessInfos = s;
119    }
120
121    public void setTModelInfos(TModelInfos s) {
122       tModelInfos = s;
123    }
124
125    public String JavaDoc getOperator() {
126       return operator;
127    }
128
129
130    public String JavaDoc getTruncated() {
131       return truncated;
132    }
133
134    public boolean getTruncatedBoolean() {
135       return "true".equals(truncated);
136    }
137
138    public BusinessInfos getBusinessInfos() {
139       return businessInfos;
140    }
141
142
143    public TModelInfos getTModelInfos() {
144       return tModelInfos;
145    }
146
147
148    /**
149     * Save an object to the DOM tree. Used to serialize an object
150     * to a DOM tree, usually to send a UDDI message.
151     *
152     * <BR>Used by UDDIProxy.
153     *
154     * @param parent Object will serialize as a child element under the
155     * passed in parent element.
156     */

157
158    public void saveToXML(Element parent) {
159       base = parent.getOwnerDocument().createElement(UDDI_TAG);
160       // Save attributes
161
base.setAttribute("generic", UDDIElement.GENERIC);
162       base.setAttribute("xmlns", UDDIElement.XMLNS);
163       if (operator!=null) {
164          base.setAttribute("operator", operator);
165       }
166       if (truncated!=null) {
167          base.setAttribute("truncated", truncated);
168       }
169       if (businessInfos!=null) {
170          businessInfos.saveToXML(base);
171       }
172       if (tModelInfos!=null) {
173          tModelInfos.saveToXML(base);
174       }
175       parent.appendChild(base);
176    }
177 }
178
Popular Tags