KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > killingar > forum > internal > User


1 /* Copyright 2000-2005 Anders Hovmöller
2  *
3  * The person or persons who have associated their work with
4  * this document (the "Dedicator") hereby dedicate the entire
5  * copyright in the work of authorship identified below (the
6  * "Work") to the public domain.
7  *
8  * Dedicator makes this dedication for the benefit of the
9  * public at large and to the detriment of Dedicator's heirs
10  * and successors. Dedicator intends this dedication to be an
11  * overt act of relinquishment in perpetuity of all present
12  * and future rights under copyright law, whether vested or
13  * contingent, in the Work. Dedicator understands that such
14  * relinquishment of all rights includes the relinquishment of
15  * all rights to enforce (by lawsuit or otherwise) those
16  * copyrights in the Work.
17  *
18  * Dedicator recognizes that, once placed in the public
19  * domain, the Work may be freely reproduced, distributed,
20  * transmitted, used, modified, built upon, or otherwise
21  * exploited by anyone for any purpose, commercial or non-
22  * commercial, and in any way, including by methods that have
23  * not yet been invented or conceived.
24  */

25
26 /**
27  * Describes a user.
28  */

29 package net.killingar.forum.internal;
30
31 import net.killingar.forum.internal.managers.ForumManager;
32
33 import java.sql.Date JavaDoc;
34
35 public class User extends NamedItemImpl
36 {
37     public String JavaDoc
38         email, // the viewable email (for ease of use)
39
icq,
40         telephone,
41         mobilephone,
42         address,
43         other,
44         realName,
45
46         // the email fields separated
47
publicEmail,
48         restrictedEmail,
49         secretEmail;
50
51     public Date JavaDoc birthdate;
52
53     public User()
54     {
55         super(-1, "");
56     }
57
58     public User(
59         long _ID,
60         String JavaDoc _name,
61         String JavaDoc _publicEmail)
62     {
63         super(_ID, _name);
64
65         publicEmail = _publicEmail != null && _publicEmail.length() == 0? null: _publicEmail;
66     }
67
68     public User(
69         long _ID,
70         String JavaDoc _name,
71         String JavaDoc _publicEmail,
72         String JavaDoc _restrictedEmail,
73         String JavaDoc _secretEmail,
74         String JavaDoc _icq,
75         String JavaDoc _telephone,
76         String JavaDoc _mobilephone,
77         String JavaDoc _address,
78         String JavaDoc _other,
79         String JavaDoc _realName,
80         Date JavaDoc _birthdate)
81     {
82         super(_ID, _name);
83
84         publicEmail = _publicEmail != null && _publicEmail.length() == 0? null: _publicEmail;
85         restrictedEmail = _restrictedEmail != null && _restrictedEmail.length() == 0? null: _restrictedEmail;
86         secretEmail = _secretEmail != null && _secretEmail.length() == 0? null: _secretEmail;
87         icq = _icq != null && _icq.length() == 0? null: _icq;
88         telephone = _telephone != null && _telephone.length() == 0? null: _telephone;
89         mobilephone = _mobilephone != null && _mobilephone.length() == 0? null: _mobilephone;
90         address = _address != null && _address.length() == 0? null: _address;
91         other = _other != null && _other.length() == 0? null: _other;
92         realName = _realName != null && _realName.length() == 0? null: _realName;
93         birthdate = _birthdate == null || _birthdate.getTime() == 0 || _birthdate.getTime() == -2208992400000L? null: _birthdate;
94
95         email = publicEmail;
96         if (restrictedEmail != null)
97             email = restrictedEmail;
98
99         if (email != null && email.length() == 0)
100             email = null;
101
102     }
103
104     public User(User user)
105     {
106         this(
107             user.ID,
108             user.name,
109             user.publicEmail,
110             user.restrictedEmail,
111             user.secretEmail,
112             user.icq,
113             user.telephone,
114             user.mobilephone,
115             user.address,
116             user.other,
117             user.realName,
118             user.birthdate);
119     }
120
121     public String JavaDoc getEmail() { return email; }
122     public String JavaDoc getIcq() { return icq; }
123     public String JavaDoc getTelephone() { return telephone; }
124     public String JavaDoc getMobilephone() { return mobilephone; }
125     public String JavaDoc getAddress() { return address; }
126     public String JavaDoc getOther() { return other; }
127     public String JavaDoc getRealName() { return realName; }
128     public String JavaDoc getPublicEmail() { return publicEmail; }
129     public String JavaDoc getRestrictedEmail() { return restrictedEmail; }
130     public String JavaDoc getSecretEmail(ForumManager mgr) { return mgr.getUserID() == getId()? secretEmail : null; }
131     public Date JavaDoc getBirthdate() { return birthdate; }
132
133     public String JavaDoc toString() { return getName(); }
134 }
Popular Tags