KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > uddi4j > datatype > assertion > PublisherAssertion


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.datatype.assertion;
10
11 import org.uddi4j.UDDIElement;
12 import org.uddi4j.UDDIException;
13 import org.uddi4j.util.FromKey;
14 import org.uddi4j.util.KeyedReference;
15 import org.uddi4j.util.ToKey;
16 import org.w3c.dom.Element JavaDoc;
17 import org.w3c.dom.NodeList JavaDoc;
18
19 /**
20  * <p>
21  * Represents the publisherAssertion element within the UDDI version 2.0 schema.
22  * This class contains the following types of methods:
23  *
24  * <ul>
25  * <li>Constructor passing the required fields.
26  * <li>Constructor that will instantiate the object from an appropriate XML
27  * DOM element.
28  * <li>Get/set methods for each attribute that this element can contain.
29  * <li>For sets of attributes, a get/setVector method is provided.
30  * <li>SaveToXML method. Serializes this class within a passed in element.
31  * </ul>
32  *
33  * Typically this class is used to construct parameters for, or interpret
34  * responses from, methods in the UDDIProxy class.
35  *
36  * <p><b>Element description:</b>
37  *
38  * <p>UDDI version 2.0 introduces an assertion feature based on "publisher
39  * assertions". Publisher assertions are the basis for a mechanism to
40  * that allows more than one registered businessEntity element to be
41  * linked in a manner that conveys a specific type of relationship.
42  * This is why the feature is sometimes called the relationship feature.
43  * Publisher assertions are used to establish visible relationships between
44  * registered data and a set of assertions. This relationship can be seen by
45  * a general inquiry message (named "find_relatedBusinesses").
46  *
47  * @author Mahesh C S (csmahesh@india.hp.com)
48  */

49 public class PublisherAssertion extends UDDIElement {
50    public static final String JavaDoc UDDI_TAG = "publisherAssertion";
51
52    protected Element base = null;
53
54    FromKey fromKey = null;
55    ToKey toKey = null;
56    KeyedReference keyedReference = null;
57
58
59    /**
60     * Default constructor.
61     * Avoid using the default constructor for validation. It does not validate
62     * required fields. Instead, use the required fields constructor to perform
63     * validation.
64     */

65    public PublisherAssertion() {
66    }
67
68    /**
69     * Construct the object with required fields.
70     *
71     * @param fromKey String
72     * @param toKey String
73     * @param keyRef KeyedReference
74     */

75    public PublisherAssertion(String JavaDoc fromKey, String JavaDoc toKey ,
76                              KeyedReference keyRef) {
77         this.fromKey = new FromKey(fromKey);
78         this.toKey = new ToKey(toKey);
79         this.keyedReference = keyRef;
80    }
81
82    /**
83     * Construct the object from a DOM tree. Used by
84     * UDDIProxy to construct an object from a received UDDI
85     * message.
86     *
87     * @param base Element with the name appropriate for this class.
88     * @exception UDDIException Thrown if DOM tree contains a SOAP fault
89     * or a disposition report indicating a UDDI error.
90     */

91    public PublisherAssertion(Element base) throws UDDIException {
92        // Check if it is a fault. Throws an exception if it is.
93
super(base);
94        NodeList JavaDoc nl = null;
95        nl = getChildElementsByTagName(base, FromKey.UDDI_TAG);
96        if (nl.getLength() > 0) {
97           fromKey = new FromKey((Element)nl.item(0));
98        }
99        nl = getChildElementsByTagName(base, ToKey.UDDI_TAG);
100        if (nl.getLength() > 0) {
101           toKey = new ToKey((Element)nl.item(0));
102        }
103        nl = getChildElementsByTagName(base, KeyedReference.UDDI_TAG);
104        if (nl.getLength() > 0) {
105           keyedReference = new KeyedReference((Element)nl.item(0));
106        }
107    }
108
109    public String JavaDoc getFromKeyString() {
110        return fromKey.getText();
111    }
112
113    public void setFromKeyString(String JavaDoc s) {
114        fromKey = new FromKey();
115        fromKey.setText(s);
116    }
117
118    public String JavaDoc getToKeyString() {
119        return toKey.getText();
120    }
121
122    public void setToKeyString(String JavaDoc s) {
123        toKey = new ToKey();
124        toKey.setText(s);
125    }
126
127    public FromKey getFromKey() {
128        return fromKey;
129    }
130
131    public void setFromKey(FromKey key) {
132        fromKey = key;
133    }
134
135    public ToKey getToKey() {
136        return toKey;
137    }
138
139    public void setToKey(ToKey key) {
140        toKey = key;
141    }
142
143    public KeyedReference getKeyedReference() {
144        return keyedReference;
145    }
146
147    public void setKeyedReference(KeyedReference r ) {
148        keyedReference = r;
149    }
150
151    /**
152     * Save an object to the DOM tree. Used to serialize an object
153     * to a DOM tree, usually to send a UDDI message.
154     *
155     * <BR>Used by UDDIProxy.
156     *
157     * @param parent Object will serialize as a child element under the
158     * passed in parent element.
159     */

160    public void saveToXML(Element parent) {
161        base = parent.getOwnerDocument().createElement(UDDI_TAG);
162
163        if (fromKey!=null) {
164           fromKey.saveToXML(base);
165        }
166        if (toKey!=null) {
167           toKey.saveToXML(base);
168        }
169        if (keyedReference!=null) {
170           keyedReference.saveToXML(base);
171        }
172
173        parent.appendChild(base);
174    }
175 }
176
Popular Tags