001
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
049 public class CounterModelImpl extends BaseModelImpl<Counter>
050 implements CounterModel {
051 public static final String TABLE_NAME = "Counter";
052 public static final Object[][] TABLE_COLUMNS = {
053 { "name", new Integer(Types.VARCHAR) },
054 { "currentId", new Integer(Types.BIGINT) }
055 };
056 public static final String TABLE_SQL_CREATE = "create table Counter (name VARCHAR(75) not null primary key,currentId LONG)";
057 public static final String TABLE_SQL_DROP = "drop table Counter";
058 public static final String DATA_SOURCE = "liferayDataSource";
059 public static final String SESSION_FACTORY = "liferaySessionFactory";
060 public static final String TX_MANAGER = "liferayTransactionManager";
061 public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
062 "value.object.entity.cache.enabled.com.liferay.counter.model.Counter"),
063 false);
064 public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
065 "value.object.finder.cache.enabled.com.liferay.counter.model.Counter"),
066 false);
067 public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
068 "lock.expiration.time.com.liferay.counter.model.Counter"));
069
070 public CounterModelImpl() {
071 }
072
073 public String getPrimaryKey() {
074 return _name;
075 }
076
077 public void setPrimaryKey(String pk) {
078 setName(pk);
079 }
080
081 public Serializable getPrimaryKeyObj() {
082 return _name;
083 }
084
085 public String getName() {
086 if (_name == null) {
087 return StringPool.BLANK;
088 }
089 else {
090 return _name;
091 }
092 }
093
094 public void setName(String name) {
095 _name = name;
096 }
097
098 public long getCurrentId() {
099 return _currentId;
100 }
101
102 public void setCurrentId(long currentId) {
103 _currentId = currentId;
104 }
105
106 public Counter toEscapedModel() {
107 if (isEscapedModel()) {
108 return (Counter)this;
109 }
110 else {
111 return (Counter)Proxy.newProxyInstance(Counter.class.getClassLoader(),
112 new Class[] { Counter.class }, new AutoEscapeBeanHandler(this));
113 }
114 }
115
116 public Object clone() {
117 CounterImpl clone = new CounterImpl();
118
119 clone.setName(getName());
120 clone.setCurrentId(getCurrentId());
121
122 return clone;
123 }
124
125 public int compareTo(Counter counter) {
126 String pk = counter.getPrimaryKey();
127
128 return getPrimaryKey().compareTo(pk);
129 }
130
131 public boolean equals(Object obj) {
132 if (obj == null) {
133 return false;
134 }
135
136 Counter counter = null;
137
138 try {
139 counter = (Counter)obj;
140 }
141 catch (ClassCastException cce) {
142 return false;
143 }
144
145 String pk = counter.getPrimaryKey();
146
147 if (getPrimaryKey().equals(pk)) {
148 return true;
149 }
150 else {
151 return false;
152 }
153 }
154
155 public int hashCode() {
156 return getPrimaryKey().hashCode();
157 }
158
159 public String toString() {
160 StringBundler sb = new StringBundler(5);
161
162 sb.append("{name=");
163 sb.append(getName());
164 sb.append(", currentId=");
165 sb.append(getCurrentId());
166 sb.append("}");
167
168 return sb.toString();
169 }
170
171 public String toXmlString() {
172 StringBundler sb = new StringBundler(10);
173
174 sb.append("<model><model-name>");
175 sb.append("com.liferay.counter.model.Counter");
176 sb.append("</model-name>");
177
178 sb.append(
179 "<column><column-name>name</column-name><column-value><![CDATA[");
180 sb.append(getName());
181 sb.append("]]></column-value></column>");
182 sb.append(
183 "<column><column-name>currentId</column-name><column-value><![CDATA[");
184 sb.append(getCurrentId());
185 sb.append("]]></column-value></column>");
186
187 sb.append("</model>");
188
189 return sb.toString();
190 }
191
192 private String _name;
193 private long _currentId;
194 }