KickJava   Java API By Example, From Geeks To Geeks.

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


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.response;
10
11 import org.uddi4j.UDDIElement;
12 import org.uddi4j.UDDIException;
13 import org.uddi4j.util.FromKey;
14 import org.uddi4j.util.ToKey;
15 import org.w3c.dom.Element JavaDoc;
16 import org.w3c.dom.NodeList JavaDoc;
17
18 /**
19  * Represents the keysOwned element within the UDDI version 2.0 schema.
20  * This class contains the following types of methods:
21  *
22  * <ul>
23  * <li>A constructor that passes the required fields.
24  * <li>A Constructor that will instantiate the object from an appropriate XML
25  * DOM element.
26  * <li>Get/set methods for each attribute that this element can contain.
27  * <li>A get/setVector method is provided for sets of attributes.
28  * <li>A SaveToXML method that serializes this class within a passed in
29  * element.
30  * </ul>
31  *
32  * Typically, this class is used to construct parameters for, or interpret
33  * responses from, methods in the UDDIProxy class.
34  *
35  * <p><b>Element description:</b>
36  * <p>This element designates the businessKeys (fromKey, toKey) that the publisher
37  * manages.
38  *
39  * @author Mahesh C S (csmahesh@india.hp.com)
40  * @author Ozzy (ozzy@hursley.ibm.com)
41  */

42 public class KeysOwned extends UDDIElement {
43    public static final String JavaDoc UDDI_TAG = "keysOwned";
44
45    protected Element base = null;
46
47    FromKey fromKey = null;
48    ToKey toKey = null;
49
50    /**
51     * Default constructor.
52     * Avoid using the default constructor for validation. It does not validate
53     * required fields. Instead, use the required fields constructor to perform
54     * validation.
55     */

56
57    public KeysOwned() {
58    }
59
60
61    /**
62     * Construct the object from a DOM tree. Used by
63     * UDDIProxy to construct an object from a received UDDI
64     * message.
65     *
66     * @param base Element with the name appropriate for this class.
67     *
68     * @exception UDDIException Thrown if DOM tree contains a SOAP fault
69     * or a disposition report indicating a UDDI error.
70     */

71
72    public KeysOwned(Element base) throws UDDIException {
73        // Check if it is a fault. Throws an exception if it is.
74
super(base);
75        NodeList JavaDoc nl = null;
76        nl = getChildElementsByTagName(base, FromKey.UDDI_TAG);
77        if (nl.getLength() > 0) {
78           fromKey = new FromKey((Element)nl.item(0));
79        }
80        nl = getChildElementsByTagName(base, ToKey.UDDI_TAG);
81        if (nl.getLength() > 0) {
82           toKey = new ToKey((Element)nl.item(0));
83        }
84    }
85
86    public void setFromKeyString(String JavaDoc s) {
87        fromKey = new FromKey();
88        fromKey.setText(s);
89    }
90
91    public String JavaDoc getFromKeyString() {
92        if(fromKey!=null)
93          return fromKey.getText();
94        else
95          return null;
96    }
97
98    public void setFromKey(FromKey key) {
99        fromKey = key;
100    }
101
102    public FromKey getFromKey() {
103        return fromKey;
104    }
105
106    public void setToKey(ToKey key) {
107        toKey = key;
108    }
109
110    public ToKey getToKey() {
111        return toKey;
112    }
113
114    public void setToKeyString(String JavaDoc s) {
115        toKey = new ToKey();
116        toKey.setText(s);
117    }
118
119    public String JavaDoc getToKeyString() {
120        if(toKey!=null)
121          return toKey.getText();
122        else
123          return null;
124    }
125
126    /**
127     * Save an object to the DOM tree. Used to serialize an object
128     * to a DOM tree, usually to send a UDDI message.
129     *
130     * <BR>Used by UDDIProxy.
131     *
132     * @param parent Object will serialize as a child element under the
133     * passed in parent element.
134     */

135
136    public void saveToXML(Element parent) {
137        base = parent.getOwnerDocument().createElement(UDDI_TAG);
138
139        if (fromKey!=null) {
140           fromKey.saveToXML(base);
141        }
142        if (toKey!=null) {
143           toKey.saveToXML(base);
144        }
145        parent.appendChild(base);
146    }
147 }
148
Popular Tags