KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > uddi4j > request > FindBinding


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.request;
10
11 import org.uddi4j.UDDIElement;
12 import org.uddi4j.UDDIException;
13 import org.uddi4j.util.FindQualifiers;
14 import org.uddi4j.util.TModelBag;
15 import org.w3c.dom.Element JavaDoc;
16 import org.w3c.dom.NodeList JavaDoc;
17
18 /**
19  * Represents the find_binding 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  *
37  * <p>This message is used to search for summary results listing registered
38  * bindingTemplate data within a businessService matching specific criteria.
39  *
40  * @author David Melgar (dmelgar@us.ibm.com)
41  */

42 public class FindBinding extends UDDIElement {
43    public static final String JavaDoc UDDI_TAG = "find_binding";
44
45    protected Element base = null;
46
47    String JavaDoc maxRows = null;
48    String JavaDoc serviceKey = null;
49    FindQualifiers findQualifiers = null;
50    TModelBag tModelBag = null;
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    public FindBinding() {
59    }
60
61    /**
62     * Construct the object with required fields.
63     *
64     * @param serviceKey String
65     * @param tModelBag TModelBag object
66     */

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

83    public FindBinding(Element base) throws UDDIException {
84       // Check if it is a fault. Throws an exception if it is.
85
super(base);
86       maxRows = base.getAttribute("maxRows");
87       serviceKey = base.getAttribute("serviceKey");
88       NodeList JavaDoc nl = null;
89       nl = getChildElementsByTagName(base, FindQualifiers.UDDI_TAG);
90       if (nl.getLength() > 0) {
91          findQualifiers = new FindQualifiers((Element)nl.item(0));
92       }
93       nl = getChildElementsByTagName(base, TModelBag.UDDI_TAG);
94       if (nl.getLength() > 0) {
95          tModelBag = new TModelBag((Element)nl.item(0));
96       }
97    }
98
99    public void setMaxRows(String JavaDoc s) {
100       maxRows = s;
101    }
102    public void setMaxRows(int s) {
103       maxRows = Integer.toString(s);
104    }
105
106    public void setServiceKey(String JavaDoc s) {
107       serviceKey = s;
108    }
109
110    public void setFindQualifiers(FindQualifiers s) {
111       findQualifiers = s;
112    }
113
114    public void setTModelBag(TModelBag s) {
115       tModelBag = s;
116    }
117
118    public String JavaDoc getMaxRows() {
119       return maxRows;
120    }
121
122    public int getMaxRowsInt() {
123       return Integer.parseInt(maxRows);
124    }
125
126    public String JavaDoc getServiceKey() {
127       return serviceKey;
128    }
129
130
131    public FindQualifiers getFindQualifiers() {
132       return findQualifiers;
133    }
134
135
136    public TModelBag getTModelBag() {
137       return tModelBag;
138    }
139
140
141    /**
142     * Save an object to the DOM tree. Used to serialize an object
143     * to a DOM tree, usually to send a UDDI message.
144     *
145     * <BR>Used by UDDIProxy.
146     *
147     * @param parent Object will serialize as a child element under the
148     * passed in parent element.
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 (maxRows!=null) {
156          base.setAttribute("maxRows", maxRows);
157       }
158       if (serviceKey!=null) {
159          base.setAttribute("serviceKey", serviceKey);
160       }
161       if (findQualifiers!=null) {
162          findQualifiers.saveToXML(base);
163       }
164       if (tModelBag!=null) {
165          tModelBag.saveToXML(base);
166       }
167       parent.appendChild(base);
168    }
169 }
170
Popular Tags