KickJava   Java API By Example, From Geeks To Geeks.

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


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 businessList 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 is a report - a list of businesses in short form.
35  * This message is the response to a find_businessEntity query.
36  *
37  * @author David Melgar (dmelgar@us.ibm.com)
38  * @author Ozzy (ozzy@hursley.ibm.com)
39  */

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

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

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

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

140
141    public void saveToXML(Element parent) {
142       base = parent.getOwnerDocument().createElement(UDDI_TAG);
143       // Save attributes
144
base.setAttribute("generic", UDDIElement.GENERIC);
145       base.setAttribute("xmlns", UDDIElement.XMLNS);
146       if (operator!=null) {
147          base.setAttribute("operator", operator);
148       }
149       if (truncated!=null) {
150          base.setAttribute("truncated", truncated);
151       }
152       if (businessInfos!=null) {
153          businessInfos.saveToXML(base);
154       }
155       parent.appendChild(base);
156    }
157 }
158
Popular Tags