KickJava   Java API By Example, From Geeks To Geeks.

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


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 personName 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  */

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

46    public PersonName() {
47    }
48
49    /**
50     * Construct the object with required fields.
51     *
52     * @param value String value
53     */

54    public PersonName(String JavaDoc value) {
55       setText(value);
56    }
57
58    /**
59     * Construct the object from a DOM tree. Used by
60     * UDDIProxy to construct an object from a received UDDI
61     * message.
62     *
63     * @param base Element with the name appropriate for this class.
64     *
65     * @exception UDDIException Thrown if DOM tree contains a SOAP fault
66     * or a disposition report indicating a UDDI error.
67     */

68    public PersonName(Element base) throws UDDIException {
69       // Check if it is a fault. Throws an exception if it is.
70
super(base);
71       text = getText(base);
72    }
73
74    public void setText(String JavaDoc s) {
75       text = s;
76    }
77
78    public String JavaDoc getText() {
79       return text;
80    }
81
82    /**
83     * Save an object to the DOM tree. Used to serialize an object
84     * to a DOM tree, usually to send a UDDI message.
85     *
86     * <BR>Used by UDDIProxy.
87     *
88     * @param parent Object will serialize as a child element under the
89     * passed in parent element.
90     */

91    public void saveToXML(Element parent) {
92       base = parent.getOwnerDocument().createElement(UDDI_TAG);
93       // Save attributes.
94
if (text!=null) {
95          base.appendChild(parent.getOwnerDocument().createTextNode(text));
96       }
97       parent.appendChild(base);
98    }
99 }
100
Popular Tags