KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > uddi4j > util > FindQualifiers


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

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

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

68    public FindQualifiers(Element base) throws UDDIException {
69       // Check if it is a fault. Throws an exception if it is.
70
super(base);
71       NodeList JavaDoc nl = null;
72       nl = getChildElementsByTagName(base, FindQualifier.UDDI_TAG);
73       for (int i=0; i < nl.getLength(); i++) {
74          findQualifier.addElement(new FindQualifier((Element)nl.item(i)));
75       }
76    }
77
78    /**
79     * Set findQualifier vector.
80     *
81     * @param s Vector of <I>FindQualifier</I> objects.
82     */

83    public void setFindQualifierVector(Vector JavaDoc s) {
84       findQualifier = s;
85    }
86
87    /**
88     * Add a FindQualifier object to the collection
89     * @param f Find qualifier to be added
90     */

91    public void add (FindQualifier f) {
92       findQualifier.add (f);
93    }
94
95    /**
96     * Remove a FindQualifier object from the collection
97     * @param f Find qualifier to be removed
98     * @return True if object was removed, false if it
99     * was not found in the collection.
100     */

101    public boolean remove (FindQualifier f) {
102       return findQualifier.remove (f);
103    }
104
105    /**
106     * Retrieve the findQualfier at the specified index within the collection.
107     * @param index Index to retrieve from.
108     * @return FindQualifier at that index
109     */

110    public FindQualifier get (int index) {
111       return (FindQualifier) findQualifier.get (index);
112    }
113
114    /**
115     * Return current size of the collection.
116     * @return Number of find qualifiers in the collection
117     */

118    public int size () {
119       return findQualifier.size ();
120    }
121
122    /**
123     * Get findQualifier
124     *
125     * @return s Vector of <I>FindQualifier</I> objects.
126     */

127    public Vector JavaDoc getFindQualifierVector() {
128       return findQualifier;
129    }
130
131    /**
132     * Save an object to the DOM tree. Used to serialize an object
133     * to a DOM tree, usually to send a UDDI message.
134     *
135     * <BR>Used by UDDIProxy.
136     *
137     * @param parent Object will serialize as a child element under the
138     * passed in parent element.
139     */

140    public void saveToXML(Element parent) {
141       base = parent.getOwnerDocument().createElement(UDDI_TAG);
142       // Save attributes
143
if (findQualifier!=null) {
144          for (int i=0; i < findQualifier.size(); i++) {
145             ((FindQualifier)(findQualifier.elementAt(i))).saveToXML(base);
146      }
147       }
148       parent.appendChild(base);
149    }
150 }
151
Popular Tags