KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > roller > pojos > UserCookieData


1 package org.roller.pojos;
2
3 import java.io.Serializable JavaDoc;
4 import java.util.Date JavaDoc;
5
6
7
8 /**
9  * This class is used to manage cookie-based authentication.
10  *
11  * @author Matt Raible
12  * @version $Revision: 1.2 $ $Date: 2005/01/21 19:01:10 $
13  *
14  * @hibernate.class table="usercookie"
15  */

16 public class UserCookieData extends PersistentObject implements Serializable JavaDoc
17 {
18     static final long serialVersionUID = -1109195226932397420L;
19
20     private String JavaDoc id;
21     private String JavaDoc username;
22     private String JavaDoc cookieId;
23     private Date JavaDoc dateCreated;
24
25     public UserCookieData()
26     {
27         this.dateCreated = new Date JavaDoc();
28     }
29
30     public UserCookieData( String JavaDoc id, String JavaDoc username, String JavaDoc cookieId,
31                        Date JavaDoc dateCreated )
32     {
33         this.id = id;
34         this.username = username;
35         this.cookieId = cookieId;
36         this.dateCreated = (Date JavaDoc)dateCreated.clone();
37     }
38
39     public UserCookieData( UserCookieData otherData )
40     {
41         this.id = otherData.id;
42         this.username = otherData.username;
43         this.cookieId = otherData.cookieId;
44         this.dateCreated = (Date JavaDoc)otherData.dateCreated.clone();
45     }
46
47
48     /**
49      * @ejb:persistent-field
50      * @hibernate.id column="id" type="string"
51      * generator-class="uuid.hex" unsaved-value="null"
52      */

53     public java.lang.String JavaDoc getId()
54     {
55        return this.id;
56     }
57     /** @ejb:persistent-field */
58     public void setId( java.lang.String JavaDoc id )
59     {
60        this.id = id;
61     }
62
63     /**
64      * Returns the username.
65      * @ejb:persistent-field
66      * @hibernate.property column="username" not-null="true" unique="false"
67      * @return String
68      */

69     public String JavaDoc getUsername()
70     {
71         return username;
72     }
73
74     /**
75      * Sets the username.
76      * @ejb:persistent-field
77      * @param username The username to set
78      */

79     public void setUsername( String JavaDoc username )
80     {
81         this.username = username;
82     }
83
84     /**
85      * Returns the cookieId (a GUID).
86      * @ejb:persistent-field
87      * @hibernate.property column="cookieid" not-null="true" unique="true"
88      * @return String
89      */

90     public String JavaDoc getCookieId()
91     {
92         return cookieId;
93     }
94
95     /**
96      * Sets the cookieId.
97      * @ejb:persistent-field
98      * @param rolename The cookieId to set
99      */

100     public void setCookieId( String JavaDoc rolename )
101     {
102         this.cookieId = rolename;
103     }
104
105     /**
106      * @return Returns the dateCreated.
107      * @ejb:persistent-field
108      * @hibernate.property column="datecreated" not-null="true" unique="false"
109      */

110     public Date JavaDoc getDateCreated()
111     {
112         return (Date JavaDoc)dateCreated.clone();
113     }
114
115     /**
116      * @param dateCreated The dateCreated to set.
117      * @ejb:persistent-field
118      */

119     public void setDateCreated(final Date JavaDoc dateCreated )
120     {
121         if (dateCreated != null)
122         {
123             this.dateCreated = (Date JavaDoc)dateCreated.clone();
124         }
125         else
126         {
127             this.dateCreated = null;
128         }
129     }
130
131     /**
132      * @see org.roller.pojos.PersistentObject#setData(org.roller.pojos.PersistentObject)
133      */

134     public void setData(PersistentObject vo) {
135         UserCookieData newData = (UserCookieData) vo;
136         this.id = newData.getId();
137         this.username = newData.getUsername();
138         this.cookieId = newData.getCookieId();
139         this.dateCreated = newData.getDateCreated();
140     }
141
142     /**
143      * @see java.lang.Object#equals(Object)
144      */

145     public boolean equals(Object JavaDoc o)
146     {
147         // Generated by IDEA 4.5.1
148
// But avoid super.equals() because that has a full reflection-based implementation.
149
if (this == o)
150         {
151             return true;
152         }
153         if (!(o instanceof UserCookieData))
154         {
155             return false;
156         }
157         final UserCookieData userCookieData = (UserCookieData)o;
158
159         if (cookieId != null ? !cookieId.equals(userCookieData.cookieId) : userCookieData.cookieId != null)
160         {
161             return false;
162         }
163         if (dateCreated != null ? !dateCreated.equals(userCookieData.dateCreated) : userCookieData.dateCreated != null)
164         {
165             return false;
166         }
167         if (id != null ? !id.equals(userCookieData.id) : userCookieData.id != null)
168         {
169             return false;
170         }
171         if (username != null ? !username.equals(userCookieData.username) : userCookieData.username != null)
172         {
173             return false;
174         }
175
176         return true;
177     }
178
179     /**
180      * @see java.lang.Object#hashCode()
181      */

182     public int hashCode()
183     {
184         // Hash on id and dateCreated.
185
// But avoid super.hashCode() because that has a full reflection-based implementation.
186
int result = 0;
187         result = 29 * result + (id != null ? id.hashCode() : 0);
188         result = 29 * result + (dateCreated != null ? dateCreated.hashCode() : 0);
189         return result;
190     }
191
192 }
193
Popular Tags