Source code: dtk/gui/TKAddressBookEntry.java
1 //Title: D3E ToolKit
2 //Version:
3 //Copyright: See accompanying license agreement
4 //Author: John Weatherley
5 //Company:
6 //Description: D3E Toolkit
7
8 package dtk.gui;
9
10
11 import dtk.core.*;
12 import java.util.*;
13
14
15 /**
16 This is a container class that holds the information in a single
17 address book entry such as name and e-mail address.
18
19 @see dtk.gui.TKAddressBook TKAddressBook
20 */
21 public class TKAddressBookEntry {
22
23 String first,last,eMail;
24
25 //Constructors
26 public TKAddressBookEntry()
27 {
28 };
29 public TKAddressBookEntry( TKAddressBookEntry en )
30 { set(en.getFirstName(),en.getLastName(),en.getEmail());
31 }
32 public TKAddressBookEntry( String f, String l, String e)
33 { set(f,l,e);
34 }
35
36 /**
37 Sets the first name, last name and eMail address for this TKAddressBookEntry
38
39 @param first First name
40 @param last Last name
41 @param eMail e-mail address
42 */
43 public void set(String first, String last, String eMail)
44 {
45 // Save each while removing whitespace:
46 this.first = first.trim();
47 this.last = last.trim();
48 this.eMail = eMail.trim();
49 }
50
51 /**Returns the first name for this entry*/
52 public String getFirstName()
53 {
54 if(first == null) return "";
55 else return first;
56 }
57
58 /**Returns the last name for this entry*/
59 public String getLastName()
60 {
61 if(last == null) return "";
62 else return last;
63 }
64
65 /**Returns the e-mail for this entry*/
66 public String getEmail()
67 {
68 if(eMail == null) return "";
69 else return eMail;
70 }
71
72 /**Returns a concatination of first last and eMail values for this entry*/
73 public String toString()
74 {
75 return (first + " " + last + " (" + eMail + ")");
76 }
77
78 /**Prints the entry to standard output = used for testing*/
79 public void print ()
80 {
81 TKLog.println(toString());
82 }
83 }