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.GetterUtil;
26  import com.liferay.portal.model.impl.BaseModelImpl;
27  import com.liferay.portal.util.PropsUtil;
28  
29  import com.liferay.util.XSSUtil;
30  
31  import java.io.Serializable;
32  
33  import java.sql.Types;
34  
35  /**
36   * <a href="ClassNameModelImpl.java.html"><b><i>View Source</i></b></a>
37   *
38   * <p>
39   * ServiceBuilder generated this class. Modifications in this class will be overwritten
40   * the next time is generated.
41   * </p>
42   *
43   * <p>
44   * This class is a model that represents the <code>ClassName_</code> table in the
45   * database.
46   * </p>
47   *
48   * @author Brian Wing Shun Chan
49   *
50   * @see com.liferay.portal.service.model.ClassName
51   * @see com.liferay.portal.service.model.ClassNameModel
52   * @see com.liferay.portal.service.model.impl.ClassNameImpl
53   *
54   */
55  public class ClassNameModelImpl extends BaseModelImpl {
56      public static String TABLE_NAME = "ClassName_";
57      public static Object[][] TABLE_COLUMNS = {
58              { "classNameId", new Integer(Types.BIGINT) },
59              { "value", new Integer(Types.VARCHAR) }
60          };
61      public static String TABLE_SQL_CREATE = "create table ClassName_ (classNameId LONG not null primary key,value VARCHAR(200) null)";
62      public static String TABLE_SQL_DROP = "drop table ClassName_";
63      public static boolean XSS_ALLOW_BY_MODEL = GetterUtil.getBoolean(PropsUtil.get(
64                  "xss.allow.com.liferay.portal.model.ClassName"), XSS_ALLOW);
65      public static boolean XSS_ALLOW_VALUE = GetterUtil.getBoolean(PropsUtil.get(
66                  "xss.allow.com.liferay.portal.model.ClassName.value"),
67              XSS_ALLOW_BY_MODEL);
68      public static long LOCK_EXPIRATION_TIME = GetterUtil.getLong(PropsUtil.get(
69                  "lock.expiration.time.com.liferay.portal.model.ClassNameModel"));
70  
71      public ClassNameModelImpl() {
72      }
73  
74      public long getPrimaryKey() {
75          return _classNameId;
76      }
77  
78      public void setPrimaryKey(long pk) {
79          setClassNameId(pk);
80      }
81  
82      public Serializable getPrimaryKeyObj() {
83          return new Long(_classNameId);
84      }
85  
86      public long getClassNameId() {
87          return _classNameId;
88      }
89  
90      public void setClassNameId(long classNameId) {
91          if (classNameId != _classNameId) {
92              _classNameId = classNameId;
93          }
94      }
95  
96      public String getValue() {
97          return GetterUtil.getString(_value);
98      }
99  
100     public void setValue(String value) {
101         if (((value == null) && (_value != null)) ||
102                 ((value != null) && (_value == null)) ||
103                 ((value != null) && (_value != null) && !value.equals(_value))) {
104             if (!XSS_ALLOW_VALUE) {
105                 value = XSSUtil.strip(value);
106             }
107 
108             _value = value;
109         }
110     }
111 
112     public Object clone() {
113         ClassNameImpl clone = new ClassNameImpl();
114         clone.setClassNameId(getClassNameId());
115         clone.setValue(getValue());
116 
117         return clone;
118     }
119 
120     public int compareTo(Object obj) {
121         if (obj == null) {
122             return -1;
123         }
124 
125         ClassNameImpl className = (ClassNameImpl)obj;
126         long pk = className.getPrimaryKey();
127 
128         if (getPrimaryKey() < pk) {
129             return -1;
130         }
131         else if (getPrimaryKey() > pk) {
132             return 1;
133         }
134         else {
135             return 0;
136         }
137     }
138 
139     public boolean equals(Object obj) {
140         if (obj == null) {
141             return false;
142         }
143 
144         ClassNameImpl className = null;
145 
146         try {
147             className = (ClassNameImpl)obj;
148         }
149         catch (ClassCastException cce) {
150             return false;
151         }
152 
153         long pk = className.getPrimaryKey();
154 
155         if (getPrimaryKey() == pk) {
156             return true;
157         }
158         else {
159             return false;
160         }
161     }
162 
163     public int hashCode() {
164         return (int)getPrimaryKey();
165     }
166 
167     private long _classNameId;
168     private String _value;
169 }