KickJava   Java API By Example, From Geeks To Geeks.

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


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

44 public class FindTModel extends UDDIElement {
45    public static final String JavaDoc UDDI_TAG = "find_tModel";
46
47    protected Element base = null;
48
49    String JavaDoc maxRows = null;
50    FindQualifiers findQualifiers = null;
51    Name name = null;
52    IdentifierBag identifierBag = null;
53    CategoryBag categoryBag = null;
54
55    /**
56     * Default constructor.
57     * Avoid using the default constructor for validation. It does not validate
58     * required fields. Instead, use the required fields constructor to perform
59     * validation.
60     */

61    public FindTModel() {
62    }
63
64    /**
65     * Construct the object from a DOM tree. Used by
66     * UDDIProxy to construct an object from a received UDDI
67     * message.
68     *
69     * @param base Element with the name appropriate for this class.
70     *
71     * @exception UDDIException Thrown if DOM tree contains a SOAP fault
72     * or a disposition report indicating a UDDI error.
73     */

74    public FindTModel(Element base) throws UDDIException {
75       // Check if it is a fault. Throws an exception if it is.
76
super(base);
77       maxRows = base.getAttribute("maxRows");
78       NodeList JavaDoc nl = null;
79       nl = getChildElementsByTagName(base, FindQualifiers.UDDI_TAG);
80       if (nl.getLength() > 0) {
81          findQualifiers = new FindQualifiers((Element)nl.item(0));
82       }
83       nl = getChildElementsByTagName(base, Name.UDDI_TAG);
84       if (nl.getLength() > 0) {
85          name = new Name((Element)nl.item(0));
86       }
87       nl = getChildElementsByTagName(base, IdentifierBag.UDDI_TAG);
88       if (nl.getLength() > 0) {
89          identifierBag = new IdentifierBag((Element)nl.item(0));
90       }
91       nl = getChildElementsByTagName(base, CategoryBag.UDDI_TAG);
92       if (nl.getLength() > 0) {
93          categoryBag = new CategoryBag((Element)nl.item(0));
94       }
95    }
96
97    public void setMaxRows(String JavaDoc s) {
98       maxRows = s;
99    }
100    public void setMaxRows(int s) {
101       maxRows = Integer.toString(s);
102    }
103
104    public void setFindQualifiers(FindQualifiers s) {
105       findQualifiers = s;
106    }
107
108    public void setName(Name s) {
109       name = s;
110    }
111    public void setName(String JavaDoc s) {
112       if (s !=null && !s.equals ("")) {
113         name = new Name();
114         name.setText(s);
115       }
116    }
117
118    public void setIdentifierBag(IdentifierBag s) {
119       identifierBag = s;
120    }
121
122    public void setCategoryBag(CategoryBag s) {
123       categoryBag = s;
124    }
125
126    public String JavaDoc getMaxRows() {
127       return maxRows;
128    }
129
130    public int getMaxRowsInt() {
131       return Integer.parseInt(maxRows);
132    }
133
134    public FindQualifiers getFindQualifiers() {
135       return findQualifiers;
136    }
137
138
139    public Name getName() {
140       return name;
141    }
142
143    public String JavaDoc getNameString() {
144       if(name!=null)
145         return name.getText();
146       else
147         return null;
148    }
149
150    public IdentifierBag getIdentifierBag() {
151       return identifierBag;
152    }
153
154
155    public CategoryBag getCategoryBag() {
156       return categoryBag;
157    }
158
159
160    /**
161     * Save an object to the DOM tree. Used to serialize an object
162     * to a DOM tree, usually to send a UDDI message.
163     *
164     * <BR>Used by UDDIProxy.
165     *
166     * @param parent Object will serialize as a child element under the
167     * passed in parent element.
168     */

169    public void saveToXML(Element parent) {
170       base = parent.getOwnerDocument().createElement(UDDI_TAG);
171       // Save attributes.
172
base.setAttribute("generic", UDDIElement.GENERIC);
173       base.setAttribute("xmlns", UDDIElement.XMLNS);
174       if (maxRows!=null) {
175          base.setAttribute("maxRows", maxRows);
176       }
177       if (findQualifiers!=null) {
178          findQualifiers.saveToXML(base);
179       }
180       if (name!=null) {
181          name.saveToXML(base);
182       }
183       if (identifierBag!=null) {
184          identifierBag.saveToXML(base);
185       }
186       if (categoryBag!=null) {
187          categoryBag.saveToXML(base);
188       }
189       parent.appendChild(base);
190    }
191 }
192
Popular Tags