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="PhoneModelImpl.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>Phone</code> table in the database.
48   * </p>
49   *
50   * @author Brian Wing Shun Chan
51   *
52   * @see com.liferay.portal.service.model.Phone
53   * @see com.liferay.portal.service.model.PhoneModel
54   * @see com.liferay.portal.service.model.impl.PhoneImpl
55   *
56   */
57  public class PhoneModelImpl extends BaseModelImpl {
58      public static String TABLE_NAME = "Phone";
59      public static Object[][] TABLE_COLUMNS = {
60              { "phoneId", new Integer(Types.BIGINT) },
61              { "companyId", new Integer(Types.BIGINT) },
62              { "userId", new Integer(Types.BIGINT) },
63              { "userName", new Integer(Types.VARCHAR) },
64              { "createDate", new Integer(Types.TIMESTAMP) },
65              { "modifiedDate", new Integer(Types.TIMESTAMP) },
66              { "classNameId", new Integer(Types.BIGINT) },
67              { "classPK", new Integer(Types.BIGINT) },
68              { "number_", new Integer(Types.VARCHAR) },
69              { "extension", 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 Phone (phoneId LONG not null primary key,companyId LONG,userId LONG,userName VARCHAR(75) null,createDate DATE null,modifiedDate DATE null,classNameId LONG,classPK LONG,number_ VARCHAR(75) null,extension VARCHAR(75) null,typeId INTEGER,primary_ BOOLEAN)";
74      public static String TABLE_SQL_DROP = "drop table Phone";
75      public static boolean XSS_ALLOW_BY_MODEL = GetterUtil.getBoolean(PropsUtil.get(
76                  "xss.allow.com.liferay.portal.model.Phone"), XSS_ALLOW);
77      public static boolean XSS_ALLOW_USERNAME = GetterUtil.getBoolean(PropsUtil.get(
78                  "xss.allow.com.liferay.portal.model.Phone.userName"),
79              XSS_ALLOW_BY_MODEL);
80      public static boolean XSS_ALLOW_NUMBER = GetterUtil.getBoolean(PropsUtil.get(
81                  "xss.allow.com.liferay.portal.model.Phone.number"),
82              XSS_ALLOW_BY_MODEL);
83      public static boolean XSS_ALLOW_EXTENSION = GetterUtil.getBoolean(PropsUtil.get(
84                  "xss.allow.com.liferay.portal.model.Phone.extension"),
85              XSS_ALLOW_BY_MODEL);
86      public static long LOCK_EXPIRATION_TIME = GetterUtil.getLong(PropsUtil.get(
87                  "lock.expiration.time.com.liferay.portal.model.PhoneModel"));
88  
89      public PhoneModelImpl() {
90      }
91  
92      public long getPrimaryKey() {
93          return _phoneId;
94      }
95  
96      public void setPrimaryKey(long pk) {
97          setPhoneId(pk);
98      }
99  
100     public Serializable getPrimaryKeyObj() {
101         return new Long(_phoneId);
102     }
103 
104     public long getPhoneId() {
105         return _phoneId;
106     }
107 
108     public void setPhoneId(long phoneId) {
109         if (phoneId != _phoneId) {
110             _phoneId = phoneId;
111         }
112     }
113 
114     public long getCompanyId() {
115         return _companyId;
116     }
117 
118     public void setCompanyId(long companyId) {
119         if (companyId != _companyId) {
120             _companyId = companyId;
121         }
122     }
123 
124     public long getUserId() {
125         return _userId;
126     }
127 
128     public void setUserId(long userId) {
129         if (userId != _userId) {
130             _userId = userId;
131         }
132     }
133 
134     public String getUserName() {
135         return GetterUtil.getString(_userName);
136     }
137 
138     public void setUserName(String userName) {
139         if (((userName == null) && (_userName != null)) ||
140                 ((userName != null) && (_userName == null)) ||
141                 ((userName != null) && (_userName != null) &&
142                 !userName.equals(_userName))) {
143             if (!XSS_ALLOW_USERNAME) {
144                 userName = XSSUtil.strip(userName);
145             }
146 
147             _userName = userName;
148         }
149     }
150 
151     public Date getCreateDate() {
152         return _createDate;
153     }
154 
155     public void setCreateDate(Date createDate) {
156         if (((createDate == null) && (_createDate != null)) ||
157                 ((createDate != null) && (_createDate == null)) ||
158                 ((createDate != null) && (_createDate != null) &&
159                 !createDate.equals(_createDate))) {
160             _createDate = createDate;
161         }
162     }
163 
164     public Date getModifiedDate() {
165         return _modifiedDate;
166     }
167 
168     public void setModifiedDate(Date modifiedDate) {
169         if (((modifiedDate == null) && (_modifiedDate != null)) ||
170                 ((modifiedDate != null) && (_modifiedDate == null)) ||
171                 ((modifiedDate != null) && (_modifiedDate != null) &&
172                 !modifiedDate.equals(_modifiedDate))) {
173             _modifiedDate = modifiedDate;
174         }
175     }
176 
177     public long getClassNameId() {
178         return _classNameId;
179     }
180 
181     public void setClassNameId(long classNameId) {
182         if (classNameId != _classNameId) {
183             _classNameId = classNameId;
184         }
185     }
186 
187     public long getClassPK() {
188         return _classPK;
189     }
190 
191     public void setClassPK(long classPK) {
192         if (classPK != _classPK) {
193             _classPK = classPK;
194         }
195     }
196 
197     public String getNumber() {
198         return GetterUtil.getString(_number);
199     }
200 
201     public void setNumber(String number) {
202         if (((number == null) && (_number != null)) ||
203                 ((number != null) && (_number == null)) ||
204                 ((number != null) && (_number != null) &&
205                 !number.equals(_number))) {
206             if (!XSS_ALLOW_NUMBER) {
207                 number = XSSUtil.strip(number);
208             }
209 
210             _number = number;
211         }
212     }
213 
214     public String getExtension() {
215         return GetterUtil.getString(_extension);
216     }
217 
218     public void setExtension(String extension) {
219         if (((extension == null) && (_extension != null)) ||
220                 ((extension != null) && (_extension == null)) ||
221                 ((extension != null) && (_extension != null) &&
222                 !extension.equals(_extension))) {
223             if (!XSS_ALLOW_EXTENSION) {
224                 extension = XSSUtil.strip(extension);
225             }
226 
227             _extension = extension;
228         }
229     }
230 
231     public int getTypeId() {
232         return _typeId;
233     }
234 
235     public void setTypeId(int typeId) {
236         if (typeId != _typeId) {
237             _typeId = typeId;
238         }
239     }
240 
241     public boolean getPrimary() {
242         return _primary;
243     }
244 
245     public boolean isPrimary() {
246         return _primary;
247     }
248 
249     public void setPrimary(boolean primary) {
250         if (primary != _primary) {
251             _primary = primary;
252         }
253     }
254 
255     public Object clone() {
256         PhoneImpl clone = new PhoneImpl();
257         clone.setPhoneId(getPhoneId());
258         clone.setCompanyId(getCompanyId());
259         clone.setUserId(getUserId());
260         clone.setUserName(getUserName());
261         clone.setCreateDate(getCreateDate());
262         clone.setModifiedDate(getModifiedDate());
263         clone.setClassNameId(getClassNameId());
264         clone.setClassPK(getClassPK());
265         clone.setNumber(getNumber());
266         clone.setExtension(getExtension());
267         clone.setTypeId(getTypeId());
268         clone.setPrimary(getPrimary());
269 
270         return clone;
271     }
272 
273     public int compareTo(Object obj) {
274         if (obj == null) {
275             return -1;
276         }
277 
278         PhoneImpl phone = (PhoneImpl)obj;
279         int value = 0;
280         value = DateUtil.compareTo(getCreateDate(), phone.getCreateDate());
281 
282         if (value != 0) {
283             return value;
284         }
285 
286         return 0;
287     }
288 
289     public boolean equals(Object obj) {
290         if (obj == null) {
291             return false;
292         }
293 
294         PhoneImpl phone = null;
295 
296         try {
297             phone = (PhoneImpl)obj;
298         }
299         catch (ClassCastException cce) {
300             return false;
301         }
302 
303         long pk = phone.getPrimaryKey();
304 
305         if (getPrimaryKey() == pk) {
306             return true;
307         }
308         else {
309             return false;
310         }
311     }
312 
313     public int hashCode() {
314         return (int)getPrimaryKey();
315     }
316 
317     private long _phoneId;
318     private long _companyId;
319     private long _userId;
320     private String _userName;
321     private Date _createDate;
322     private Date _modifiedDate;
323     private long _classNameId;
324     private long _classPK;
325     private String _number;
326     private String _extension;
327     private int _typeId;
328     private boolean _primary;
329 }