KickJava   Java API By Example, From Geeks To Geeks.

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


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.response;
10
11 import java.util.Vector JavaDoc;
12
13 import org.uddi4j.UDDIElement;
14 import org.uddi4j.UDDIException;
15 import org.uddi4j.datatype.tmodel.TModel;
16 import org.w3c.dom.Element JavaDoc;
17 import org.w3c.dom.NodeList JavaDoc;
18
19 /**
20  * Represents the tModelDetail 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 is a response message that returns all exposed details about a tModel.
38  *
39  * @author David Melgar (dmelgar@us.ibm.com)
40  * @author Ozzy (ozzy@hursley.ibm.com)
41  */

42 public class TModelDetail extends UDDIElement
43 {
44     public static final String JavaDoc UDDI_TAG = "tModelDetail";
45
46     protected Element base = null;
47
48     String JavaDoc operator = null;
49     String JavaDoc truncated = null;
50     // Vector of TModel objects
51
Vector JavaDoc tModel = new Vector JavaDoc();
52
53     /**
54      * Default constructor.
55      * Avoid using the default constructor for validation. It does not validate
56      * required fields. Instead, use the required fields constructor to perform
57      * validation.
58      */

59
60     public TModelDetail()
61     {
62     }
63
64     /**
65      * Construct the object with required fields.
66      *
67      * @param operator String
68      * @param tModel Vector of TModel objects.
69      */

70     public TModelDetail(String JavaDoc operator, Vector JavaDoc tModel)
71     {
72         this.operator = operator;
73         this.tModel = tModel;
74     }
75
76     /**
77      * Construct the object from a DOM tree. Used by
78      * UDDIProxy to construct an object from a received UDDI
79      * message.
80      *
81      * @param base Element with the name appropriate for this class.
82      *
83      * @exception UDDIException Thrown if DOM tree contains a SOAP fault
84      * or a disposition report indicating a UDDI error.
85      */

86
87     public TModelDetail(Element base) throws UDDIException
88     {
89         // Check if it is a fault. Throws an exception if it is.
90
super(base);
91         operator = base.getAttribute("operator");
92         truncated = base.getAttribute("truncated");
93         NodeList JavaDoc nl = null;
94         nl = getChildElementsByTagName(base, TModel.UDDI_TAG);
95         for (int i = 0; i < nl.getLength(); i++)
96         {
97             tModel.addElement(new TModel((Element)nl.item(i)));
98         }
99     }
100
101     public void setOperator(String JavaDoc s)
102     {
103         operator = s;
104     }
105
106     public void setTruncated(String JavaDoc s)
107     {
108         truncated = s;
109     }
110     public void setTruncated(boolean s)
111     {
112         if (s)
113         {
114             truncated = "true";
115         }
116         else
117         {
118             truncated = "false";
119         }
120     }
121
122     /**
123      * Set tModel vector
124      *
125      * @param s Vector of <I>TModel</I> objects.
126      */

127     public void setTModelVector(Vector JavaDoc s)
128     {
129         tModel = s;
130     }
131
132     public String JavaDoc getOperator()
133     {
134         return operator;
135     }
136
137     public String JavaDoc getTruncated()
138     {
139         return truncated;
140     }
141
142     public boolean getTruncatedBoolean()
143     {
144         return "true".equals(truncated);
145     }
146
147     /**
148      * Get tModel
149      *
150      * @return s Vector of <I>TModel</I> objects.
151      */

152     public Vector JavaDoc getTModelVector()
153     {
154         return tModel;
155     }
156
157     /**
158      * Save an object to the DOM tree. Used to serialize an object
159      * to a DOM tree, usually to send a UDDI message.
160      *
161      * <BR>Used by UDDIProxy.
162      *
163      * @param parent Object will serialize as a child element under the
164      * passed in parent element.
165      */

166
167     public void saveToXML(Element parent)
168     {
169         base = parent.getOwnerDocument().createElement(UDDI_TAG);
170         // Save attributes
171
base.setAttribute("generic", UDDIElement.GENERIC);
172         base.setAttribute("xmlns", UDDIElement.XMLNS);
173         if (operator != null)
174         {
175             base.setAttribute("operator", operator);
176         }
177         if (truncated != null)
178         {
179             base.setAttribute("truncated", truncated);
180         }
181         if (tModel != null)
182         {
183             for (int i = 0; i < tModel.size(); i++)
184             {
185                 ((TModel) (tModel.elementAt(i))).saveToXML(base);
186             }
187         }
188         parent.appendChild(base);
189     }
190 }
191
Popular Tags