1   /**
2    * Copyright (c) 2000-2008 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.bean.ReadOnlyBeanHandler;
26  import com.liferay.portal.kernel.util.GetterUtil;
27  import com.liferay.portal.kernel.util.HtmlUtil;
28  import com.liferay.portal.model.ClassName;
29  import com.liferay.portal.model.ClassNameSoap;
30  import com.liferay.portal.util.PortalUtil;
31  import com.liferay.portal.util.PropsUtil;
32  
33  import java.io.Serializable;
34  
35  import java.lang.reflect.Proxy;
36  
37  import java.sql.Types;
38  
39  import java.util.ArrayList;
40  import java.util.List;
41  
42  /**
43   * <a href="ClassNameModelImpl.java.html"><b><i>View Source</i></b></a>
44   *
45   * <p>
46   * ServiceBuilder generated this class. Modifications in this class will be
47   * overwritten the next time is generated.
48   * </p>
49   *
50   * <p>
51   * This class is a model that represents the <code>ClassName</code> table
52   * in the database.
53   * </p>
54   *
55   * @author Brian Wing Shun Chan
56   *
57   * @see com.liferay.portal.service.model.ClassName
58   * @see com.liferay.portal.service.model.ClassNameModel
59   * @see com.liferay.portal.service.model.impl.ClassNameImpl
60   *
61   */
62  public class ClassNameModelImpl extends BaseModelImpl {
63      public static final String TABLE_NAME = "ClassName_";
64      public static final Object[][] TABLE_COLUMNS = {
65              { "classNameId", new Integer(Types.BIGINT) },
66              
67  
68              { "value", new Integer(Types.VARCHAR) }
69          };
70      public static final String TABLE_SQL_CREATE = "create table ClassName_ (classNameId LONG not null primary key,value VARCHAR(200) null)";
71      public static final String TABLE_SQL_DROP = "drop table ClassName_";
72      public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(PropsUtil.get(
73                  "value.object.finder.cache.enabled.com.liferay.portal.model.ClassName"),
74              true);
75  
76      public static ClassName toModel(ClassNameSoap soapModel) {
77          ClassName model = new ClassNameImpl();
78  
79          model.setClassNameId(soapModel.getClassNameId());
80          model.setValue(soapModel.getValue());
81  
82          return model;
83      }
84  
85      public static List<ClassName> toModels(ClassNameSoap[] soapModels) {
86          List<ClassName> models = new ArrayList<ClassName>(soapModels.length);
87  
88          for (ClassNameSoap soapModel : soapModels) {
89              models.add(toModel(soapModel));
90          }
91  
92          return models;
93      }
94  
95      public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(PropsUtil.get(
96                  "lock.expiration.time.com.liferay.portal.model.ClassName"));
97  
98      public ClassNameModelImpl() {
99      }
100 
101     public long getPrimaryKey() {
102         return _classNameId;
103     }
104 
105     public void setPrimaryKey(long pk) {
106         setClassNameId(pk);
107     }
108 
109     public Serializable getPrimaryKeyObj() {
110         return new Long(_classNameId);
111     }
112 
113     public String getClassName() {
114         return PortalUtil.getClassName(getClassNameId());
115     }
116 
117     public long getClassNameId() {
118         return _classNameId;
119     }
120 
121     public void setClassNameId(long classNameId) {
122         if (classNameId != _classNameId) {
123             _classNameId = classNameId;
124         }
125     }
126 
127     public String getValue() {
128         return GetterUtil.getString(_value);
129     }
130 
131     public void setValue(String value) {
132         if (((value == null) && (_value != null)) ||
133                 ((value != null) && (_value == null)) ||
134                 ((value != null) && (_value != null) && !value.equals(_value))) {
135             _value = value;
136         }
137     }
138 
139     public ClassName toEscapedModel() {
140         if (isEscapedModel()) {
141             return (ClassName)this;
142         }
143         else {
144             ClassName model = new ClassNameImpl();
145 
146             model.setEscapedModel(true);
147 
148             model.setClassNameId(getClassNameId());
149             model.setValue(HtmlUtil.escape(getValue()));
150 
151             model = (ClassName)Proxy.newProxyInstance(ClassName.class.getClassLoader(),
152                     new Class[] { ClassName.class },
153                     new ReadOnlyBeanHandler(model));
154 
155             return model;
156         }
157     }
158 
159     public Object clone() {
160         ClassNameImpl clone = new ClassNameImpl();
161 
162         clone.setClassNameId(getClassNameId());
163         clone.setValue(getValue());
164 
165         return clone;
166     }
167 
168     public int compareTo(Object obj) {
169         if (obj == null) {
170             return -1;
171         }
172 
173         ClassNameImpl className = (ClassNameImpl)obj;
174 
175         long pk = className.getPrimaryKey();
176 
177         if (getPrimaryKey() < pk) {
178             return -1;
179         }
180         else if (getPrimaryKey() > pk) {
181             return 1;
182         }
183         else {
184             return 0;
185         }
186     }
187 
188     public boolean equals(Object obj) {
189         if (obj == null) {
190             return false;
191         }
192 
193         ClassNameImpl className = null;
194 
195         try {
196             className = (ClassNameImpl)obj;
197         }
198         catch (ClassCastException cce) {
199             return false;
200         }
201 
202         long pk = className.getPrimaryKey();
203 
204         if (getPrimaryKey() == pk) {
205             return true;
206         }
207         else {
208             return false;
209         }
210     }
211 
212     public int hashCode() {
213         return (int)getPrimaryKey();
214     }
215 
216     private long _classNameId;
217     private String _value;
218 }