KickJava   Java API By Example, From Geeks To Geeks.

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


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 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 relatedBusinessInfos 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>This is a response message that contains a set of one or more RelatedBusinessInfo
37  * structures.
38  *
39  * @author Ravi Trivedi (ravi_trivedi@hp.com)
40  * @author Vivek Chopra (vivek@soaprpc.com)
41  */

42 public class RelatedBusinessInfos extends UDDIElement {
43
44    public static final String JavaDoc UDDI_TAG = "relatedBusinessInfos";
45
46    protected Element base = null;
47
48    // Vector of RelatedBusinessInfo objects
49
Vector JavaDoc relatedBusinessInfo = new Vector JavaDoc();
50
51    /**
52     * Default constructor.
53     * Avoid using the default constructor for validation. It does not validate
54     * required fields. Instead, use the required fields constructor to perform
55     * validation.
56     */

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

72
73    public RelatedBusinessInfos(Element base) throws UDDIException {
74         // Check if it is a fault. Throws an exception if it is.
75
super(base);
76          NodeList JavaDoc nl = null;
77          nl = getChildElementsByTagName(base, RelatedBusinessInfo.UDDI_TAG);
78          for (int i=0; i < nl.getLength(); i++) {
79             relatedBusinessInfo.addElement(new RelatedBusinessInfo((Element)nl.item(i)));
80          }
81    }
82
83    /**
84     * Construct the object with required fields.
85     *
86     * @param relatedBusinessInfo Vector
87     */

88    public RelatedBusinessInfos(Vector JavaDoc relatedBusinessInfo) {
89        this.relatedBusinessInfo = relatedBusinessInfo;
90    }
91
92    public Vector JavaDoc getRelatedBusinessInfoVector() {
93        return this.relatedBusinessInfo;
94    }
95
96    public void setRelatedBusinessInfoVector(Vector JavaDoc relatedBusinessInfo) {
97        this.relatedBusinessInfo = relatedBusinessInfo;
98    }
99
100    /**
101     * Add a RelatedBusinessInfo object to the collection
102     * @param r RelatedBusinessInfo to be added
103     */

104    public void add (RelatedBusinessInfo r) {
105       relatedBusinessInfo.add (r);
106    }
107
108    /**
109     * Remove a RelatedBusinessInfo object from the collection
110     * @param r RelatedBusinessInfo to be removed
111     * @return True if object was removed, false if it
112     * was not found in the collection.
113     */

114    public boolean remove (RelatedBusinessInfo r) {
115       return relatedBusinessInfo.remove (r);
116    }
117
118    /**
119     * Retrieve the RelatedBusinessInfo at the specified index within the collection.
120     * @param index Index to retrieve from.
121     * @return RelatedBusinessInfo at that index
122     */

123    public RelatedBusinessInfo get (int index) {
124       return (RelatedBusinessInfo) relatedBusinessInfo.get (index);
125    }
126
127    /**
128     * Return current size of the collection.
129     * @return Number of RelatedBusinessInfos in the collection
130     */

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

144
145    public void saveToXML(Element parent) {
146          base = parent.getOwnerDocument().createElement(UDDI_TAG);
147          // Save attributes
148
if (relatedBusinessInfo!=null) {
149             for (int i=0; i < relatedBusinessInfo.size(); i++) {
150                ((RelatedBusinessInfo)(relatedBusinessInfo.elementAt(i))).saveToXML(base);
151             }
152          }
153          parent.appendChild(base);
154
155    }
156 }
157
Popular Tags