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="ResourceCodeModelImpl.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>ResourceCode</code> table in
45   * the database.
46   * </p>
47   *
48   * @author Brian Wing Shun Chan
49   *
50   * @see com.liferay.portal.service.model.ResourceCode
51   * @see com.liferay.portal.service.model.ResourceCodeModel
52   * @see com.liferay.portal.service.model.impl.ResourceCodeImpl
53   *
54   */
55  public class ResourceCodeModelImpl extends BaseModelImpl {
56      public static String TABLE_NAME = "ResourceCode";
57      public static Object[][] TABLE_COLUMNS = {
58              { "codeId", new Integer(Types.BIGINT) },
59              { "companyId", new Integer(Types.BIGINT) },
60              { "name", new Integer(Types.VARCHAR) },
61              { "scope", new Integer(Types.INTEGER) }
62          };
63      public static String TABLE_SQL_CREATE = "create table ResourceCode (codeId LONG not null primary key,companyId LONG,name VARCHAR(300) null,scope INTEGER)";
64      public static String TABLE_SQL_DROP = "drop table ResourceCode";
65      public static boolean XSS_ALLOW_BY_MODEL = GetterUtil.getBoolean(PropsUtil.get(
66                  "xss.allow.com.liferay.portal.model.ResourceCode"), XSS_ALLOW);
67      public static boolean XSS_ALLOW_NAME = GetterUtil.getBoolean(PropsUtil.get(
68                  "xss.allow.com.liferay.portal.model.ResourceCode.name"),
69              XSS_ALLOW_BY_MODEL);
70      public static long LOCK_EXPIRATION_TIME = GetterUtil.getLong(PropsUtil.get(
71                  "lock.expiration.time.com.liferay.portal.model.ResourceCodeModel"));
72  
73      public ResourceCodeModelImpl() {
74      }
75  
76      public long getPrimaryKey() {
77          return _codeId;
78      }
79  
80      public void setPrimaryKey(long pk) {
81          setCodeId(pk);
82      }
83  
84      public Serializable getPrimaryKeyObj() {
85          return new Long(_codeId);
86      }
87  
88      public long getCodeId() {
89          return _codeId;
90      }
91  
92      public void setCodeId(long codeId) {
93          if (codeId != _codeId) {
94              _codeId = codeId;
95          }
96      }
97  
98      public long getCompanyId() {
99          return _companyId;
100     }
101 
102     public void setCompanyId(long companyId) {
103         if (companyId != _companyId) {
104             _companyId = companyId;
105         }
106     }
107 
108     public String getName() {
109         return GetterUtil.getString(_name);
110     }
111 
112     public void setName(String name) {
113         if (((name == null) && (_name != null)) ||
114                 ((name != null) && (_name == null)) ||
115                 ((name != null) && (_name != null) && !name.equals(_name))) {
116             if (!XSS_ALLOW_NAME) {
117                 name = XSSUtil.strip(name);
118             }
119 
120             _name = name;
121         }
122     }
123 
124     public int getScope() {
125         return _scope;
126     }
127 
128     public void setScope(int scope) {
129         if (scope != _scope) {
130             _scope = scope;
131         }
132     }
133 
134     public Object clone() {
135         ResourceCodeImpl clone = new ResourceCodeImpl();
136         clone.setCodeId(getCodeId());
137         clone.setCompanyId(getCompanyId());
138         clone.setName(getName());
139         clone.setScope(getScope());
140 
141         return clone;
142     }
143 
144     public int compareTo(Object obj) {
145         if (obj == null) {
146             return -1;
147         }
148 
149         ResourceCodeImpl resourceCode = (ResourceCodeImpl)obj;
150         long pk = resourceCode.getPrimaryKey();
151 
152         if (getPrimaryKey() < pk) {
153             return -1;
154         }
155         else if (getPrimaryKey() > pk) {
156             return 1;
157         }
158         else {
159             return 0;
160         }
161     }
162 
163     public boolean equals(Object obj) {
164         if (obj == null) {
165             return false;
166         }
167 
168         ResourceCodeImpl resourceCode = null;
169 
170         try {
171             resourceCode = (ResourceCodeImpl)obj;
172         }
173         catch (ClassCastException cce) {
174             return false;
175         }
176 
177         long pk = resourceCode.getPrimaryKey();
178 
179         if (getPrimaryKey() == pk) {
180             return true;
181         }
182         else {
183             return false;
184         }
185     }
186 
187     public int hashCode() {
188         return (int)getPrimaryKey();
189     }
190 
191     private long _codeId;
192     private long _companyId;
193     private String _name;
194     private int _scope;
195 }