KickJava   Java API By Example, From Geeks To Geeks.

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


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, Hewlett-Packard Company
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.BusinessKey;
14 import org.uddi4j.util.FindQualifiers;
15 import org.uddi4j.util.KeyedReference;
16 import org.w3c.dom.Element JavaDoc;
17 import org.w3c.dom.NodeList JavaDoc;
18
19 /**
20  * Represents the find_relatedBusinesses 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  *
38  * <p>This message returns zero or more relatedBusinessInfo structures. For the
39  * businessEntity specified in the find_relatedBusinesses class, the response
40  * reports that business relationships with other businessEntity registrations
41  * are complete. Business relationships are complete between two businessEntity
42  * registrations when the publishers controlling each of the businessEntity
43  * structures involved in the relationship set assertions affirming that
44  * relationship.
45  *
46  * @author Ravi Trivedi (ravi_trivedi@hp.com)
47  */

48 public class FindRelatedBusinesses extends UDDIElement {
49
50    public static final String JavaDoc UDDI_TAG = "find_relatedBusinesses";
51
52    protected Element base = null;
53
54    String JavaDoc maxRows = null;
55    FindQualifiers findQualifiers = null;
56    KeyedReference keyRef = null;
57    String JavaDoc businessKey = null;
58
59    /**
60     * Default constructor.
61     * Avoid using the default constructor for validation. It does not validate
62     * required fields. Instead, use the required fields constructor to perform
63     * validation.
64     */

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

78    public FindRelatedBusinesses(Element base) throws UDDIException {
79      // Check if it is a fault. Throws an exception if it is.
80
super(base);
81      maxRows = base.getAttribute("maxRows");
82
83      NodeList JavaDoc nl = null;
84       nl = getChildElementsByTagName(base, BusinessKey.UDDI_TAG);
85       if (nl.getLength() > 0) {
86          businessKey = new BusinessKey((Element)nl.item(0)).getText();
87       }
88
89      nl = getChildElementsByTagName(base, FindQualifiers.UDDI_TAG);
90      if (nl.getLength() > 0) {
91         findQualifiers = new FindQualifiers((Element)nl.item(0));
92      }
93
94      nl = getChildElementsByTagName(base, KeyedReference.UDDI_TAG);
95      if (nl.getLength() > 0) {
96          keyRef = new KeyedReference((Element)nl.item(0));
97      }
98
99    }
100
101    /**
102     * Construct the object with required fields.
103     *
104     * @param businessKey String
105     */

106    public FindRelatedBusinesses(String JavaDoc businessKey) {
107        this.businessKey = businessKey;
108    }
109
110    public void setBusinessKey(String JavaDoc newBusinessKey) {
111        this.businessKey = newBusinessKey;
112    }
113
114    public String JavaDoc getBusinessKey() {
115        return this.businessKey;
116    }
117
118    public void setFindQualifiers(FindQualifiers fqs) {
119        this.findQualifiers = fqs;
120    }
121
122    public FindQualifiers getFindQualifiers() {
123        return this.findQualifiers;
124    }
125
126    public void setKeyedReference (KeyedReference newKeyedReference) {
127        this.keyRef = newKeyedReference;
128    }
129
130    public KeyedReference getKeyedReference() {
131        return this.keyRef;
132    }
133
134    public String JavaDoc getMaxRows() {
135        return this.maxRows;
136    }
137
138    public void setMaxRows(String JavaDoc rows) {
139        this.maxRows = rows;
140    }
141
142    public int getMaxRowsInt() {
143       return Integer.parseInt(this.maxRows);
144    }
145
146    public void setMaxRows(int s) {
147       maxRows = Integer.toString(s);
148    }
149
150    /**
151     * Save an object to the DOM tree. Used to serialize an object
152     * to a DOM tree, usually to send a UDDI message.
153     *
154     * <BR>Used by UDDIProxy.
155     *
156     * @param parent Object will serialize as a child element under the
157     * passed in parent element.
158     */

159    public void saveToXML(Element parent) {
160          base = parent.getOwnerDocument().createElement(UDDI_TAG);
161          // Save attributes.
162
base.setAttribute("generic", UDDIElement.GENERIC);
163          base.setAttribute("xmlns", UDDIElement.XMLNS);
164
165          if (maxRows!=null) {
166             base.setAttribute("maxRows", maxRows);
167          }
168          if (findQualifiers!=null) {
169              findQualifiers.saveToXML(base);
170          }
171          if (businessKey!=null) {
172              (new BusinessKey(businessKey)).saveToXML(base);
173          }
174          if(keyRef != null ) {
175             keyRef.saveToXML(base);
176          }
177
178         parent.appendChild(base);
179    }
180 }
181
Popular Tags