KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > uddi4j > request > FindBusiness


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  * Copyright (C) 2001, Hewlett-Packard Company
6  * All Rights Reserved.
7  *
8  */

9
10 package org.uddi4j.request;
11
12 import java.util.Vector JavaDoc;
13
14 import org.uddi4j.UDDIElement;
15 import org.uddi4j.UDDIException;
16 import org.uddi4j.datatype.Name;
17 import org.uddi4j.util.CategoryBag;
18 import org.uddi4j.util.DiscoveryURLs;
19 import org.uddi4j.util.FindQualifiers;
20 import org.uddi4j.util.IdentifierBag;
21 import org.uddi4j.util.TModelBag;
22 import org.w3c.dom.Element JavaDoc;
23 import org.w3c.dom.NodeList JavaDoc;
24
25 /**
26  * Represents the find_business element within the UDDI version 2.0 schema.
27  * This class contains the following types of methods:
28  *
29  * <ul>
30  * <li>A constructor that passes the required fields.
31  * <li>A Constructor that will instantiate the object from an appropriate XML
32  * DOM element.
33  * <li>Get/set methods for each attribute that this element can contain.
34  * <li>A get/setVector method is provided for sets of attributes.
35  * <li>A SaveToXML method that serializes this class within a passed in
36  * element.
37  * </ul>
38  *
39  * Typically, this class is used to construct parameters for, or interpret
40  * responses from, methods in the UDDIProxy class.
41  *
42  * <p><b>Element description:</b>
43  * <p>This message is used to search for summary results listing registered
44  * businessEntity data matching specific criteria.
45  *
46  * @author David Melgar (dmelgar@us.ibm.com)
47  * @author Ravi Trivedi (ravi_trivedi@hp.com)
48  * @author Vivek Chopra (vivek@soaprpc.com)
49  * @author Ozzy (ozzy@hursley.ibm.com)
50  */

