KickJava   Java API By Example, From Geeks To Geeks.

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


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.request;
10
11 import java.util.Vector JavaDoc;
12
13 import org.uddi4j.UDDIElement;
14 import org.uddi4j.UDDIException;
15 import org.uddi4j.datatype.assertion.PublisherAssertion;
16 import org.uddi4j.util.AuthInfo;
17 import org.w3c.dom.Element JavaDoc;
18 import org.w3c.dom.NodeList JavaDoc;
19
20 /**
21  * Represents the add_publisherAssertions 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  *
39  * <p>This message is used to add relationship assertions to the existing
40  * set of assertions. Relationship assertions consist of a reference to two businessEntity key values.
41  * These values are designated by the fromKey and toKey elements, as well as, a required
42  * expression of directional relationship within the contained keyedReference element.
43  *
44  * @author Ravi Trivedi (ravi_trivedi@hp.com)
45  */

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

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

73    public AddPublisherAssertions(Element base) throws UDDIException {
74        super(base);
75       NodeList JavaDoc nl = null;
76
77       nl = getChildElementsByTagName(base, AuthInfo.UDDI_TAG);
78        if (nl.getLength() > 0) {
79           authInfo = new AuthInfo((Element)nl.item(0));
80       }
81        nl = getChildElementsByTagName(base, PublisherAssertion.UDDI_TAG);
82        for (int i=0; i < nl.getLength(); i++) {
83            pubAssertion.addElement(new
84            PublisherAssertion((Element)nl.item(i)));
85        }
86    }
87
88    /**
89     * Construct the object with required fields.
90     *
91     * @param authInfo String
92     * @param pubAssertVector Vector
93     */

94    public AddPublisherAssertions(String JavaDoc authInfo,
95             Vector JavaDoc pubAssertVector) {
96             this.authInfo = new AuthInfo();
97             this.authInfo.setText(authInfo);
98             this.pubAssertion = pubAssertVector;
99    }
100
101    public void setPublisherAssertionVector(Vector JavaDoc pubAssertVector ) {
102        this.pubAssertion = pubAssertVector;
103    }
104
105    public Vector JavaDoc getPublisherAssertionVector() {
106        return this.pubAssertion;
107    }
108
109    public AuthInfo getAuthInfo() {
110        return this.authInfo;
111    }
112
113    public void setAuthInfo(AuthInfo s) {
114          this.authInfo = s;
115       }
116
117
118    public String JavaDoc getAuthInfoString() {
119        return this.authInfo.getText();
120    }
121
122
123    public void setAuthInfo(String JavaDoc s) {
124         authInfo = new AuthInfo();
125         authInfo.setText(s);
126     }
127
128
129    /**
130     * Save an object to the DOM tree. Used to serialize an object
131     * to a DOM tree, usually to send a UDDI message.
132     *
133     * <BR>Used by UDDIProxy.
134     *
135     * @param parent Object will serialize as a child element under the
136     * passed in parent element.
137     */

138    public void saveToXML(Element parent) {
139         base = parent.getOwnerDocument().createElement(UDDI_TAG);
140          // Save attributes
141
base.setAttribute("generic", UDDIElement.GENERIC);
142         base.setAttribute("xmlns", UDDIElement.XMLNS);
143         if (authInfo!=null) {
144            authInfo.saveToXML(base);
145         }
146         if (pubAssertion!=null) {
147           for (int i=0; i < pubAssertion.size(); i++) {
148              ((PublisherAssertion)(pubAssertion.elementAt(i))).saveToXML(base);
149           }
150         }
151         parent.appendChild(base);
152
153    }
154 }
155
156
Popular Tags