KickJava   Java API By Example, From Geeks To Geeks.

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


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 tModelInstanceDetails 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>Support element used as a container for tModel references within a
36  * web service bindingTemplate metadata set.
37  *
38  * @author David Melgar (dmelgar@us.ibm.com)
39  * @author Vivek Chopra (vivek@soaprpc.com)
40  */

41 public class TModelInstanceDetails extends UDDIElement {
42    public static final String JavaDoc UDDI_TAG = "tModelInstanceDetails";
43
44    protected Element base = null;
45
46    // Vector of TModelInstanceInfo objects
47
Vector JavaDoc tModelInstanceInfo = new Vector JavaDoc();
48
49    /**
50     * Default constructor.
51     *
52     */

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

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

81    public void setTModelInstanceInfoVector(Vector JavaDoc s) {
82       tModelInstanceInfo = s;
83    }
84
85    /**
86     * Get tModelInstanceInfo.
87     *
88     * @return s Vector of <I>TModelInstanceInfo</I> objects.
89     */

90    public Vector JavaDoc getTModelInstanceInfoVector() {
91       return tModelInstanceInfo;
92    }
93
94    /**
95     * Add a TModelInstanceInfo object to the collection
96     * @param t TModelInstanceInfo to be added
97     */

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

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

117    public TModelInstanceInfo get (int index) {
118       return (TModelInstanceInfo) tModelInstanceInfo.get (index);
119    }
120
121    /**
122     * Return current size of the collection.
123     * @return Number of TModelInstanceInfos in the collection
124     */

125    public int size () {
126       return tModelInstanceInfo.size ();
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
if (tModelInstanceInfo!=null) {
142         for (int i=0; i < tModelInstanceInfo.size(); i++) {
143            ((TModelInstanceInfo)(tModelInstanceInfo.elementAt(i))).saveToXML(base);
144         }
145       }
146       parent.appendChild(base);
147    }
148 }
149
Popular Tags