001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.counter.model.impl;
016    
017    import com.liferay.counter.model.Counter;
018    import com.liferay.counter.model.CounterModel;
019    
020    import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
021    import com.liferay.portal.kernel.util.GetterUtil;
022    import com.liferay.portal.kernel.util.StringBundler;
023    import com.liferay.portal.kernel.util.StringPool;
024    import com.liferay.portal.model.impl.BaseModelImpl;
025    
026    import java.io.Serializable;
027    
028    import java.lang.reflect.Proxy;
029    
030    import java.sql.Types;
031    
032    /**
033     * <p>
034     * This interface is a model that represents the Counter table in the
035     * database.
036     * </p>
037     *
038     * @author    Brian Wing Shun Chan
039     * @see       CounterImpl
040     * @see       com.liferay.counter.model.Counter
041     * @see       com.liferay.counter.model.CounterModel
042     * @generated
043     */
044    public class CounterModelImpl extends BaseModelImpl<Counter>
045            implements CounterModel {
046            public static final String TABLE_NAME = "Counter";
047            public static final Object[][] TABLE_COLUMNS = {
048                            { "name", new Integer(Types.VARCHAR) },
049                            { "currentId", new Integer(Types.BIGINT) }
050                    };
051            public static final String TABLE_SQL_CREATE = "create table Counter (name VARCHAR(75) not null primary key,currentId LONG)";
052            public static final String TABLE_SQL_DROP = "drop table Counter";
053            public static final String DATA_SOURCE = "liferayDataSource";
054            public static final String SESSION_FACTORY = "liferaySessionFactory";
055            public static final String TX_MANAGER = "liferayTransactionManager";
056            public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
057                                    "value.object.entity.cache.enabled.com.liferay.counter.model.Counter"),
058                            false);
059            public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
060                                    "value.object.finder.cache.enabled.com.liferay.counter.model.Counter"),
061                            false);
062            public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
063                                    "lock.expiration.time.com.liferay.counter.model.Counter"));
064    
065            public CounterModelImpl() {
066            }
067    
068            public String getPrimaryKey() {
069                    return _name;
070            }
071    
072            public void setPrimaryKey(String pk) {
073                    setName(pk);
074            }
075    
076            public Serializable getPrimaryKeyObj() {
077                    return _name;
078            }
079    
080            public String getName() {
081                    if (_name == null) {
082                            return StringPool.BLANK;
083                    }
084                    else {
085                            return _name;
086                    }
087            }
088    
089            public void setName(String name) {
090                    _name = name;
091            }
092    
093            public long getCurrentId() {
094                    return _currentId;
095            }
096    
097            public void setCurrentId(long currentId) {
098                    _currentId = currentId;
099            }
100    
101            public Counter toEscapedModel() {
102                    if (isEscapedModel()) {
103                            return (Counter)this;
104                    }
105                    else {
106                            return (Counter)Proxy.newProxyInstance(Counter.class.getClassLoader(),
107                                    new Class[] { Counter.class }, new AutoEscapeBeanHandler(this));
108                    }
109            }
110    
111            public Object clone() {
112                    CounterImpl clone = new CounterImpl();
113    
114                    clone.setName(getName());
115                    clone.setCurrentId(getCurrentId());
116    
117                    return clone;
118            }
119    
120            public int compareTo(Counter counter) {
121                    String pk = counter.getPrimaryKey();
122    
123                    return getPrimaryKey().compareTo(pk);
124            }
125    
126            public boolean equals(Object obj) {
127                    if (obj == null) {
128                            return false;
129                    }
130    
131                    Counter counter = null;
132    
133                    try {
134                            counter = (Counter)obj;
135                    }
136                    catch (ClassCastException cce) {
137                            return false;
138                    }
139    
140                    String pk = counter.getPrimaryKey();
141    
142                    if (getPrimaryKey().equals(pk)) {
143                            return true;
144                    }
145                    else {
146                            return false;
147                    }
148            }
149    
150            public int hashCode() {
151                    return getPrimaryKey().hashCode();
152            }
153    
154            public String toString() {
155                    StringBundler sb = new StringBundler(5);
156    
157                    sb.append("{name=");
158                    sb.append(getName());
159                    sb.append(", currentId=");
160                    sb.append(getCurrentId());
161                    sb.append("}");
162    
163                    return sb.toString();
164            }
165    
166            public String toXmlString() {
167                    StringBundler sb = new StringBundler(10);
168    
169                    sb.append("<model><model-name>");
170                    sb.append("com.liferay.counter.model.Counter");
171                    sb.append("</model-name>");
172    
173                    sb.append(
174                            "<column><column-name>name</column-name><column-value><![CDATA[");
175                    sb.append(getName());
176                    sb.append("]]></column-value></column>");
177                    sb.append(
178                            "<column><column-name>currentId</column-name><column-value><![CDATA[");
179                    sb.append(getCurrentId());
180                    sb.append("]]></column-value></column>");
181    
182                    sb.append("</model>");
183    
184                    return sb.toString();
185            }
186    
187            private String _name;
188            private long _currentId;
189    }