KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > uddi4j > request > ValidateValues


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.request;
10
11 import java.util.Vector JavaDoc;
12
13 import org.uddi4j.UDDIElement;
14 import org.uddi4j.UDDIException;
15 import org.uddi4j.datatype.business.BusinessEntity;
16 import org.uddi4j.datatype.service.BusinessService;
17 import org.uddi4j.datatype.tmodel.TModel;
18 import org.w3c.dom.Element JavaDoc;
19 import org.w3c.dom.NodeList JavaDoc;
20
21 /**
22  * Represents the validate_values element within the UDDI version 2.0 schema.
23  * This class contains the following types of methods:
24  *
25  * <ul>
26  * <li>A constructor that passes the required fields.
27  * <li>A Constructor that will instantiate the object from an appropriate XML
28  * DOM element.
29  * <li>Get/set methods for each attribute that this element can contain.
30  * <li>A get/setVector method is provided for sets of attributes.
31  * <li>A SaveToXML method that serializes this class within a passed in
32  * element.
33  * </ul>
34  *
35  * Typically, this class is used to construct parameters for, or interpret
36  * responses from, methods in the UDDIProxy class.
37  *
38  * <p><b>Element description:</b>
39  * <p>validate_values is used is to verify that specific categories or identifiers
40  * (checking the keyValue attribute values supplied) exist within the given
41  * taxonomy or identifier system.
42  *
43  * @author Rajesh Sumra (rajesh_sumra@hp.com)
44  * @author Arulazi D (arulazi_d@hp.com)
45  */

46 public class ValidateValues extends UDDIElement {
47    public static final String JavaDoc UDDI_TAG = "validate_values";
48
49    protected Element base = null;
50
51    Vector JavaDoc businessServiceVector = new Vector JavaDoc();
52    Vector JavaDoc businessEntityVector = new Vector JavaDoc();
53    Vector JavaDoc tModelVector = new Vector JavaDoc();
54
55    /**
56     * Default constructor.
57     * Avoid using the default constructor for validation. It does not validate
58     * required fields. Instead, use the required fields constructor to perform
59     * validation.
60     */

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

74    public ValidateValues(Element base) throws UDDIException {
75       // Check if its a fault. Throw exception if it is
76
super(base);
77       NodeList JavaDoc nl = null;
78
79       nl = getChildElementsByTagName(base, BusinessEntity.UDDI_TAG);
80       for (int i=0; i < nl.getLength(); i++) {
81           businessEntityVector.addElement(new BusinessEntity((Element)nl.item(i)));
82       }
83
84       nl = getChildElementsByTagName(base, BusinessService.UDDI_TAG);
85       for (int i=0; i < nl.getLength(); i++) {
86           businessServiceVector.addElement(new BusinessService((Element)nl.item(i)));
87       }
88
89       nl = getChildElementsByTagName(base, TModel.UDDI_TAG);
90       for (int i=0; i < nl.getLength(); i++) {
91           tModelVector.addElement(new TModel((Element)nl.item(i)));
92       }
93    }
94
95    public Vector JavaDoc getBusinessServiceVector() {
96        return this.businessServiceVector;
97    }
98
99    public void setBusinessServiceVector(Vector JavaDoc businessService) {
100        this.businessServiceVector = businessService;
101    }
102
103    public Vector JavaDoc getBusinessEntityVector() {
104        return this.businessEntityVector;
105    }
106
107    public void setBusinessEntityVector(Vector JavaDoc businessEntity) {
108        this.businessEntityVector = businessEntity;
109    }
110
111    public Vector JavaDoc getTModelVector() {
112        return this.tModelVector;
113    }
114
115    public void setTModelVector(Vector JavaDoc tModel) {
116        this.tModelVector = tModel;
117    }
118
119    /**
120     * Save an object to the DOM tree. Used to serialize an object
121     * to a DOM tree, usually to send a UDDI message.
122     *
123     * <BR>Used by UDDIProxy.
124     *
125     * @param parent Object will serialize as a child element under the
126     * passed in parent element.
127     */

128    public void saveToXML(Element parent) {
129        base = parent.getOwnerDocument().createElement(UDDI_TAG);
130        // Save attributes.
131
base.setAttribute("generic", UDDIElement.GENERIC);
132        base.setAttribute("xmlns", UDDIElement.XMLNS);
133        if (businessEntityVector!=null) {
134          for (int i=0; i < businessEntityVector.size(); i++) {
135             ((BusinessEntity)(businessEntityVector.elementAt(i))).saveToXML(base);
136          }
137        }
138        if (businessServiceVector!=null) {
139          for (int i=0; i < businessServiceVector.size(); i++) {
140             ((BusinessService)(businessServiceVector.elementAt(i))).saveToXML(base);
141          }
142        }
143        if (tModelVector!=null) {
144          for (int i=0; i < tModelVector.size(); i++) {
145             ((TModel)(tModelVector.elementAt(i))).saveToXML(base);
146          }
147        }
148
149        parent.appendChild(base);
150    }
151 }
152
Popular Tags