KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > javabb > vo > User


1 package org.javabb.vo;
2
3 import java.io.Serializable JavaDoc;
4 import java.util.Date JavaDoc;
5 import java.util.Set JavaDoc;
6
7 import org.apache.commons.lang.builder.HashCodeBuilder;
8 import org.apache.commons.lang.builder.ToStringBuilder;
9 import org.javabb.bbcode.ProcessBBCode;
10
11 /*
12  * Copyright 2004 JavaFree.org
13  *
14  * Licensed under the Apache License, Version 2.0 (the "License");
15  * you may not use this file except in compliance with the License.
16  * You may obtain a copy of the License at
17  *
18  * http://www.apache.org/licenses/LICENSE-2.0
19  *
20  * Unless required by applicable law or agreed to in writing, software
21  * distributed under the License is distributed on an "AS IS" BASIS,
22  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
23  * See the License for the specific language governing permissions and
24  * limitations under the License.
25  */

26
27 /**
28  * $Id: User.java,v 1.19.2.1.6.4 2006/08/01 22:30:41 daltoncamargo Exp $
29  * @author Dalton Camargo - <a HREF="mailto:dalton@javabb.org">dalton@javabb.org </a> <br>
30  * @author Ronald Tetsuo Miura
31  */

32 public class User extends VOObject implements Serializable JavaDoc {
33
34     private static final long serialVersionUID = 1L;
35
36     /** nullable persistent field */
37     private String JavaDoc user;
38
39     /** nullable persistent field */
40     private String JavaDoc passwordHash;
41
42     /** nullable persistent field */
43     private String JavaDoc name;
44
45     /** nullable persistent field */
46     private String JavaDoc email;
47
48     /** nullable persistent field */
49     private Long JavaDoc user_posts;
50
51     private Integer JavaDoc admin;
52
53     private Date JavaDoc dataRegistro;
54
55     /** persistent field */
56     private Set JavaDoc posts;
57
58     /** persistent field */
59     private Set JavaDoc topics;
60
61     /** nullable persistent field */
62     private String JavaDoc localizacao;
63
64     /** nullable persistent field */
65     private String JavaDoc website;
66
67     /** nullable persistent field */
68     private String JavaDoc occupation;
69
70     /** nullable persistent field */
71     private String JavaDoc userSig;
72
73     /** nullable persistent field */
74     private String JavaDoc user_avatar;
75
76     /** nullable persistent field */
77     private String JavaDoc user_icq;
78
79     /** nullable persistent field */
80     private String JavaDoc user_interests;
81
82     /** nullable persistent field */
83     private String JavaDoc user_sig;
84
85     /** nullable persistent field */
86     private String JavaDoc user_aim;
87
88     /** nullable persistent field */
89     private String JavaDoc user_yim;
90
91     /** nullable persistent field */
92     private String JavaDoc user_msnm;
93
94     /** nullable persistent field */
95     private Date JavaDoc _lastVisitTimestamp;
96
97     /** nullable persistent field */
98     private Date JavaDoc user_lastvisit;
99
100     /** nullable persistent field */
101     private String JavaDoc user_dateformat;
102
103     /** nullable persistent field */
104     private String JavaDoc user_allow_viewonline;
105     
106     /** nullable persistent field */
107     private String JavaDoc hash_fpwd;
108
109     /** nullable persistent field */
110     private Integer JavaDoc show_mail;
111
112     /** nullable persistent field */
113     private Integer JavaDoc show_signature;
114
115     /** nullable persistent field */
116     private Integer JavaDoc userStatus;
117
118     /** nullable persistent field */
119     private String JavaDoc userCode;
120     
121     private Set JavaDoc forumTopUsers;
122
123     // TODO Dependency Injection
124
private ProcessBBCode postFormatter = new ProcessBBCode();
125
126     private Set JavaDoc answerNotifies;
127     
128     private Set JavaDoc favUserTopics;
129     
130     /**
131      * @param id
132      * @param user
133      * @param passwordHash
134      * @param name
135      * @param email
136      * @param user_posts
137      * @param posts
138      * @param topics
139      */

140     public User(Long JavaDoc id, String JavaDoc user, String JavaDoc passwordHash, String JavaDoc name, String JavaDoc email,
141         Long JavaDoc user_posts, Set JavaDoc posts, Set JavaDoc topics) {
142         setId(id);
143         this.user = user;
144         this.passwordHash = passwordHash;
145         this.name = name;
146         this.email = email;
147         this.posts = posts;
148         this.posts = posts;
149         this.topics = topics;
150         this.user_posts = user_posts;
151     }
152
153     /**
154      * Default constructor.
155      */

156     public User() {
157         // do nothing
158
}
159
160     /**
161      * @param id
162      * @param posts
163      * @param topics
164      */

165     public User(Long JavaDoc id, Set JavaDoc posts, Set JavaDoc topics) {
166         setId(id);
167         this.posts = posts;
168         this.topics = topics;
169     }
170
171     /**
172      * @param id
173      */

174     public User(Long JavaDoc id) {
175         setId(id);
176     }
177     
178     /**
179      * @return the user ID
180      */

181     public Long JavaDoc getIdUser() {
182         return getId();
183     }
184
185     /**
186      * @param idUser
187      */

188     public void setIdUser(Long JavaDoc idUser) {
189         this.setId(idUser);
190     }
191
192     /**
193      * @return the username
194      */

195     public String JavaDoc getUser() {
196         return this.user;
197     }
198
199     /**
200      * @param user
201      */

202     public void setUser(String JavaDoc user) {
203         this.user = user;
204     }
205
206     /**
207      * @return passwordHash
208      */

209     public String JavaDoc getPasswordHash() {
210         return this.passwordHash;
211     }
212
213     /**
214      * @param passwordHash
215      */

216     public void setPasswordHash(String JavaDoc passwordHash) {
217         this.passwordHash = passwordHash;
218     }
219
220     /**
221      * @return the user name
222      */

223     public String JavaDoc getName() {
224         return this.name;
225     }
226
227     /**
228      * @param name
229      */

230     public void setName(String JavaDoc name) {
231         this.name = name;
232     }
233
234     /**
235      * @return email
236      */

237     public String JavaDoc getEmail() {
238         return this.email;
239     }
240
241     /**
242      * @param email
243      */

244     public void setEmail(String JavaDoc email) {
245         this.email = email;
246     }
247
248     /**
249      * @return posts
250      */

251     public Set JavaDoc getPosts() {
252         return this.posts;
253     }
254
255     /**
256      * @param posts
257      */

258     public void setPosts(Set JavaDoc posts) {
259         this.posts = posts;
260     }
261
262     /**
263      * @return Returns the topics' value
264      */

265     public Set JavaDoc getTopics() {
266         return this.topics;
267     }
268
269     /**
270      * @param topics
271      */

272     public void setTopics(Set JavaDoc topics) {
273         this.topics = topics;
274     }
275
276     /**
277      * @see java.lang.Object#toString()
278      */

279     public String JavaDoc toString() {
280         return new ToStringBuilder(this).append("idUser", getIdUser()).toString();
281     }
282
283     /**
284      * @see java.lang.Object#equals(java.lang.Object)
285      */

286     public boolean equals(Object JavaDoc other) {
287         if (!(other instanceof User)) {
288             return false;
289         }
290
291         User castOther = (User) other;
292
293         //return new EqualsBuilder().append(this.getIdUser(), castOther.getIdUser()).isEquals();
294
if(this.getIdUser().longValue() == castOther.getIdUser().longValue()){
295             return true;
296         } else {
297             return false;
298         }
299     }
300
301     /**
302      * @see java.lang.Object#hashCode()
303      */

304     public int hashCode() {
305         return new HashCodeBuilder().append(getIdUser()).toHashCode();
306     }
307
308     /**
309      * @return Returns the user_posts.
310      */

311     public Long JavaDoc getUser_posts() {
312         return user_posts;
313     }
314
315     /**
316      * @param user_posts The user_posts to set.
317      */

318     public void setUser_posts(Long JavaDoc user_posts) {
319         this.user_posts = user_posts;
320     }
321
322     /**
323      * @return Returns the admin.
324      */

325     public Integer JavaDoc getAdmin() {
326         return admin;
327     }
328
329     /**
330      * @param admin The admin to set.
331      */

332     public void setAdmin(Integer JavaDoc admin) {
333         this.admin = admin;
334     }
335
336     /**
337      * @return Returns the admin.
338      */

339     public boolean isAdministrator() {
340         return getAdmin().intValue() == 1;
341     }
342
343     /**
344      * @return Returns the dataRegistro.
345      */

346     public Date JavaDoc getDataRegistro() {
347         return dataRegistro;
348     }
349
350     /**
351      * @param dataRegistro The dataRegistro to set.
352      */

353     public void setDataRegistro(Date JavaDoc dataRegistro) {
354         this.dataRegistro = dataRegistro;
355     }
356
357
358     /**
359      * @return Returns the localizacao.
360      */

361     public String JavaDoc getLocalizacao() {
362         return localizacao;
363     }
364
365     /**
366      * @param localizacao The localizacao to set.
367      */

368     public void setLocalizacao(String JavaDoc localizacao) {
369         this.localizacao = localizacao;
370     }
371
372     /**
373      * @return Returns the website.
374      */

375     public String JavaDoc getWebsite() {
376         return website;
377     }
378
379     /**
380      * @param website The website to set.
381      */

382     public void setWebsite(String JavaDoc website) {
383         this.website = website;
384     }
385
386     /**
387      * @return Returns the occupation.
388      */

389     public String JavaDoc getOccupation() {
390         return occupation;
391     }
392
393     /**
394      * @param occupation The occupation to set.
395      */

396     public void setOccupation(String JavaDoc occupation) {
397         this.occupation = occupation;
398     }
399
400     /**
401      * @return Returns the userSig.
402      */

403     public String JavaDoc getUserSig() {
404         return userSig;
405     }
406
407     /**
408      * TODO Deveria estar em outro lugar. Mesmo na view mas não aqui.
409      * @return Returns the userSig.
410      */

411     public String JavaDoc getUserSig_formated() {
412         String JavaDoc ret;
413         try {
414             postFormatter.setAcceptHTML(false);
415             postFormatter.setAcceptBBCode(true);
416             ret = postFormatter.preparePostText(getUserSig());
417         } catch (Exception JavaDoc e) {
418             ret = userSig;
419         }
420         return ret;
421     }
422
423     /**
424      * @param userSig The userSig to set.
425      */

426     public void setUserSig(String JavaDoc userSig) {
427         this.userSig = userSig;
428     }
429
430     /**
431      * @return Returns the user_aim.
432      */

433     public String JavaDoc getUser_aim() {
434         return user_aim;
435     }
436
437     /**
438      * @param user_aim The user_aim to set.
439      */

440     public void setUser_aim(String JavaDoc user_aim) {
441         this.user_aim = user_aim;
442     }
443     
444     /**
445      * @return Returns the hash_fpwd.
446      */

447     public String JavaDoc getHash_fpwd() {
448         return hash_fpwd;
449     }
450
451     /**
452      * @param user_aim The hash_fpwd to set.
453      */

454     public void setHash_fpwd(String JavaDoc hash_fpwd) {
455         this.hash_fpwd = hash_fpwd;
456     }
457
458     /**
459      * @return Returns the user_avatar.
460      */

461     public String JavaDoc getUser_avatar() {
462         return user_avatar;
463     }
464
465     /**
466      * @param user_avatar The user_avatar to set.
467      */

468     public void setUser_avatar(String JavaDoc user_avatar) {
469         this.user_avatar = user_avatar;
470     }
471
472     /**
473      * @return Returns the user_dateformat.
474      */

475     public String JavaDoc getUser_dateformat() {
476         return user_dateformat;
477     }
478
479     /**
480      * @param user_dateformat The user_dateformat to set.
481      */

482     public void setUser_dateformat(String JavaDoc user_dateformat) {
483         this.user_dateformat = user_dateformat;
484     }
485
486     /**
487      * @return Returns the user_icq.
488      */

489     public String JavaDoc getUser_icq() {
490         return user_icq;
491     }
492
493     /**
494      * @param user_icq The user_icq to set.
495      */

496     public void setUser_icq(String JavaDoc user_icq) {
497         this.user_icq = user_icq;
498     }
499
500     /**
501      * @return Returns the user_interests.
502      */

503     public String JavaDoc getUser_interests() {
504         return user_interests;
505     }
506
507     /**
508      * @param user_interests The user_interests to set.
509      */

510     public void setUser_interests(String JavaDoc user_interests) {
511         this.user_interests = user_interests;
512     }
513
514     /**
515      * @return Returns the user_msnm.
516      */

517     public String JavaDoc getUser_msnm() {
518         return user_msnm;
519     }
520
521     /**
522      * @param user_msnm The user_msnm to set.
523      */

524     public void setUser_msnm(String JavaDoc user_msnm) {
525         this.user_msnm = user_msnm;
526     }
527
528     /**
529      * @return Returns the user_sig.
530      */

531     public String JavaDoc getUser_sig() {
532         return user_sig;
533     }
534
535     /**
536      * @param user_sig The user_sig to set.
537      */

538     public void setUser_sig(String JavaDoc user_sig) {
539         this.user_sig = user_sig;
540     }
541
542     /**
543      * @return Returns the user_yim.
544      */

545     public String JavaDoc getUser_yim() {
546         return user_yim;
547     }
548
549     /**
550      * @param user_yim The user_yim to set.
551      */

552     public void setUser_yim(String JavaDoc user_yim) {
553         this.user_yim = user_yim;
554     }
555
556     /**
557      * @return Returns the user_lastvisit.
558      */

559     public Date JavaDoc getUser_lastvisit() {
560         return user_lastvisit;
561     }
562
563     /**
564      * @param user_lastvisit The user_lastvisit to set.
565      */

566     public void setUser_lastvisit(Date JavaDoc user_lastvisit) {
567         this.user_lastvisit = user_lastvisit;
568     }
569
570     /**
571      * @return Returns the user_allow_viewonline.
572      */

573     public String JavaDoc getUser_allow_viewonline() {
574         return user_allow_viewonline;
575     }
576
577     /**
578      * @param user_allow_viewonline The user_allow_viewonline to set.
579      */

580     public void setUser_allow_viewonline(String JavaDoc user_allow_viewonline) {
581         this.user_allow_viewonline = user_allow_viewonline;
582     }
583
584     /**
585      * @return Returns the show_mail.
586      */

587     public Integer JavaDoc getShow_mail() {
588         return show_mail;
589     }
590
591     /**
592      * @param show_mail The show_mail to set.
593      */

594     public void setShow_mail(Integer JavaDoc show_mail) {
595         this.show_mail = show_mail;
596     }
597
598     /**
599      * @return Returns the show_signature.
600      */

601     public Integer JavaDoc getShow_signature() {
602         return show_signature;
603     }
604
605     /**
606      * @param show_signature The show_signature to set.
607      */

608     public void setShow_signature(Integer JavaDoc show_signature) {
609         this.show_signature = show_signature;
610     }
611
612     /**
613      * @return Returns the userStatus.
614      */

615     public Integer JavaDoc getUserStatus() {
616         return userStatus;
617     }
618
619     /**
620      * @param userStatus The userStatus to set.
621      */

622     public void setUserStatus(Integer JavaDoc userStatus) {
623         this.userStatus = userStatus;
624     }
625
626     /**
627      * @return Returns the userCode.
628      */

629     public String JavaDoc getUserCode() {
630         return userCode;
631     }
632
633     /**
634      * @param userCode The userCode to set.
635      */

636     public void setUserCode(String JavaDoc userCode) {
637         this.userCode = userCode;
638     }
639
640     /**
641      * @return Returns the timestamp of the last visit.
642      */

643     public Date JavaDoc getLastVisitTimestamp() {
644         return _lastVisitTimestamp;
645     }
646
647     /**
648      * @param lastVisitTimestamp
649      */

650     public void setLastVisitTimestamp(Date JavaDoc lastVisitTimestamp) {
651         this._lastVisitTimestamp = lastVisitTimestamp;
652     }
653     /**
654      * @return Returns the answerNotifies.
655      */

656     public Set JavaDoc getAnswerNotifies() {
657         return answerNotifies;
658     }
659     /**
660      * @param answerNotifies The answerNotifies to set.
661      */

662     public void setAnswerNotifies(Set JavaDoc answerNotifies) {
663         this.answerNotifies = answerNotifies;
664     }
665
666     public Set JavaDoc getForumTopUsers() {
667         return forumTopUsers;
668     }
669
670     public void setForumTopUsers(Set JavaDoc forumTopUsers) {
671         this.forumTopUsers = forumTopUsers;
672     }
673
674     public Set JavaDoc getFavUserTopics() {
675         return favUserTopics;
676     }
677
678     public void setFavUserTopics(Set JavaDoc favUserTopics) {
679         this.favUserTopics = favUserTopics;
680     }
681 }
682
Popular Tags