KickJava   Java API By Example, From Geeks To Geeks.

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


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 result 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 structure supports the dispositionReport structure.
35  *
36  * @author David Melgar (dmelgar@us.ibm.com)
37  */

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

53
54    public Result() {
55    }
56
57    /**
58     * Construct the object with required fields.
59     *
60     * @param errno String
61     */

62    public Result(String JavaDoc errno) {
63       this.errno = errno;
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
77    public Result(Element base) throws UDDIException {
78       // Check if it is a fault. Throws an exception if it is.
79
super(base);
80       keyType = base.getAttribute("keyType");
81       errno = base.getAttribute("errno");
82       NodeList JavaDoc nl = null;
83       nl = getChildElementsByTagName(base, ErrInfo.UDDI_TAG);
84             if( nl.getLength() > 0 ) {
85         errInfo = new ErrInfo((Element)nl.item(0));
86       }
87    }
88
89    public void setKeyType(String JavaDoc s) {
90       keyType = s;
91    }
92
93    public void setErrno(String JavaDoc s) {
94       errno = s;
95    }
96
97    public void setErrInfo(ErrInfo s) {
98           errInfo = s;
99    }
100
101    public String JavaDoc getKeyType() {
102       return keyType;
103    }
104
105    public String JavaDoc getErrno() {
106       return errno;
107    }
108
109    public ErrInfo getErrInfo() {
110      return errInfo;
111      }
112
113    /**
114     * Save an object to the DOM tree. Used to serialize an object
115     * to a DOM tree, usually to send a UDDI message.
116     *
117     * <BR>Used by UDDIProxy.
118     *
119     * @param parent Object will serialize as a child element under the
120     * passed in parent element.
121     */

122
123    public void saveToXML(Element parent) {
124       base = parent.getOwnerDocument().createElement(UDDI_TAG);
125       // Save attributes
126
if (keyType!=null) {
127          base.setAttribute("keyType", keyType);
128       }
129       if (errno!=null) {
130          base.setAttribute("errno", errno);
131       }
132       if (errInfo!=null) {
133          errInfo.saveToXML(base);
134       }
135       parent.appendChild(base);
136    }
137 }
138
Popular Tags