KickJava   Java API By Example, From Geeks To Geeks.

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


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 java.util.Vector JavaDoc;
12
13 import org.uddi4j.UDDIElement;
14 import org.uddi4j.UDDIException;
15 import org.uddi4j.util.KeyedReference;
16 import org.w3c.dom.Element JavaDoc;
17 import org.w3c.dom.NodeList JavaDoc;
18
19 /**
20  * Represents the sharedRelationships element within the UDDI version 2.0 schema.
21  * This class contains the following types of methods:
22  *
23  * <ul>
24  * <li>A constructor that passes the required fields.
25  * <li>A Constructor that will instantiate the object from an appropriate XML
26  * DOM element.
27  * <li>Get/set methods for each attribute that this element can contain.
28  * <li>A get/setVector method is provided for sets of attributes.
29  * <li>A SaveToXML method that serializes this class within a passed in
30  * 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  * <p>This is a collection element that contains zero or more keyedReference elements.
38  * These elements form part of the RelatedBusinessInfo structure.
39  * The RelatedBusinessInfo structure is a response message to the
40  * find_relatedBusinesses inquiry message.
41  * The information in the keyedReference and businessKey elements, for a specific
42  * businessEntity (present in relatedBusinessInfo structure), represent complete
43  * relationships when they match publisher assertions made by the publisher for each
44  * businessEntity.
45  *
46  * @author Ravi Trivedi (ravi_trivedi@hp.com)
47  */

48 public class SharedRelationships extends UDDIElement {
49
50     public static final String JavaDoc UDDI_TAG = "sharedRelationships";
51
52     public static final String JavaDoc DIRECTION_TOKEY = "toKey";
53     public static final String JavaDoc DIRECTION_FROMKEY = "fromKey";
54
55     protected Element base = null;
56     Vector JavaDoc keyedReference = new Vector JavaDoc();
57     String JavaDoc direction = null;
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
66    public SharedRelationships() {
67    }
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 SharedRelationships(Element base) throws UDDIException {
82      // Check if it is a fault. Throws an exception if it is.
83
super(base);
84      direction = base.getAttribute("direction");
85      NodeList JavaDoc nl = null;
86      nl = getChildElementsByTagName(base, KeyedReference.UDDI_TAG);
87      for (int i=0; i < nl.getLength(); i++) {
88         keyedReference.addElement(new KeyedReference((Element)nl.item(i)));
89      }
90     }
91
92    public Vector JavaDoc getKeyedReferenceVector() {
93        return this.keyedReference;
94    }
95
96    public void setKeyedReferenceVector(Vector JavaDoc keyedReference) {
97        this.keyedReference = keyedReference;
98    }
99
100    public String JavaDoc getDirection() {
101        return direction;
102    }
103
104    public void setDirection(String JavaDoc d) {
105           direction = d ;
106    }
107
108    /**
109     * Save an object to the DOM tree. Used to serialize an object
110     * to a DOM tree, usually to send a UDDI message.
111     *
112     * <BR>Used by UDDIProxy.
113     *
114     * @param parent Object will serialize as a child element under the
115     * passed in parent element.
116     */

117
118    public void saveToXML(Element parent) {
119         base = parent.getOwnerDocument().createElement(UDDI_TAG);
120         if(direction !=null ) {
121             base.setAttribute("direction", direction);
122         }
123
124          // Save attributes
125
if (keyedReference!=null) {
126             for (int i=0; i < keyedReference.size(); i++) {
127                ((KeyedReference)(keyedReference.elementAt(i))).saveToXML(base);
128             }
129          }
130          parent.appendChild(base);
131
132    }
133 }
134
Popular Tags