KickJava   Java API By Example, From Geeks To Geeks.

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


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.service.BusinessService;
16 import org.w3c.dom.Element JavaDoc;
17 import org.w3c.dom.NodeList JavaDoc;
18
19 /**
20  * Represents the serviceDetail 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 structure is used to return all businessService details.
38  *
39  * @author David Melgar (dmelgar@us.ibm.com)
40  * @author Ozzy (ozzy@hursley.ibm.com)
41  */

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

58
59    public ServiceDetail() {
60    }
61
62    /**
63     * Construct the object with required fields.
64     *
65     * @param operator String
66     */

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

81
82    public ServiceDetail(Element base) throws UDDIException {
83       // Check if it is a fault. Throws an exception if it is.
84
super(base);
85       operator = base.getAttribute("operator");
86       truncated = base.getAttribute("truncated");
87       NodeList JavaDoc nl = null;
88       nl = getChildElementsByTagName(base, BusinessService.UDDI_TAG);
89       for (int i=0; i < nl.getLength(); i++) {
90          businessService.addElement(new BusinessService((Element)nl.item(i)));
91       }
92    }
93
94    public void setOperator(String JavaDoc s) {
95       operator = s;
96    }
97
98    public void setTruncated(String JavaDoc s) {
99       truncated = s;
100    }
101    public void setTruncated(boolean s) {
102       if (s) {
103          truncated = "true";
104       } else {
105          truncated = "false";
106       }
107    }
108
109    /**
110     * Set businessService vector
111     *
112     * @param s Vector of <I>BusinessService</I> objects.
113     */

114    public void setBusinessServiceVector(Vector JavaDoc s) {
115       businessService = s;
116    }
117
118    public String JavaDoc getOperator() {
119       return operator;
120    }
121
122
123    public String JavaDoc getTruncated() {
124       return truncated;
125    }
126
127    public boolean getTruncatedBoolean() {
128       return "true".equals(truncated);
129    }
130
131    /**
132     * Get businessService
133     *
134     * @return s Vector of <I>BusinessService</I> objects.
135     */

136    public Vector JavaDoc getBusinessServiceVector() {
137       return businessService;
138    }
139
140    /**
141     * Save an object to the DOM tree. Used to serialize an object
142     * to a DOM tree, usually to send a UDDI message.
143     *
144     * <BR>Used by UDDIProxy.
145     *
146     * @param parent Object will serialize as a child element under the
147     * passed in parent element.
148     */

149
150    public void saveToXML(Element parent) {
151       base = parent.getOwnerDocument().createElement(UDDI_TAG);
152       // Save attributes
153
base.setAttribute("generic", UDDIElement.GENERIC);
154       base.setAttribute("xmlns", UDDIElement.XMLNS);
155       if (operator!=null) {
156          base.setAttribute("operator", operator);
157       }
158       if (truncated!=null) {
159          base.setAttribute("truncated", truncated);
160       }
161       if (businessService!=null) {
162          for (int i=0; i < businessService.size(); i++) {
163             ((BusinessService)(businessService.elementAt(i))).saveToXML(base);
164          }
165       }
166       parent.appendChild(base);
167    }
168 }
169
Popular Tags