KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > blandware > atleap > model > core > UserCookie


1 package com.blandware.atleap.model.core;
2
3 import java.util.Date JavaDoc;
4
5
6 /**
7  * <p>This class is used to manage cookie-based authentication.
8  * </p>
9  * <p><a HREF="UserCookie.java.htm"><i>View Source</i></a>
10  * </p>
11  *
12  * @author Matt Raible <a HREF="mailto:matt@raibledesigns.com">&lt;matt@raibledesigns.com&gt;</a>
13  * @version $Revision: 1.16 $ $Date: 2005/12/18 16:43:44 $
14  * @hibernate.class table="`al_core_user_cookie`" lazy="false"
15  */

16 public class UserCookie extends BaseObject {
17     //~ Instance fields ========================================================
18

19     /**
20      * ID of this cookie in database (as stored object)
21      */

22     private Long JavaDoc id;
23     /**
24      * Owner of this cookie
25      */

26     private User user;
27     /**
28      * ID of the cookie (as cookie)
29      */

30     private String JavaDoc cookieId;
31     /**
32      * Creation date
33      */

34     private Date JavaDoc dateCreated;
35
36     //~ Methods ================================================================
37

38     /**
39      * Create a cookie and set it's creation date to current one
40      */

41     public UserCookie() {
42         this.dateCreated = new Date JavaDoc();
43     }
44
45     /**
46      * Returns the id.
47      *
48      * @return id
49      * @hibernate.id column="`id`"
50      * generator-class="increment" unsaved-value="null"
51      */

52     public Long JavaDoc getId() {
53         return id;
54     }
55
56     /**
57      * Sets the id.
58      *
59      * @param id The id to set
60      */

61     public void setId(Long JavaDoc id) {
62         this.id = id;
63     }
64
65     /**
66      * Returns the user this cookie associated with.
67      *
68      * @return user
69      * @hibernate.many-to-one column="`username`" not-null="false" lazy="false" outer-join="false"
70      */

71     public User getUser() {
72         return user;
73     }
74
75     /**
76      * Sets the user.
77      *
78      * @param user The user to set
79      */

80     public void setUser(User user) {
81         this.user = user;
82     }
83
84     /**
85      * Returns the cookie id (a GUID).
86      *
87      * @return cookie id
88      * @hibernate.property column="`cookie_id`" not-null="true" length="100"
89      */

90     public String JavaDoc getCookieId() {
91         return cookieId;
92     }
93
94     /**
95      * Sets the cookieId.
96      *
97      * @param cookieId The cookie id to set
98      */

99     public void setCookieId(String JavaDoc cookieId) {
100         this.cookieId = cookieId;
101     }
102
103     /**
104      * Gets date of this cookie creation
105      *
106      * @return Returns the date this cookie was created
107      * @hibernate.property column="`date_created`" not-null="true"
108      */

109     public Date JavaDoc getDateCreated() {
110         return dateCreated;
111     }
112
113     /**
114      * Sets date of this cookie creation
115      *
116      * @param dateCreated The date this cookie was created
117      */

118     public void setDateCreated(Date JavaDoc dateCreated) {
119         this.dateCreated = dateCreated;
120     }
121
122     public boolean equals(Object JavaDoc o) {
123         if ( this == o ) {
124             return true;
125         }
126         if ( !(o instanceof UserCookie) ) {
127             return false;
128         }
129
130         final UserCookie userCookie = (UserCookie) o;
131
132         if ( cookieId != null ? !cookieId.equals(userCookie.cookieId) : userCookie.cookieId != null ) {
133             return false;
134         }
135         if ( dateCreated != null ? !dateCreated.equals(userCookie.dateCreated) : userCookie.dateCreated != null ) {
136             return false;
137         }
138         if ( user != null ? !user.equals(userCookie.user) : userCookie.user != null ) {
139             return false;
140         }
141
142         return true;
143     }
144
145     public int hashCode() {
146         int result;
147         result = (user != null ? user.hashCode() : 0);
148         result = 29 * result + (cookieId != null ? cookieId.hashCode() : 0);
149         result = 29 * result + (dateCreated != null ? dateCreated.hashCode() : 0);
150         return result;
151     }
152
153 }
154
Popular Tags