51 public class FindBusiness extends UDDIElement {
52    public static final String JavaDoc UDDI_TAG = "find_business";
53
54    protected Element base = null;
55
56    String JavaDoc maxRows = null;
57    FindQualifiers findQualifiers = null;
58    IdentifierBag identifierBag = null;
59    CategoryBag categoryBag = null;
60    TModelBag tModelBag = null;
61    DiscoveryURLs discoveryURLs = null;
62    Vector JavaDoc nameVector = new Vector JavaDoc();
63
64    /**
65     * Default constructor.
66     * Avoid using the default constructor for validation. It does not validate
67     * required fields. Instead, use the required fields constructor to perform
68     * validation.
69     */

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

83    public FindBusiness(Element base) throws UDDIException {
84       // Check if it is a fault. Throws an exception if it is.
85
super(base);
86       maxRows = base.getAttribute("maxRows");
87       NodeList JavaDoc nl = null;
88       nl = getChildElementsByTagName(base, FindQualifiers.UDDI_TAG);
89       if (nl.getLength() > 0) {
90          findQualifiers = new FindQualifiers((Element)nl.item(0));
91       }
92       nl = getChildElementsByTagName(base, Name.UDDI_TAG);
93       for (int i=0; i < nl.getLength(); i++) {
94           nameVector.addElement(new Name((Element)nl.item(i)));
95       }
96       nl = getChildElementsByTagName(base, IdentifierBag.UDDI_TAG);
97       if (nl.getLength() > 0) {
98          identifierBag = new IdentifierBag((Element)nl.item(0));
99       }
100       nl = getChildElementsByTagName(base, CategoryBag.UDDI_TAG);
101       if (nl.getLength() > 0) {
102          categoryBag = new CategoryBag((Element)nl.item(0));
103       }
104       nl = getChildElementsByTagName(base, TModelBag.UDDI_TAG);
105       if (nl.getLength() > 0) {
106          tModelBag = new TModelBag((Element)nl.item(0));
107       }
108       nl = getChildElementsByTagName(base, DiscoveryURLs.UDDI_TAG);
109       if (nl.getLength() > 0) {
110          discoveryURLs = new DiscoveryURLs((Element)nl.item(0));
111       }
112    }
113
114    public void setMaxRows(String JavaDoc s) {
115       maxRows = s;
116    }
117    public void setMaxRows(int s) {
118       maxRows = Integer.toString(s);
119    }
120
121    public void setFindQualifiers(FindQualifiers s) {
122       findQualifiers = s;
123    }
124
125    /**
126     * @deprecated This method has been deprecated. Use
127     * {@link #setNameVector(Vector)} or
128     * {@link #setDefaultName(Name)}
129     */

130    public void setName(Name s) {
131       setDefaultName(s);
132    }
133
134    /**
135     * @deprecated This method has been deprecated. Use
136     * {@link #setNameVector(Vector)} or
137     * {@link #setDefaultNameString(String, String)}
138     */

139    public void setName(String JavaDoc s) {
140       setDefaultNameString(s,null);
141    }
142
143    /**
144     * This method stores this name as the Default Name
145     * (i.e., places it in the first location in the Vector)
146     */

147    public void setDefaultName(Name name) {
148       if (nameVector.size() > 0) {
149        nameVector.setElementAt(name,0);
150       } else {
151        nameVector.addElement(name);
152       }
153    }
154
155    /**
156     * This stores this String, in the given language, as the Default Name
157     * (i.e., places it in the first location in the Vector.)
158     */

159    public void setDefaultNameString(String JavaDoc value, String JavaDoc lang) {
160       Name name = new Name(value, lang);
161        if (nameVector.size() > 0) {
162          nameVector.setElementAt(name,0);
163        } else {
164          nameVector.addElement(name);
165        }
166    }
167
168    /**
169     * @param s Vector of <I> Name </I> objects
170     */

171    public void setNameVector(Vector JavaDoc s) {
172       nameVector = s;
173    }
174
175    public void setIdentifierBag(IdentifierBag s) {
176       identifierBag = s;
177    }
178
179    public void setCategoryBag(CategoryBag s) {
180       categoryBag = s;
181    }
182
183    public void setTModelBag(TModelBag s) {
184       tModelBag = s;
185    }
186
187    public void setDiscoveryURLs(DiscoveryURLs s) {
188       discoveryURLs = s;
189    }
190
191    public String JavaDoc getMaxRows() {
192       return maxRows;
193    }
194
195    public int getMaxRowsInt() {
196       return Integer.parseInt(maxRows);
197    }
198
199    public FindQualifiers getFindQualifiers() {
200       return findQualifiers;
201    }
202
203    /**
204     * @deprecated This method has been deprecated. Use
205     * {@link #getNameVector()} or
206     * {@link #getDefaultName()}
207     */

208    public Name getName() {
209       return getDefaultName();
210    }
211
212    /**
213     * @deprecated This method has been deprecated. Use
214     * {@link #getNameVector()} or
215     * {@link #getDefaultNameString()}
216     */

217    public String JavaDoc getNameString() {
218       return getDefaultNameString();
219    }
220
221    public Name getDefaultName() {
222       if(nameVector.size() > 0)
223         return (Name) nameVector.elementAt(0);
224       else
225         return null;
226    }
227
228    public String JavaDoc getDefaultNameString() {
229        if ((nameVector).size() > 0) {
230         return ((Name)nameVector.elementAt(0)).getText();
231        } else {
232            return null;
233        }
234    }
235
236    /**
237     * Get all names.
238     *
239     * @return Vector of <I>Name</I> objects.
240     */

241    public Vector JavaDoc getNameVector() {
242          return nameVector ;
243    }
244
245    public IdentifierBag getIdentifierBag() {
246       return identifierBag;
247    }
248
249
250    public CategoryBag getCategoryBag() {
251       return categoryBag;
252    }
253
254
255    public TModelBag getTModelBag() {
256       return tModelBag;
257    }
258
259
260    public DiscoveryURLs getDiscoveryURLs() {
261       return discoveryURLs;
262    }
263
264
265    /**
266     * Save an object to the DOM tree. Used to serialize an object
267     * to a DOM tree, usually to send a UDDI message.
268     *
269     * <BR>Used by UDDIProxy.
270     *
271     * @param parent Object will serialize as a child element under the
272     * passed in parent element.
273     */

274    public void saveToXML(Element parent) {
275       base = parent.getOwnerDocument().createElement(UDDI_TAG);
276       // Save attributes.
277
base.setAttribute("generic", UDDIElement.GENERIC);
278       base.setAttribute("xmlns", UDDIElement.XMLNS);
279       if (maxRows!=null) {
280          base.setAttribute("maxRows", maxRows);
281       }
282       if (findQualifiers!=null) {
283          findQualifiers.saveToXML(base);
284       }
285       if (nameVector!=null) {
286         for (int i=0; i < nameVector.size(); i++) {
287            ((Name)(nameVector.elementAt(i))).saveToXML(base);
288         }
289       }
290       if (identifierBag!=null) {
291          identifierBag.saveToXML(base);
292       }
293       if (categoryBag!=null) {
294          categoryBag.saveToXML(base);
295       }
296       if (tModelBag!=null) {
297          tModelBag.saveToXML(base);
298       }
299       if (discoveryURLs!=null) {
300          discoveryURLs.saveToXML(base);
301       }
302       parent.appendChild(base);
303    }
304 }
305
Popular Tags