1   /**
2    * Copyright (c) 2000-2007 Liferay, Inc. All rights reserved.
3    *
4    * Permission is hereby granted, free of charge, to any person obtaining a copy
5    * of this software and associated documentation files (the "Software"), to deal
6    * in the Software without restriction, including without limitation the rights
7    * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8    * copies of the Software, and to permit persons to whom the Software is
9    * furnished to do so, subject to the following conditions:
10   *
11   * The above copyright notice and this permission notice shall be included in
12   * all copies or substantial portions of the Software.
13   *
14   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20   * SOFTWARE.
21   */
22  
23  package com.liferay.portal.model.impl;
24  
25  import com.liferay.portal.kernel.util.DateUtil;
26  import com.liferay.portal.kernel.util.GetterUtil;
27  import com.liferay.portal.model.impl.BaseModelImpl;
28  import com.liferay.portal.util.PropsUtil;
29  
30  import com.liferay.util.XSSUtil;
31  
32  import java.io.Serializable;
33  
34  import java.sql.Types;
35  
36  import java.util.Date;
37  
38  /**
39   * <a href="EmailAddressModelImpl.java.html"><b><i>View Source</i></b></a>
40   *
41   * <p>
42   * ServiceBuilder generated this class. Modifications in this class will be overwritten
43   * the next time is generated.
44   * </p>
45   *
46   * <p>
47   * This class is a model that represents the <code>EmailAddress</code> table in
48   * the database.
49   * </p>
50   *
51   * @author Brian Wing Shun Chan
52   *
53   * @see com.liferay.portal.service.model.EmailAddress
54   * @see com.liferay.portal.service.model.EmailAddressModel
55   * @see com.liferay.portal.service.model.impl.EmailAddressImpl
56   *
57   */
58  public class EmailAddressModelImpl extends BaseModelImpl {
59      public static String TABLE_NAME = "EmailAddress";
60      public static Object[][] TABLE_COLUMNS = {
61              { "emailAddressId", new Integer(Types.BIGINT) },
62              { "companyId", new Integer(Types.BIGINT) },
63              { "userId", new Integer(Types.BIGINT) },
64              { "userName", new Integer(Types.VARCHAR) },
65              { "createDate", new Integer(Types.TIMESTAMP) },
66              { "modifiedDate", new Integer(Types.TIMESTAMP) },
67              { "classNameId", new Integer(Types.BIGINT) },
68              { "classPK", new Integer(Types.BIGINT) },
69              { "address", new Integer(Types.VARCHAR) },
70              { "typeId", new Integer(Types.INTEGER) },
71              { "primary_", new Integer(Types.BOOLEAN) }
72          };
73      public static String TABLE_SQL_CREATE = "create table EmailAddress (emailAddressId LONG not null primary key,companyId LONG,userId LONG,userName VARCHAR(75) null,createDate DATE null,modifiedDate DATE null,classNameId LONG,classPK LONG,address VARCHAR(75) null,typeId INTEGER,primary_ BOOLEAN)";
74      public static String TABLE_SQL_DROP = "drop table EmailAddress";
75      public static boolean XSS_ALLOW_BY_MODEL = GetterUtil.getBoolean(PropsUtil.get(
76                  "xss.allow.com.liferay.portal.model.EmailAddress"), XSS_ALLOW);
77      public static boolean XSS_ALLOW_USERNAME = GetterUtil.getBoolean(PropsUtil.get(
78                  "xss.allow.com.liferay.portal.model.EmailAddress.userName"),
79              XSS_ALLOW_BY_MODEL);
80      public static boolean XSS_ALLOW_ADDRESS = GetterUtil.getBoolean(PropsUtil.get(
81                  "xss.allow.com.liferay.portal.model.EmailAddress.address"),
82              XSS_ALLOW_BY_MODEL);
83      public static long LOCK_EXPIRATION_TIME = GetterUtil.getLong(PropsUtil.get(
84                  "lock.expiration.time.com.liferay.portal.model.EmailAddressModel"));
85  
86      public EmailAddressModelImpl() {
87      }
88  
89      public long getPrimaryKey() {
90          return _emailAddressId;
91      }
92  
93      public void setPrimaryKey(long pk) {
94          setEmailAddressId(pk);
95      }
96  
97      public Serializable getPrimaryKeyObj() {
98          return new Long(_emailAddressId);
99      }
100 
101     public long getEmailAddressId() {
102         return _emailAddressId;
103     }
104 
105     public void setEmailAddressId(long emailAddressId) {
106         if (emailAddressId != _emailAddressId) {
107             _emailAddressId = emailAddressId;
108         }
109     }
110 
111     public long getCompanyId() {
112         return _companyId;
113     }
114 
115     public void setCompanyId(long companyId) {
116         if (companyId != _companyId) {
117             _companyId = companyId;
118         }
119     }
120 
121     public long getUserId() {
122         return _userId;
123     }
124 
125     public void setUserId(long userId) {
126         if (userId != _userId) {
127             _userId = userId;
128         }
129     }
130 
131     public String getUserName() {
132         return GetterUtil.getString(_userName);
133     }
134 
135     public void setUserName(String userName) {
136         if (((userName == null) && (_userName != null)) ||
137                 ((userName != null) && (_userName == null)) ||
138                 ((userName != null) && (_userName != null) &&
139                 !userName.equals(_userName))) {
140             if (!XSS_ALLOW_USERNAME) {
141                 userName = XSSUtil.strip(userName);
142             }
143 
144             _userName = userName;
145         }
146     }
147 
148     public Date getCreateDate() {
149         return _createDate;
150     }
151 
152     public void setCreateDate(Date createDate) {
153         if (((createDate == null) && (_createDate != null)) ||
154                 ((createDate != null) && (_createDate == null)) ||
155                 ((createDate != null) && (_createDate != null) &&
156                 !createDate.equals(_createDate))) {
157             _createDate = createDate;
158         }
159     }
160 
161     public Date getModifiedDate() {
162         return _modifiedDate;
163     }
164 
165     public void setModifiedDate(Date modifiedDate) {
166         if (((modifiedDate == null) && (_modifiedDate != null)) ||
167                 ((modifiedDate != null) && (_modifiedDate == null)) ||
168                 ((modifiedDate != null) && (_modifiedDate != null) &&
169                 !modifiedDate.equals(_modifiedDate))) {
170             _modifiedDate = modifiedDate;
171         }
172     }
173 
174     public long getClassNameId() {
175         return _classNameId;
176     }
177 
178     public void setClassNameId(long classNameId) {
179         if (classNameId != _classNameId) {
180             _classNameId = classNameId;
181         }
182     }
183 
184     public long getClassPK() {
185         return _classPK;
186     }
187 
188     public void setClassPK(long classPK) {
189         if (classPK != _classPK) {
190             _classPK = classPK;
191         }
192     }
193 
194     public String getAddress() {
195         return GetterUtil.getString(_address);
196     }
197 
198     public void setAddress(String address) {
199         if (((address == null) && (_address != null)) ||
200                 ((address != null) && (_address == null)) ||
201                 ((address != null) && (_address != null) &&
202                 !address.equals(_address))) {
203             if (!XSS_ALLOW_ADDRESS) {
204                 address = XSSUtil.strip(address);
205             }
206 
207             _address = address;
208         }
209     }
210 
211     public int getTypeId() {
212         return _typeId;
213     }
214 
215     public void setTypeId(int typeId) {
216         if (typeId != _typeId) {
217             _typeId = typeId;
218         }
219     }
220 
221     public boolean getPrimary() {
222         return _primary;
223     }
224 
225     public boolean isPrimary() {
226         return _primary;
227     }
228 
229     public void setPrimary(boolean primary) {
230         if (primary != _primary) {
231             _primary = primary;
232         }
233     }
234 
235     public Object clone() {
236         EmailAddressImpl clone = new EmailAddressImpl();
237         clone.setEmailAddressId(getEmailAddressId());
238         clone.setCompanyId(getCompanyId());
239         clone.setUserId(getUserId());
240         clone.setUserName(getUserName());
241         clone.setCreateDate(getCreateDate());
242         clone.setModifiedDate(getModifiedDate());
243         clone.setClassNameId(getClassNameId());
244         clone.setClassPK(getClassPK());
245         clone.setAddress(getAddress());
246         clone.setTypeId(getTypeId());
247         clone.setPrimary(getPrimary());
248 
249         return clone;
250     }
251 
252     public int compareTo(Object obj) {
253         if (obj == null) {
254             return -1;
255         }
256 
257         EmailAddressImpl emailAddress = (EmailAddressImpl)obj;
258         int value = 0;
259         value = DateUtil.compareTo(getCreateDate(), emailAddress.getCreateDate());
260 
261         if (value != 0) {
262             return value;
263         }
264 
265         return 0;
266     }
267 
268     public boolean equals(Object obj) {
269         if (obj == null) {
270             return false;
271         }
272 
273         EmailAddressImpl emailAddress = null;
274 
275         try {
276             emailAddress = (EmailAddressImpl)obj;
277         }
278         catch (ClassCastException cce) {
279             return false;
280         }
281 
282         long pk = emailAddress.getPrimaryKey();
283 
284         if (getPrimaryKey() == pk) {
285             return true;
286         }
287         else {
288             return false;
289         }
290     }
291 
292     public int hashCode() {
293         return (int)getPrimaryKey();
294     }
295 
296     private long _emailAddressId;
297     private long _companyId;
298     private long _userId;
299     private String _userName;
300     private Date _createDate;
301     private Date _modifiedDate;
302     private long _classNameId;
303     private long _classPK;
304     private String _address;
305     private int _typeId;
306     private boolean _primary;
307 }