KickJava   Java API By Example, From Geeks To Geeks.

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


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.request;
10
11 import java.util.Vector JavaDoc;
12
13 import org.uddi4j.UDDIElement;
14 import org.uddi4j.UDDIException;
15 import org.uddi4j.util.BusinessKey;
16 import org.w3c.dom.Element JavaDoc;
17 import org.w3c.dom.NodeList JavaDoc;
18
19 /**
20  * Represents the get_businessDetailExt element within the UDDI version 2.0 schema.
21  * This class contains the following types of methods:
22  *
23  * <ul>
24  * <li>A constructor that passes the required fields.
25  * <li>A Constructor that will instantiate the object from an appropriate XML
26  * DOM element.
27  * <li>Get/set methods for each attribute that this element can contain.
28  * <li>A get/setVector method is provided for sets of attributes.
29  * <li>A SaveToXML method that serializes this class within a passed in
30  * element.
31  * </ul>
32  *
33  * Typically, this class is used to construct parameters for, or interpret
34  * responses from, methods in the UDDIProxy class.
35  *
36  * <p><b>Element description:</b>
37  * <p>The extended businessDetail message defines an API that allows non-operator
38  * nodes to provide extended information via a consistent API. This message
39  * is the request that will cause a businessDetailExt message to be returned.
40  *
41  * @author David Melgar (dmelgar@us.ibm.com)
42  */

43 public class GetBusinessDetailExt extends UDDIElement {
44    public static final String JavaDoc UDDI_TAG = "get_businessDetailExt";
45
46    protected Element base = null;
47
48    // Vector of BusinessKey objects
49
Vector JavaDoc businessKey = 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    public GetBusinessDetailExt() {
58    }
59
60    /**
61     * Construct the object with required fields.
62     *
63     * @param businessKeyStrings Vector of BusinessKey Strings.
64     */

65    public GetBusinessDetailExt(Vector JavaDoc businessKeyStrings) {
66       Vector JavaDoc objects;
67       objects = new Vector JavaDoc();
68       for (int i = 0; i < businessKeyStrings.size(); i++) {
69          objects.addElement( new BusinessKey((String JavaDoc)businessKeyStrings.elementAt(i)) );
70       }
71
72       this.businessKey = objects;
73    }
74
75    /**
76     * Construct the object from a DOM tree. Used by
77     * UDDIProxy to construct an object from a received UDDI
78     * message.
79     *
80     * @param base Element with the name appropriate for this class.
81     *
82     * @exception UDDIException Thrown if DOM tree contains a SOAP fault
83     * or a disposition report indicating a UDDI error.
84     */

85    public GetBusinessDetailExt(Element base) throws UDDIException {
86       // Check if it is a fault. Throws an exception if it is.
87
super(base);
88       NodeList JavaDoc nl = null;
89       nl = getChildElementsByTagName(base, BusinessKey.UDDI_TAG);
90       for (int i=0; i < nl.getLength(); i++) {
91          businessKey.addElement(new BusinessKey((Element)nl.item(i)));
92       }
93    }
94
95    /**
96     * Set businessKey vector.
97     *
98     * @param s Vector of <I>BusinessKey</I> objects.
99     */

100    public void setBusinessKeyVector(Vector JavaDoc s) {
101       businessKey = s;
102    }
103
104    /**
105     * Set businessKey.
106     *
107     * @param s Vector of <I>String</I> objects.
108     */

109    public void setBusinessKeyStrings(Vector JavaDoc s) {
110       businessKey = new Vector JavaDoc();
111       for (int i = 0; i < s.size(); i++) {
112          businessKey.addElement( new BusinessKey((String JavaDoc)s.elementAt(i)) );
113       }
114    }
115
116    /**
117     * Get businessKey vector.
118     *
119     * @return s Vector of <I>BusinessKey</I> objects.
120     */

121    public Vector JavaDoc getBusinessKeyVector() {
122       return businessKey;
123    }
124
125    /**
126     * Get businessKey.
127     *
128     * @return s Vector of <I>String</I> objects.
129     */

130    public Vector JavaDoc getBusinessKeyStrings() {
131       Vector JavaDoc strings = new Vector JavaDoc();
132       for (int i = 0; i < businessKey.size(); i++) {
133          strings.addElement( ((BusinessKey)businessKey.elementAt(i)).getText());
134       }
135       return strings;
136    }
137
138    /**
139     * Save an object to the DOM tree. Used to serialize an object
140     * to a DOM tree, usually to send a UDDI message.
141     *
142     * <BR>Used by UDDIProxy.
143     *
144     * @param parent Object will serialize as a child element under the
145     * passed in parent element.
146     */

147    public void saveToXML(Element parent) {
148       base = parent.getOwnerDocument().createElement(UDDI_TAG);
149       // Save attributes
150
base.setAttribute("generic", UDDIElement.GENERIC);
151       base.setAttribute("xmlns", UDDIElement.XMLNS);
152       if (businessKey!=null) {
153         for (int i=0; i < businessKey.size(); i++) {
154            ((BusinessKey)(businessKey.elementAt(i))).saveToXML(base);
155         }
156       }
157       parent.appendChild(base);
158    }
159 }
160
Popular Tags