KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > uddi4j > datatype > service > BusinessServices


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.datatype.service;
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 businessServices element within the UDDI version 2.0 schema.
20  * This class contains the following types of methods:
21  *
22  * <ul>
23  * <li>Constructor passing required fields.
24  * <li>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>SaveToXML method. Serializes this class within a passed in 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>Service element. Accessor collection point for businessService data.
36  *
37  * @author David Melgar (dmelgar@us.ibm.com)
38  * @author Vivek Chopra (vivek@soaprpc.com)
39  */

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

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

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

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

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

99    public void add (BusinessService b) {
100       businessService.add (b);
101    }
102
103    /**
104     * Remove a BusinessService object from the collection
105     * @param b BusinessService 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 (BusinessService b) {
110       return businessService.remove (b);
111    }
112
113    /**
114     * Retrieve the BusinessService at the specified index within the collection.
115     * @param index Index to retrieve from.
116     * @return BusinessService at that index
117     */

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

126    public int size () {
127       return businessService.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    public void saveToXML(Element parent) {
140       base = parent.getOwnerDocument().createElement(UDDI_TAG);
141       // Save attributes
142
if (businessService!=null) {
143         for (int i=0; i < businessService.size(); i++) {
144            ((BusinessService)(businessService.elementAt(i))).saveToXML(base);
145         }
146       }
147       parent.appendChild(base);
148    }
149 }
150
Popular Tags