KickJava   Java API By Example, From Geeks To Geeks.

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


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

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

59    public DeleteBusiness() {
60    }
61
62    /**
63     * Construct the object with required fields.
64     *
65     * @param authInfo String
66     * @param businessKeyStrings Vector of BusinessKey Strings.
67     */

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

90    public DeleteBusiness(Element base) throws UDDIException {
91       // Check if it is a fault. Throws an exception if it is.
92
super(base);
93       NodeList JavaDoc nl = null;
94       nl = getChildElementsByTagName(base, AuthInfo.UDDI_TAG);
95       if (nl.getLength() > 0) {
96          authInfo = new AuthInfo((Element)nl.item(0));
97       }
98       nl = getChildElementsByTagName(base, BusinessKey.UDDI_TAG);
99       for (int i=0; i < nl.getLength(); i++) {
100          businessKey.addElement(new BusinessKey((Element)nl.item(i)));
101       }
102    }
103
104    public void setAuthInfo(AuthInfo s) {
105       authInfo = s;
106    }
107    public void setAuthInfo(String JavaDoc s) {
108       authInfo = new AuthInfo();
109       authInfo.setText(s);
110    }
111
112    /**
113     * Set businessKey vector
114     *
115     * @param s Vector of <I>BusinessKey</I> objects.
116     */

117    public void setBusinessKeyVector(Vector JavaDoc s) {
118       businessKey = s;
119    }
120
121    /**
122     * Set businessKey
123     *
124     * @param s Vector of <I>String</I> objects.
125     */

126    public void setBusinessKeyStrings(Vector JavaDoc s) {
127       businessKey = new Vector JavaDoc();
128       for (int i = 0; i < s.size(); i++) {
129          businessKey.addElement( new BusinessKey((String JavaDoc)s.elementAt(i)) );
130       }
131    }
132
133    public AuthInfo getAuthInfo() {
134       return authInfo;
135    }
136
137    public String JavaDoc getAuthInfoString() {
138       if(authInfo!=null)
139         return authInfo.getText();
140       else
141         return null;
142    }
143
144    /**
145     * Get businessKey
146     *
147     * @return s Vector of <I>BusinessKey</I> objects.
148     */

149    public Vector JavaDoc getBusinessKeyVector() {
150       return businessKey;
151    }
152
153    /**
154     * Get businessKey
155     *
156     * @return s Vector of <I>String</I> objects.
157     */

158    public Vector JavaDoc getBusinessKeyStrings() {
159       Vector JavaDoc strings = new Vector JavaDoc();
160       for (int i = 0; i < businessKey.size(); i++) {
161          strings.addElement( ((BusinessKey)businessKey.elementAt(i)).getText());
162       }
163       return strings;
164    }
165
166    /**
167     * Save an object to the DOM tree. Used to serialize an object
168     * to a DOM tree, usually to send a UDDI message.
169     *
170     * <BR>Used by UDDIProxy.
171     *
172     * @param parent Object will serialize as a child element under the
173     * passed in parent element.
174     */

175    public void saveToXML(Element parent) {
176       base = parent.getOwnerDocument().createElement(UDDI_TAG);
177       // Save attributes.
178
base.setAttribute("generic", UDDIElement.GENERIC);
179       base.setAttribute("xmlns", UDDIElement.XMLNS);
180       if (authInfo!=null) {
181          authInfo.saveToXML(base);
182       }
183       if (businessKey!=null) {
184         for (int i=0; i < businessKey.size(); i++) {
185            ((BusinessKey)(businessKey.elementAt(i))).saveToXML(base);
186         }
187       }
188       parent.appendChild(base);
189    }
190 }
191
Popular Tags