KickJava   Java API By Example, From Geeks To Geeks.

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


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 org.uddi4j.UDDIElement;
12 import org.uddi4j.UDDIException;
13 import org.w3c.dom.Element JavaDoc;
14 import org.w3c.dom.NodeList JavaDoc;
15
16 /**
17  * Represents the serviceList element within the UDDI version 2.0 schema.
18  * This class contains the following types of methods:
19  *
20  * <ul>
21  * <li>A constructor that passes the required fields.
22  * <li>A Constructor that will instantiate the object from an appropriate XML
23  * DOM element.
24  * <li>Get/set methods for each attribute that this element can contain.
25  * <li>A get/setVector method is provided for sets of attributes.
26  * <li>A SaveToXML method that serializes this class within a passed in
27  * element.
28  * </ul>
29  *
30  * Typically, this class is used to construct parameters for, or interpret
31  * responses from, methods in the UDDIProxy class.
32  *
33  * <p><b>Element description:</b>
34  * <p>This message is used to return results of a find_service request.
35  *
36  * @author David Melgar (dmelgar@us.ibm.com)
37  * @author Ozzy (ozzy@hursley.ibm.com)
38  */

39 public class ServiceList extends UDDIElement {
40    public static final String JavaDoc UDDI_TAG = "serviceList";
41
42    protected Element base = null;
43
44    String JavaDoc operator = null;
45    String JavaDoc truncated = null;
46    ServiceInfos serviceInfos = null;
47
48    /**
49     * Default constructor.
50     * Avoid using the default constructor for validation. It does not validate
51     * required fields. Instead, use the required fields constructor to perform
52     * validation.
53     */

54
55    public ServiceList() {
56    }
57
58    /**
59     * Construct the object with required fields.
60     *
61     * @param operator String
62     * @param serviceInfos ServiceInfos object
63     */

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

80
81    public ServiceList(Element base) throws UDDIException {
82       // Check if it is a fault. Throws an exception if it is.
83
super(base);
84       operator = base.getAttribute("operator");
85       truncated = base.getAttribute("truncated");
86       NodeList JavaDoc nl = null;
87       nl = getChildElementsByTagName(base, ServiceInfos.UDDI_TAG);
88       if (nl.getLength() > 0) {
89          serviceInfos = new ServiceInfos((Element)nl.item(0));
90       }
91    }
92
93    public void setOperator(String JavaDoc s) {
94       operator = s;
95    }
96
97    public void setTruncated(String JavaDoc s) {
98       truncated = s;
99    }
100    public void setTruncated(boolean s) {
101       if (s) {
102          truncated = "true";
103       } else {
104          truncated = "false";
105       }
106    }
107
108    public void setServiceInfos(ServiceInfos s) {
109       serviceInfos = s;
110    }
111
112    public String JavaDoc getOperator() {
113       return operator;
114    }
115
116
117    public String JavaDoc getTruncated() {
118       return truncated;
119    }
120
121    public boolean getTruncatedBoolean() {
122       return "true".equals(truncated);
123    }
124
125    public ServiceInfos getServiceInfos() {
126       return serviceInfos;
127    }
128
129
130    /**
131     * Save an object to the DOM tree. Used to serialize an object
132     * to a DOM tree, usually to send a UDDI message.
133     *
134     * <BR>Used by UDDIProxy.
135     *
136     * @param parent Object will serialize as a child element under the
137     * passed in parent element.
138     */

139
140    public void saveToXML(Element parent) {
141       base = parent.getOwnerDocument().createElement(UDDI_TAG);
142       // Save attributes
143
base.setAttribute("generic", UDDIElement.GENERIC);
144       base.setAttribute("xmlns", UDDIElement.XMLNS);
145       if (operator!=null) {
146          base.setAttribute("operator", operator);
147       }
148       if (truncated!=null) {
149          base.setAttribute("truncated", truncated);
150       }
151       if (serviceInfos!=null) {
152          serviceInfos.saveToXML(base);
153       }
154       parent.appendChild(base);
155    }
156 }
157
Popular Tags