KickJava   Java API By Example, From Geeks To Geeks.

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


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_businessDetail 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>This message is used to get the detailed information that is registered
38  * about businessEntity data that matches specific key value(s).
39  *
40  * @author David Melgar (dmelgar@us.ibm.com)
41  */

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

56    public GetBusinessDetail() {
57    }
58
59    /**
60     * Construct the object with required fields.
61     *
62     * @param businessKeyStrings Vector of BusinessKey Strings.
63     */

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

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

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

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

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

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

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