KickJava   Java API By Example, From Geeks To Geeks.

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


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, Hewlett-Packard Company
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.uddi4j.util.BusinessKey;
14 import org.w3c.dom.Element JavaDoc;
15 import org.w3c.dom.NodeList JavaDoc;
16
17 /**
18  * Represents the relatedBusinessesList element within the UDDI version 2.0 schema.
19  * This class contains the following types of methods:
20  *
21  * <ul>
22  * <li>A constructor that passes the required fields.
23  * <li>A Constructor that will instantiate the object from an appropriate XML
24  * DOM element.
25  * <li>Get/set methods for each attribute that this element can contain.
26  * <li>A get/setVector method is provided for sets of attributes.
27  * <li>A SaveToXML method that serializes this class within a passed in
28  * element.
29  * </ul>
30  *
31  * Typically, this class is used to construct parameters for, or interpret
32  * responses from, methods in the UDDIProxy class.
33  *
34  * <p><b>Element description:</b>
35  * <p>This structure reports the business relationships that are complete between
36  * the businessEntity, specified in the find_relatedBusinesses message, and
37  * other businessEntity registrations. Business relationships are considered complete,
38  * between two businessEntity registrations, when the publishers controlling each of
39  * the businessEntity structures set assertions affirming the relationship.
40  *
41  * @author Ravi Trivedi (ravi_trivedi@hp.com)
42  * @author Ozzy (ozzy@hursley.ibm.com)
43  */

44 public class RelatedBusinessesList extends UDDIElement
45 {
46
47     public static final String JavaDoc UDDI_TAG = "relatedBusinessesList";
48
49     protected Element base = null;
50
51     String JavaDoc operator = null;
52     String JavaDoc truncated = null;
53     BusinessKey businessKey = null;
54     RelatedBusinessInfos relBusInfos = null;
55
56     /**
57      * Default constructor.
58      * Avoid using the default constructor for validation. It does not validate
59      * required fields. Instead, use the required fields constructor to perform
60      * validation.
61      */

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

77
78     public RelatedBusinessesList(Element base) throws UDDIException
79     {
80         // Check if it is a fault. Throws an exception if it is.
81
super(base);
82         operator = base.getAttribute("operator");
83         truncated = base.getAttribute("truncated");
84         NodeList JavaDoc nl = null;
85         nl = getChildElementsByTagName(base, RelatedBusinessInfos.UDDI_TAG);
86         if (nl.getLength() > 0)
87         {
88             relBusInfos = new RelatedBusinessInfos((Element)nl.item(0));
89         }
90         nl = getChildElementsByTagName(base, BusinessKey.UDDI_TAG);
91         if (nl.getLength() > 0)
92         {
93             businessKey = new BusinessKey((Element)nl.item(0));
94         }
95     }
96
97     /**
98      * Construct the object with required fields.
99      *
100      * @param operator String
101      * @param businessKey String
102      * @param bi RelatedBusinessInfos
103      */

104     public RelatedBusinessesList(String JavaDoc operator, String JavaDoc businessKey, RelatedBusinessInfos bi)
105     {
106         this.operator = operator;
107         this.businessKey = new BusinessKey(businessKey);
108         this.relBusInfos = bi;
109     }
110
111     public String JavaDoc getOperator()
112     {
113         return this.operator;
114     }
115
116     public void setOperator(String JavaDoc s)
117     {
118         this.operator = s;
119     }
120
121     public boolean getTruncatedBoolean()
122     {
123         return "true".equals(truncated);
124     }
125
126     public void setTruncated(boolean s)
127     {
128         if (s)
129         {
130             truncated = "true";
131         }
132         else
133         {
134             truncated = "false";
135         }
136     }
137
138     public String JavaDoc getTruncated()
139     {
140         return truncated;
141     }
142
143     public void setTruncated(String JavaDoc s)
144     {
145         truncated = s;
146     }
147
148     public String JavaDoc getBusinessKey()
149     {
150         return businessKey.getText();
151     }
152
153     public void setBusinessKey(String JavaDoc businessKey)
154     {
155         this.businessKey = new BusinessKey(businessKey);
156     }
157
158     public RelatedBusinessInfos getRelatedBusinessInfos()
159     {
160         return this.relBusInfos;
161     }
162
163     public void setRelatedBusinessInfos(RelatedBusinessInfos r)
164     {
165         this.relBusInfos = r;
166     }
167
168     /**
169      * Save an object to the DOM tree. Used to serialize an object
170      * to a DOM tree, usually to send a UDDI message.
171      *
172      * <BR>Used by UDDIProxy.
173      *
174      * @param parent Object will serialize as a child element under the
175      * passed in parent element.
176      */

177
178     public void saveToXML(Element parent)
179     {
180         base = parent.getOwnerDocument().createElement(UDDI_TAG);
181         // Save attributes
182
base.setAttribute("generic", UDDIElement.GENERIC);
183         base.setAttribute("xmlns", UDDIElement.XMLNS);
184         if (operator != null)
185         {
186             base.setAttribute("operator", operator);
187         }
188         if (truncated != null)
189         {
190             base.setAttribute("truncated", truncated);
191         }
192         if (businessKey != null)
193         {
194             businessKey.saveToXML(base);
195         }
196         if (relBusInfos != null)
197         {
198             relBusInfos.saveToXML(base);
199         }
200         parent.appendChild(base);
201
202     }
203 }
204
Popular Tags