KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > uddi4j > datatype > binding > BindingTemplates


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.datatype.binding;
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 bindingTemplates element within the UDDI version 2.0 schema.
20  * This class contains the following types of methods:
21  *
22  * <ul>
23  * <li>Constructor passing required fields.
24  * <li>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>SaveToXML method. Serializes this class within a passed in element.
29  * </ul>
30  *
31  * Typically, this class is used to construct parameters for, or interpret
32  * responses from, methods in the UDDIProxy class.
33  *
34  * <p><b>Element description:</b>
35  * <p>Service element. Collection accessor for bindingTemplate information.
36  *
37  * @author David Melgar (dmelgar@us.ibm.com)
38  * @author Vivek Chopra (vivek@soaprpc.com)
39  */

40 public class BindingTemplates extends UDDIElement {
41    public static final String JavaDoc UDDI_TAG = "bindingTemplates";
42
43    protected Element base = null;
44
45    // Vector of BindingTemplate objects
46
Vector JavaDoc bindingTemplate = new Vector JavaDoc();
47
48    /**
49     * Default constructor.
50     *
51     */

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

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

80    public void setBindingTemplateVector(Vector JavaDoc s) {
81       bindingTemplate = s;
82    }
83
84    /**
85     * Get bindingTemplate
86     *
87     * @return s Vector of <I>BindingTemplate</I> objects.
88     */

89    public Vector JavaDoc getBindingTemplateVector() {
90       return bindingTemplate;
91    }
92
93    /**
94     * Add a BindingTemplate object to the collection
95     * @param b BindingTemplate to be added
96     */

97    public void add (BindingTemplate b) {
98       bindingTemplate.add (b);
99    }
100
101    /**
102     * Remove a BindingTemplate object from the collection
103     * @param b BindingTemplate to be removed
104     * @return True if object was removed, false if it
105     * was not found in the collection.
106     */

107    public boolean remove (BindingTemplate b) {
108       return bindingTemplate.remove (b);
109    }
110
111    /**
112     * Retrieve the BindingTemplate at the specified index within the collection.
113     * @param index Index to retrieve from.
114     * @return BindingTemplate at that index
115     */

116    public BindingTemplate get (int index) {
117       return (BindingTemplate) bindingTemplate.get (index);
118    }
119
120    /**
121     * Return current size of the collection.
122     * @return Number of BindingTemplates in the collection
123     */

124    public int size () {
125       return bindingTemplate.size ();
126    }
127
128    /**
129     * Save object to DOM tree. Used to serialize object
130     * to a DOM tree, usually to send a UDDI message.
131     *
132     * <BR>Used by UDDIProxy.
133     *
134     * @param parent Object will serialize as a child element under the
135     * passed in parent element.
136     */

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