KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > uddi4j > util > DiscoveryURL


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

37 public class DiscoveryURL extends UDDIElement {
38    public static final String JavaDoc UDDI_TAG = "discoveryURL";
39
40    protected Element base = null;
41
42    String JavaDoc text = null;
43    String JavaDoc useType = null;
44
45    /**
46     * Default constructor.
47     * Avoid using the default constructor for validation. It does not validate
48     * required fields. Instead, use the required fields constructor to perform
49     * validation.
50     */

51    public DiscoveryURL() {
52    }
53
54    /**
55     * Construct the object with required fields.
56     *
57     * @param value String value
58     * @param useType String
59     */

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

76    public DiscoveryURL(Element base) throws UDDIException {
77       // Check if it is a fault. Throws an exception if it is.
78
super(base);
79       text = getText(base);
80       useType = base.getAttribute("useType");
81    }
82
83    public void setText(String JavaDoc s) {
84       text = s;
85    }
86
87    public void setUseType(String JavaDoc s) {
88       useType = s;
89    }
90
91    public String JavaDoc getText() {
92       return text;
93    }
94
95    public String JavaDoc getUseType() {
96       return useType;
97    }
98
99    //KJ ADDED FOR JAXR
100
public boolean equals(Object JavaDoc obj)
101    {
102        boolean result = false;
103        if (obj != null && obj instanceof DiscoveryURL)
104        {
105            DiscoveryURL otherDiscURL = (DiscoveryURL)obj;
106            if ((text == null && otherDiscURL.getText() == null) ||
107                (text != null && text.equals(otherDiscURL.getText())))
108            {
109                if ((useType == null && otherDiscURL.getUseType() == null) ||
110                    (useType != null && useType.equals(otherDiscURL.getUseType())))
111                {
112                    result = true;
113                }
114            }
115        }
116        return result;
117    }
118
119    /**
120     * Save an object to the DOM tree. Used to serialize an object
121     * to a DOM tree, usually to send a UDDI message.
122     *
123     * <BR>Used by UDDIProxy.
124     *
125     * @param parent Object will serialize as a child element under the
126     * passed in parent element.
127     */

128    public void saveToXML(Element parent) {
129       base = parent.getOwnerDocument().createElement(UDDI_TAG);
130       // Save attributes.
131
if (text!=null) {
132          base.appendChild(parent.getOwnerDocument().createTextNode(text));
133       }
134       if (useType!=null) {
135          base.setAttribute("useType", useType);
136       }
137       parent.appendChild(base);
138    }
139 }
140
Popular Tags