KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > juddi > datatype > business > Contact


1 /*
2  * Copyright 2001-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.apache.juddi.datatype.business;
17
18 import java.util.Vector JavaDoc;
19
20 import org.apache.juddi.datatype.Address;
21 import org.apache.juddi.datatype.Description;
22 import org.apache.juddi.datatype.Email;
23 import org.apache.juddi.datatype.PersonName;
24 import org.apache.juddi.datatype.Phone;
25 import org.apache.juddi.datatype.RegistryObject;
26
27 /**
28  * A businessEntity has a "contacts" attribute which is a collection of these.
29  * Holds the "human contact" information.
30  *
31  * @author Steve Viens (sviens@apache.org)
32  */

33 //public class Contact extends Person implements RegistryObject
34
public class Contact implements RegistryObject
35 {
36   String JavaDoc useType;
37   Vector JavaDoc descVector;
38   String JavaDoc personName;
39   Vector JavaDoc phoneVector;
40   Vector JavaDoc emailAddrVector;
41   Vector JavaDoc addressVector;
42
43   /**
44    * Construct a new initialized Contact instance.
45    */

46   public Contact()
47   {
48   }
49
50   /**
51    * Construct a new contact with a given name. The given name is the name of
52    * the person or the name of the persons job role, e.g. "administrator",
53    * "webmaster", etc.
54    *
55    * @param name The name of the contact.
56    */

57   public Contact(String JavaDoc name)
58   {
59     this.setPersonNameValue(name);
60   }
61
62   /**
63    * Construct a new contact with a given UseType and Name. The given name is
64    * the name of the person or the name of the persons job role, e.g.
65    * "administrator", "webmaster", etc. The UseType is used to describe
66    * the contact in freeform text. Examples are: "technical questions", "sales
67    * contact", etc.
68    *
69    * @param name The UseType of the contact.
70    * @param type The Name of the contact.
71    */

72   public Contact(String JavaDoc name,String JavaDoc type)
73   {
74     this(name);
75     this.useType = type;
76   }
77
78   /**
79     * Add an description to this contact.
80     *
81     * @param description The description to add to this contact.
82     */

83    public void addDescription(Description description)
84    {
85      if (this.descVector == null)
86        this.descVector = new Vector JavaDoc();
87      this.descVector.add(description);
88    }
89
90    /**
91     * Set the descriptions of this contact replacing the old
92     *
93     * @param descriptions
94     */

95    public void setDescriptionVector(Vector JavaDoc descriptions)
96    {
97      this.descVector = descriptions;
98    }
99
100    /**
101     * Returns the descriptions of this contact.
102     *
103     * @return The descriptions of this contact. If this contact has no
104     * descriptions, null is returned.
105     */

106    public Vector JavaDoc getDescriptionVector()
107    {
108      return this.descVector;
109    }
110
111   /**
112    * Sets the usetype of this contact to the given usetype. The usetype is
113    * used to describe the contact in freeform text. Examples are: "technical
114    * questions", "sales contact", etc.
115    *
116    * @param type The usetype of this contact.
117    */

118   public void setUseType(String JavaDoc type)
119   {
120     this.useType = type;
121   }
122
123   /**
124    * Returns the usetype of this contact. The usetype is used to describe
125    * the contact in freeform text. Examples are: "technical questions",
126    * "sales contact", etc.
127    *
128    * @return The usetype of this contact, or null if this contact doesn't
129    * have a usetype.
130    */

131   public String JavaDoc getUseType()
132   {
133     return useType;
134   }
135
136   /**
137    * Returns the name of this person. The name can be the name of this
138    * person or it can be the role of this person. Examples are
139    * "administrator", "webmaster", etc.
140    *
141    * @return The name of this person.
142    */

143   public String JavaDoc getPersonNameValue()
144   {
145     return personName;
146   }
147
148   /**
149    * Returns the name of this person. The name can be the name of this
150    * person or it can be the role of this person. Examples are
151    * "administrator", "webmaster", etc.
152    *
153    * @return The name of this person as a PersonName.
154    */

155   public PersonName getPersonName()
156   {
157     if (this.personName == null)
158       return null;
159     else
160       return new PersonName(this.personName);
161   }
162
163   /**
164    * Sets the name of this person to the given name. The name can be
165    * the name of the person or it can be the role of this person, e.g.
166    * "administrator", "webmaster", etc.
167    *
168    * @param name The new name of this person.
169    */

170   public void setPersonNameValue(String JavaDoc name)
171   {
172     this.personName = name;
173   }
174
175   /**
176    * Sets the name of this person to the given name. The name can be
177    * the name of the person or it can be the role of this person, e.g.
178    * "administrator", "webmaster", etc.
179    *
180    * @param personName The new name of this person.
181    */

182   public void setPersonName(PersonName personName)
183   {
184     if (personName != null)
185       this.personName = personName.getValue();
186     else
187       this.personName = null;
188   }
189
190   /**
191    * Add an address to this person.
192    *
193    * @param address The address to add to this person.
194    */

195   public void addAddress(Address address)
196   {
197     // just return if the Address parameter is null (nothing to add)
198
if (address == null)
199       return;
200
201     if (this.addressVector == null)
202       this.addressVector = new Vector JavaDoc();
203     this.addressVector.add(address);
204   }
205
206   /**
207    * Set the addresses of this person replacing the old
208    *
209    * @param adds
210    */

211   public void setAddressVector(Vector JavaDoc adds)
212   {
213     this.addressVector = adds;
214   }
215
216   /**
217    * Returns the addresses of this person.
218    *
219    * @return The addresses of this person. If this person
220    * has no addresses, an empty enumeration is returned.
221    */

222   public Vector JavaDoc getAddressVector()
223   {
224     return this.addressVector;
225   }
226
227   /**
228    * Add a phone to this person.
229    *
230    * @param phone The phone to add to this person.
231    */

232   public void addPhone(Phone phone)
233   {
234     // just return if the Phone parameter is null (nothing to add)
235
if (phone == null)
236       return;
237
238     if (this.phoneVector == null)
239       this.phoneVector = new Vector JavaDoc();
240     this.phoneVector.add(phone);
241   }
242
243   /**
244    * Set a collection of phone numbers to this person
245    * replacing the old.
246    *
247    * @param phones The vector of new Phone instances to
248    * this person.
249    */

250   public void setPhoneVector(Vector JavaDoc phones)
251   {
252     this.phoneVector = phones;
253   }
254
255   /**
256    * Returns the phones of this person.
257    *
258    * @return The phones of this person. If this person
259    * doesn't have any phones, an empty enumeration is
260    * returned.
261    */

262   public Vector JavaDoc getPhoneVector()
263   {
264     return this.phoneVector;
265   }
266
267   /**
268    * Add an emailaddress to this person.
269    *
270    * @param email The email address to add to this person.
271    */

272   public void addEmail(Email email)
273   {
274     // just return if the Email parameter is null (nothing to add)
275
if (email == null)
276       return;
277
278     if (this.emailAddrVector == null)
279       this.emailAddrVector = new Vector JavaDoc();
280     this.emailAddrVector.add(email);
281   }
282
283   /**
284    * Sets a collection of email-addresses to this person
285    * replacing the old one
286    *
287    * @param emailAddresses
288    */

289   public void setEmailVector(Vector JavaDoc emailAddresses)
290   {
291     this.emailAddrVector = emailAddresses;
292   }
293
294   /**
295    * Returns the email addresses of this person.
296    *
297    * @return The emailaddresses of this person. If this person
298    * doesn't have any emailaddresses, an empty enumeration is
299    * returned.
300    */

301   public Vector JavaDoc getEmailVector()
302   {
303     return this.emailAddrVector;
304   }
305 }
Popular Tags