1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
14   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
15   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
17   * SOFTWARE.
18   */
19  
20  package com.liferay.portal.model.impl;
21  
22  import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
23  import com.liferay.portal.kernel.util.GetterUtil;
24  import com.liferay.portal.kernel.util.HtmlUtil;
25  import com.liferay.portal.kernel.util.StringPool;
26  import com.liferay.portal.model.ClassName;
27  import com.liferay.portal.model.ClassNameSoap;
28  import com.liferay.portal.util.PortalUtil;
29  
30  import com.liferay.portlet.expando.model.ExpandoBridge;
31  import com.liferay.portlet.expando.model.impl.ExpandoBridgeImpl;
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.model.ClassName
58   * @see com.liferay.portal.model.ClassNameModel
59   * @see com.liferay.portal.model.impl.ClassNameImpl
60   *
61   */
62  public class ClassNameModelImpl extends BaseModelImpl<ClassName> {
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 String DATA_SOURCE = "liferayDataSource";
73      public static final String SESSION_FACTORY = "liferaySessionFactory";
74      public static final String TX_MANAGER = "liferayTransactionManager";
75      public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
76                  "value.object.entity.cache.enabled.com.liferay.portal.model.ClassName"),
77              true);
78      public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
79                  "value.object.finder.cache.enabled.com.liferay.portal.model.ClassName"),
80              true);
81  
82      public static ClassName toModel(ClassNameSoap soapModel) {
83          ClassName model = new ClassNameImpl();
84  
85          model.setClassNameId(soapModel.getClassNameId());
86          model.setValue(soapModel.getValue());
87  
88          return model;
89      }
90  
91      public static List<ClassName> toModels(ClassNameSoap[] soapModels) {
92          List<ClassName> models = new ArrayList<ClassName>(soapModels.length);
93  
94          for (ClassNameSoap soapModel : soapModels) {
95              models.add(toModel(soapModel));
96          }
97  
98          return models;
99      }
100 
101     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
102                 "lock.expiration.time.com.liferay.portal.model.ClassName"));
103 
104     public ClassNameModelImpl() {
105     }
106 
107     public long getPrimaryKey() {
108         return _classNameId;
109     }
110 
111     public void setPrimaryKey(long pk) {
112         setClassNameId(pk);
113     }
114 
115     public Serializable getPrimaryKeyObj() {
116         return new Long(_classNameId);
117     }
118 
119     public String getClassName() {
120         if (getClassNameId() <= 0) {
121             return StringPool.BLANK;
122         }
123 
124         return PortalUtil.getClassName(getClassNameId());
125     }
126 
127     public long getClassNameId() {
128         return _classNameId;
129     }
130 
131     public void setClassNameId(long classNameId) {
132         _classNameId = classNameId;
133     }
134 
135     public String getValue() {
136         return GetterUtil.getString(_value);
137     }
138 
139     public void setValue(String value) {
140         _value = value;
141 
142         if (_originalValue == null) {
143             _originalValue = value;
144         }
145     }
146 
147     public String getOriginalValue() {
148         return GetterUtil.getString(_originalValue);
149     }
150 
151     public ClassName toEscapedModel() {
152         if (isEscapedModel()) {
153             return (ClassName)this;
154         }
155         else {
156             ClassName model = new ClassNameImpl();
157 
158             model.setNew(isNew());
159             model.setEscapedModel(true);
160 
161             model.setClassNameId(getClassNameId());
162             model.setValue(HtmlUtil.escape(getValue()));
163 
164             model = (ClassName)Proxy.newProxyInstance(ClassName.class.getClassLoader(),
165                     new Class[] { ClassName.class },
166                     new ReadOnlyBeanHandler(model));
167 
168             return model;
169         }
170     }
171 
172     public ExpandoBridge getExpandoBridge() {
173         if (_expandoBridge == null) {
174             _expandoBridge = new ExpandoBridgeImpl(ClassName.class.getName(),
175                     getPrimaryKey());
176         }
177 
178         return _expandoBridge;
179     }
180 
181     public Object clone() {
182         ClassNameImpl clone = new ClassNameImpl();
183 
184         clone.setClassNameId(getClassNameId());
185         clone.setValue(getValue());
186 
187         return clone;
188     }
189 
190     public int compareTo(ClassName className) {
191         long pk = className.getPrimaryKey();
192 
193         if (getPrimaryKey() < pk) {
194             return -1;
195         }
196         else if (getPrimaryKey() > pk) {
197             return 1;
198         }
199         else {
200             return 0;
201         }
202     }
203 
204     public boolean equals(Object obj) {
205         if (obj == null) {
206             return false;
207         }
208 
209         ClassName className = null;
210 
211         try {
212             className = (ClassName)obj;
213         }
214         catch (ClassCastException cce) {
215             return false;
216         }
217 
218         long pk = className.getPrimaryKey();
219 
220         if (getPrimaryKey() == pk) {
221             return true;
222         }
223         else {
224             return false;
225         }
226     }
227 
228     public int hashCode() {
229         return (int)getPrimaryKey();
230     }
231 
232     public String toString() {
233         StringBuilder sb = new StringBuilder();
234 
235         sb.append("{classNameId=");
236         sb.append(getClassNameId());
237         sb.append(", value=");
238         sb.append(getValue());
239         sb.append("}");
240 
241         return sb.toString();
242     }
243 
244     public String toXmlString() {
245         StringBuilder sb = new StringBuilder();
246 
247         sb.append("<model><model-name>");
248         sb.append("com.liferay.portal.model.ClassName");
249         sb.append("</model-name>");
250 
251         sb.append(
252             "<column><column-name>classNameId</column-name><column-value><![CDATA[");
253         sb.append(getClassNameId());
254         sb.append("]]></column-value></column>");
255         sb.append(
256             "<column><column-name>value</column-name><column-value><![CDATA[");
257         sb.append(getValue());
258         sb.append("]]></column-value></column>");
259 
260         sb.append("</model>");
261 
262         return sb.toString();
263     }
264 
265     private long _classNameId;
266     private String _value;
267     private String _originalValue;
268     private transient ExpandoBridge _expandoBridge;
269 }