KickJava   Java API By Example, From Geeks To Geeks.

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


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.w3c.dom.Element JavaDoc;
16 import org.w3c.dom.NodeList JavaDoc;
17
18 /**
19  * Represents the businessInfos element within the UDDI version 2.0 schema.
20  * This class contains the following types of methods:
21  *
22  * <ul>
23  * <li>A constructor that passes the required fields.
24  * <li>A Constructor that will instantiate the object from an appropriate XML
25  * DOM element.
26  * <li>Get/set methods for each attribute that this element can contain.
27  * <li>A get/setVector method is provided for sets of attributes.
28  * <li>A SaveToXML method that serializes this class within a passed in
29  * element.
30  * </ul>
31  *
32  * Typically, this class is used to construct parameters for, or interpret
33  * responses from, methods in the UDDIProxy class.
34  *
35  * <p><b>Element description:</b>
36  * <p>An accessor container for one or more businessInfo structures.
37  *
38  * @author David Melgar (dmelgar@us.ibm.com)
39  * @author Vivek Chopra (vivek@soaprpc.com)
40  */

41 public class BusinessInfos extends UDDIElement {
42    public static final String JavaDoc UDDI_TAG = "businessInfos";
43
44    protected Element base = null;
45
46    // Vector of BusinessInfo objects
47
Vector JavaDoc businessInfo = new Vector JavaDoc();
48
49    /**
50     * Default constructor.
51     *
52     */

53    public BusinessInfos() {
54    }
55
56    /**
57     * Construct the object from a DOM tree. Used by
58     * UDDIProxy to construct an object from a received UDDI
59     * message.
60     *
61     * @param base Element with the name appropriate for this class.
62     *
63     * @exception UDDIException Thrown if DOM tree contains a SOAP fault
64     * or a disposition report indicating a UDDI error.
65     */

66
67    public BusinessInfos(Element base) throws UDDIException {
68       // Check if it is a fault. Throws an exception if it is.
69
super(base);
70       NodeList JavaDoc nl = null;
71       nl = getChildElementsByTagName(base, BusinessInfo.UDDI_TAG);
72       for (int i=0; i < nl.getLength(); i++) {
73          businessInfo.addElement(new BusinessInfo((Element)nl.item(i)));
74       }
75    }
76
77    /**
78     * Set businessInfo vector
79     *
80     * @param s Vector of <I>BusinessInfo</I> objects.
81     */

82    public void setBusinessInfoVector(Vector JavaDoc s) {
83       businessInfo = s;
84    }
85
86    /**
87     * Get businessInfo
88     *
89     * @return s Vector of <I>BusinessInfo</I> objects.
90     */

91    public Vector JavaDoc getBusinessInfoVector() {
92       return businessInfo;
93    }
94
95    /**
96     * Add a BusinessInfo object to the collection
97     * @param b BusinessInfo to be added
98     */

99    public void add (BusinessInfo b) {
100       businessInfo.add (b);
101    }
102
103    /**
104     * Remove a BusinessInfo object from the collection
105     * @param b BusinessInfo to be removed
106     * @return True if object was removed, false if it
107     * was not found in the collection.
108     */

109    public boolean remove (BusinessInfo b) {
110       return businessInfo.remove (b);
111    }
112
113    /**
114     * Retrieve the BusinessInfo at the specified index within the collection.
115     * @param index Index to retrieve from.
116     * @return BusinessInfo at that index
117     */

118    public BusinessInfo get (int index) {
119       return (BusinessInfo) businessInfo.get (index);
120    }
121
122    /**
123     * Return current size of the collection.
124     * @return Number of BusinessInfos in the collection
125     */

126    public int size () {
127       return businessInfo.size ();
128    }
129
130    /**
131     * Save an object to the DOM tree. Used to serialize an object
132     * to a DOM tree, usually to send a UDDI message.
133     *
134     * <BR>Used by UDDIProxy.
135     *
136     * @param parent Object will serialize as a child element under the
137     * passed in parent element.
138     */

139
140    public void saveToXML(Element parent) {
141       base = parent.getOwnerDocument().createElement(UDDI_TAG);
142       // Save attributes
143
if (businessInfo!=null) {
144          for (int i=0; i < businessInfo.size(); i++) {
145             ((BusinessInfo)(businessInfo.elementAt(i))).saveToXML(base);
146          }
147       }
148       parent.appendChild(base);
149    }
150 }
151
Popular Tags