KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > uddi4j > datatype > business > AddressLine


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.datatype.business;
10
11 import org.uddi4j.UDDIElement;
12 import org.uddi4j.UDDIException;
13 import org.w3c.dom.Element JavaDoc;
14
15 /**
16  * Represents the addressLine element within the UDDI version 2.0 schema.
17  * This class contains the following types of methods:
18  *
19  * <ul>
20  * <li>Constructor passing required fields.
21  * <li>Constructor that will instantiate the object from an appropriate XML
22  * DOM element.
23  * <li>Get/set methods for each attribute that this element can contain.
24  * <li>A get/setVector method is provided for sets of attributes.
25  * <li>SaveToXML method. Serializes this class within a passed in element.
26  * </ul>
27  *
28  * Typically, this class is used to construct parameters for, or interpret
29  * responses from methods in the UDDIProxy class.
30  *
31  * @author David Melgar (dmelgar@us.ibm.com)
32  * @author Vivek Chopra (vivek@soaprpc.com)
33  */

34 public class AddressLine extends UDDIElement {
35    public static final String JavaDoc UDDI_TAG = "addressLine";
36
37    protected Element base = null;
38
39    String JavaDoc text = null;
40    String JavaDoc keyName = null;
41    String JavaDoc keyValue = null;
42
43    /**
44     * Default constructor.
45     * Avoid using the default constructor for validation. It does not validate
46     * required fields. Instead, use the required fields constructor to perform
47     * validation.
48     */

49    public AddressLine() {
50    }
51
52    /**
53     * Construct the object with required fields.
54     *
55     * @param value String value
56     */

57    public AddressLine(String JavaDoc value) {
58       setText(value);
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 AddressLine(Element base) throws UDDIException {
73       // Check if its a fault. Throws an exception if it is.
74
super(base);
75       keyName = getAttr(base,"keyName");
76       keyValue = getAttr(base,"keyValue");
77       text = getText(base);
78    }
79
80    private String JavaDoc getAttr(Element base, String JavaDoc attrname)
81    {
82      if(base.getAttributeNode(attrname)!=null && base.getAttributeNode(attrname).getSpecified() )
83      {
84        return base.getAttribute(attrname);
85      }
86      return null;
87    }
88
89
90    /**
91     * Set the (optional) keyName attribute
92     */

93    public void setKeyName (String JavaDoc keyName) {
94       this.keyName = keyName;
95    }
96
97    /**
98     * Set the (optional) keyValue attribute
99     */

100    public void setKeyValue (String JavaDoc keyValue) {
101       this.keyValue = keyValue;
102    }
103
104    public void setText(String JavaDoc s) {
105       text = s;
106    }
107
108    public String JavaDoc getKeyName () {
109       return keyName;
110    }
111
112    public String JavaDoc getKeyValue () {
113       return keyValue;
114    }
115
116    public String JavaDoc getText() {
117       return text;
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    public void saveToXML(Element parent) {
130       base = parent.getOwnerDocument().createElement(UDDI_TAG);
131       // Save attributes
132

133       if (keyName != null) {
134          base.setAttribute("keyName", keyName);
135       }
136
137       if (keyValue != null) {
138          base.setAttribute("keyValue", keyValue);
139       }
140
141       if (text!=null) {
142          base.appendChild(parent.getOwnerDocument().createTextNode(text));
143       }
144       parent.appendChild(base);
145    }
146 }
147
Popular Tags