KickJava   Java API By Example, From Geeks To Geeks.

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


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, International Business Machines Corporation
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.datatype.Name;
14 import org.w3c.dom.Element JavaDoc;
15 import org.w3c.dom.NodeList JavaDoc;
16
17 /**
18  * Represents the tModelInfo element within the UDDI version 2.0 schema.
19  * This class contains the following types of methods:
20  *
21  * <ul>
22  * <li>A constructor that passes the required fields.
23  * <li>A Constructor that will instantiate the object from an appropriate XML
24  * DOM element.
25  * <li>Get/set methods for each attribute that this element can contain.
26  * <li>A get/setVector method is provided for sets of attributes.
27  * <li>A SaveToXML method that serializes this class within a passed in
28  * element.
29  * </ul>
30  *
31  * Typically, this class is used to construct parameters for, or interpret
32  * responses from, methods in the UDDIProxy class.
33  *
34  * <p><b>Element description:</b>
35  * <p>This structure is used to enumerate short form tModel information.
36  *
37  * @author David Melgar (dmelgar@us.ibm.com)
38  * @author Ozzy (ozzy@hursley.ibm.com)
39  */

40 public class TModelInfo extends UDDIElement {
41    public static final String JavaDoc UDDI_TAG = "tModelInfo";
42
43    protected Element base = null;
44
45    String JavaDoc tModelKey = null;
46    Name name = null;
47
48    /**
49     * Default constructor.
50     * Avoid using the default constructor for validation. It does not validate
51     * required fields. Instead, use the required fields constructor to perform
52     * validation.
53     */

54
55    public TModelInfo() {
56    }
57
58    /**
59     * Construct the object with required fields.
60     *
61     * @param tModelKey String
62     * @param name String
63     */

64    public TModelInfo(String JavaDoc tModelKey,
65             String JavaDoc name) {
66       this.tModelKey = tModelKey;
67       this.name = new Name(name);
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 TModelInfo(Element base) throws UDDIException {
82       // Check if it is a fault. Throws an exception if it is.
83
super(base);
84       tModelKey = base.getAttribute("tModelKey");
85       NodeList JavaDoc nl = null;
86       nl = getChildElementsByTagName(base, Name.UDDI_TAG);
87       if (nl.getLength() > 0) {
88          name = new Name((Element)nl.item(0));
89       }
90    }
91
92    public void setTModelKey(String JavaDoc s) {
93       tModelKey = s;
94    }
95
96    public void setName(Name s) {
97       name = s;
98    }
99    public void setName(String JavaDoc s) {
100       name = new Name();
101       name.setText(s);
102    }
103
104    public String JavaDoc getTModelKey() {
105       return tModelKey;
106    }
107
108
109    public Name getName() {
110       return name;
111    }
112
113    public String JavaDoc getNameString() {
114       if(name!=null)
115         return name.getText();
116       else
117         return null;
118    }
119
120    /**
121     * Save an object to the DOM tree. Used to serialize an object
122     * to a DOM tree, usually to send a UDDI message.
123     *
124     * <BR>Used by UDDIProxy.
125     *
126     * @param parent Object will serialize as a child element under the
127     * passed in parent element.
128     */

129
130    public void saveToXML(Element parent) {
131       base = parent.getOwnerDocument().createElement(UDDI_TAG);
132       // Save attributes
133
if (tModelKey!=null) {
134          base.setAttribute("tModelKey", tModelKey);
135       }
136       if (name!=null) {
137          name.saveToXML(base);
138       }
139       parent.appendChild(base);
140    }
141 }
142
Popular Tags