KickJava   Java API By Example, From Geeks To Geeks.

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


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.util;
10
11 import org.uddi4j.UDDIElement;
12 import org.uddi4j.UDDIException;
13 import org.w3c.dom.Element JavaDoc;
14
15 /**
16  * Represents the fromKey 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  * @author Mahesh C S (csmahesh@india.hp.com)
33  */

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

48    public FromKey() {
49    }
50
51    /**
52     * Construct the object from a DOM tree. Used by
53     * UDDIProxy to construct an object from a received UDDI
54     * message.
55     *
56     * @param base Element with the name appropriate for this class.
57     *
58     * @exception UDDIException Thrown if DOM tree contains a SOAP fault
59     * or a disposition report indicating a UDDI error.
60     */

61    public FromKey(Element base) throws UDDIException {
62        super(base);
63        text = getText(base);
64    }
65
66    /**
67     * Construct the object with required fields.
68     *
69     * @param key String
70     */

71    public FromKey(String JavaDoc key) {
72        setText(key);
73    }
74
75    public void setText(String JavaDoc s) {
76        text = s;
77    }
78
79    public String JavaDoc getText() {
80        return text;
81    }
82
83    /**
84     * Save an object to the DOM tree. Used to serialize an object
85     * to a DOM tree, usually to send a UDDI message.
86     *
87     * <BR>Used by UDDIProxy.
88     *
89     * @param parent Object will serialize as a child element under the
90     * passed in parent element.
91     */

92    public void saveToXML(Element parent) {
93        base = parent.getOwnerDocument().createElement(UDDI_TAG);
94
95        if (text!=null) {
96           base.appendChild(parent.getOwnerDocument().createTextNode(text));
97        }
98        parent.appendChild(base);
99    }
100 }
101
Popular Tags