KickJava   Java API By Example, From Geeks To Geeks.

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


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
15 /**
16  * Represents the errInfo 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>Supports the DispositionReport structure.
34  * This structure is provided for conveying text and structured
35  * error code (alphanumeric) information. Error message text
36  * is contained by this element.
37  *
38  * @author David Melgar (dmelgar@us.ibm.com)
39  */

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

54
55    public ErrInfo() {
56    }
57
58    /**
59     * Construct the object with required fields.
60     *
61     * @param value String value
62     * @param errCode String
63     */

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

80
81    public ErrInfo(Element base) throws UDDIException {
82       // Check if it is a fault. Throws an exception if it is.
83
super(base);
84       text = getText(base);
85       errCode = base.getAttribute("errCode");
86    }
87
88    public void setText(String JavaDoc s) {
89       text = s;
90    }
91
92    public void setErrCode(String JavaDoc s) {
93       errCode = s;
94    }
95
96    public String JavaDoc getText() {
97       return text;
98    }
99
100    public String JavaDoc getErrCode() {
101       return errCode;
102    }
103
104
105    /**
106     * Save an object to the DOM tree. Used to serialize an object
107     * to a DOM tree, usually to send a UDDI message.
108     *
109     * <BR>Used by UDDIProxy.
110     *
111     * @param parent Object will serialize as a child element under the
112     * passed in parent element.
113     */

114
115    public void saveToXML(Element parent) {
116       base = parent.getOwnerDocument().createElement(UDDI_TAG);
117       // Save attributes
118
if (text!=null) {
119          base.appendChild(parent.getOwnerDocument().createTextNode(text));
120       }
121       if (errCode!=null) {
122          base.setAttribute("errCode", errCode);
123       }
124       parent.appendChild(base);
125    }
126 }
127
Popular Tags