KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > uddi4j > response > PublisherAssertions


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.response;
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.w3c.dom.Element JavaDoc;
17 import org.w3c.dom.NodeList JavaDoc;
18
19 /**
20  * Represents the publisherAssertions 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 response message contains a set of one or more PublisherAssertion
38  * structures. It returns all publisherAssertion structures that were authenticated
39  * in the preceding set_publisherAssertions or get_publisherAssertions messages.
40  *
41  * @author Mahesh C S (csmahesh@india.hp.com)
42  */

43 public class PublisherAssertions extends UDDIElement {
44    public static final String JavaDoc UDDI_TAG = "publisherAssertions";
45
46    protected Element base = null;
47
48    String JavaDoc operator = null;
49    String JavaDoc authorizedName = null;
50    // Vector of PublisherAssertion objects
51
Vector JavaDoc publisherAssertion = new Vector JavaDoc();
52
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
61    public PublisherAssertions() {
62    }
63
64
65    /**
66     * Construct the object from a DOM tree. Used by
67     * UDDIProxy to construct an object from a received UDDI
68     * message.
69     *
70     * @param base Element with the name appropriate for this class.
71     *
72     * @exception UDDIException Thrown if DOM tree contains a SOAP fault
73     * or a disposition report indicating a UDDI error.
74     */

75
76    public PublisherAssertions(Element base) throws UDDIException {
77        // Check if it is a fault. Throws an exception if it is.
78
super(base);
79        operator = base.getAttribute("operator");
80        authorizedName = base.getAttribute("authorizedName");
81        NodeList JavaDoc nl = null;
82        nl = getChildElementsByTagName(base, PublisherAssertion.UDDI_TAG);
83        for (int i=0; i < nl.getLength(); i++) {
84            publisherAssertion.addElement(new PublisherAssertion((Element)nl.item(i)));
85        }
86    }
87
88    /**
89     * Construct the object with required fields.
90     *
91     * @param operator String
92     * @param name String
93     * @param publishAssertion Vector of publisherAssertion objects.
94     */

95    public PublisherAssertions(String JavaDoc operator, String JavaDoc name,
96                               Vector JavaDoc publishAssertion) throws UDDIException {
97        this.operator = operator;
98        this.authorizedName = name;
99        this.publisherAssertion = publishAssertion;
100    }
101
102    public String JavaDoc getAuthorizedName() {
103        return authorizedName;
104    }
105
106    public void setAuthorizedName(String JavaDoc name) {
107        authorizedName = name;
108    }
109
110    public String JavaDoc getOperator() {
111        return operator;
112    }
113
114    public void setOperator(String JavaDoc s) {
115        operator = s;
116    }
117
118    /**
119     * Set PublisherAssertion vector
120     *
121     * @param s Vector of <I>PublisherAssertion</I> objects.
122     */

123    public void setPublisherAssertionVector(Vector JavaDoc s) {
124        publisherAssertion = s;
125    }
126
127    /**
128     * Get PublisherAssertion vector
129     *
130     * @return Vector of <I>PublisherAssertion</I> objects.
131     */

132    public Vector JavaDoc getPublisherAssertionVector() {
133        return publisherAssertion;
134    }
135
136    /**
137     * Add a PublisherAssertion object to the collection
138     * @param p PublisherAssertion to be added
139     */

140    public void add (PublisherAssertion p) {
141       publisherAssertion.add (p);
142    }
143
144    /**
145     * Remove a PublisherAssertion object from the collection
146     * @param p PublisherAssertion to be removed
147     * @return True if object was removed, false if it
148     * was not found in the collection.
149     */

150    public boolean remove (PublisherAssertion p) {
151       return publisherAssertion.remove (p);
152    }
153
154    /**
155     * Retrieve the PublisherAssertion at the specified index within the collection.
156     * @param index Index to retrieve from.
157     * @return PublisherAssertion at that index
158     */

159    public PublisherAssertion get (int index) {
160       return (PublisherAssertion) publisherAssertion.get (index);
161    }
162
163    /**
164     * Return current size of the collection.
165     * @return Number of PublisherAssertions in the collection
166     */

167    public int size () {
168       return publisherAssertion.size ();
169    }
170
171
172    /**
173     * Save an object to the DOM tree. Used to serialize an object
174     * to a DOM tree, usually to send a UDDI message.
175     *
176     * <BR>Used by UDDIProxy.
177     *
178     * @param parent Object will serialize as a child element under the
179     * passed in parent element.
180     */

181
182    public void saveToXML(Element parent) {
183        base = parent.getOwnerDocument().createElement(UDDI_TAG);
184        // Save attributes
185
base.setAttribute("generic", UDDIElement.GENERIC);
186        base.setAttribute("xmlns", UDDIElement.XMLNS);
187        if (operator!=null) {
188           base.setAttribute("operator", operator);
189        }
190        if (authorizedName!=null) {
191           base.setAttribute("authorizedName", authorizedName);
192        }
193        if (publisherAssertion!=null) {
194           for (int i=0; i < publisherAssertion.size(); i++) {
195              ((PublisherAssertion)(publisherAssertion.elementAt(i))).saveToXML(base);
196           }
197        }
198        parent.appendChild(base);
199    }
200 }
201
Popular Tags