KickJava   Java API By Example, From Geeks To Geeks.

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


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.w3c.dom.Element JavaDoc;
16 import org.w3c.dom.NodeList JavaDoc;
17
18 /**
19  * Represents the businessDetailExt 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 extended businessDetail messages define an API that allows non-operator
37  * nodes to provide extended information via a consistent API. This message
38  * is the response to get_businessDetailExt.
39  *
40  * @author David Melgar (dmelgar@us.ibm.com)
41  * @author Ozzy (ozzy@hursley.ibm.com)
42  */

43 public class BusinessDetailExt extends UDDIElement
44 {
45     public static final String JavaDoc UDDI_TAG = "businessDetailExt";
46
47     protected Element base = null;
48
49     String JavaDoc operator = null;
50     String JavaDoc truncated = null;
51     // Vector of BusinessEntityExt objects
52
Vector JavaDoc businessEntityExt = new Vector JavaDoc();
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 BusinessDetailExt()
62     {
63     }
64
65     /**
66      * Construct the object with required fields.
67      *
68      * @param operator String
69      * @param businessEntityExt Vector of BusinessEntityExt objects.
70      */

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

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

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

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

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