001    /**
002     * Copyright (c) 2000-2012 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.portlet.messageboards.model.impl;
016    
017    import com.liferay.portal.kernel.util.StringBundler;
018    import com.liferay.portal.kernel.util.StringPool;
019    import com.liferay.portal.model.CacheModel;
020    
021    import com.liferay.portlet.messageboards.model.MBMessage;
022    
023    import java.io.Externalizable;
024    import java.io.IOException;
025    import java.io.ObjectInput;
026    import java.io.ObjectOutput;
027    
028    import java.util.Date;
029    
030    /**
031     * The cache model class for representing MBMessage in entity cache.
032     *
033     * @author Brian Wing Shun Chan
034     * @see MBMessage
035     * @generated
036     */
037    public class MBMessageCacheModel implements CacheModel<MBMessage>,
038            Externalizable {
039            @Override
040            public String toString() {
041                    StringBundler sb = new StringBundler(53);
042    
043                    sb.append("{uuid=");
044                    sb.append(uuid);
045                    sb.append(", messageId=");
046                    sb.append(messageId);
047                    sb.append(", groupId=");
048                    sb.append(groupId);
049                    sb.append(", companyId=");
050                    sb.append(companyId);
051                    sb.append(", userId=");
052                    sb.append(userId);
053                    sb.append(", userName=");
054                    sb.append(userName);
055                    sb.append(", createDate=");
056                    sb.append(createDate);
057                    sb.append(", modifiedDate=");
058                    sb.append(modifiedDate);
059                    sb.append(", classNameId=");
060                    sb.append(classNameId);
061                    sb.append(", classPK=");
062                    sb.append(classPK);
063                    sb.append(", categoryId=");
064                    sb.append(categoryId);
065                    sb.append(", threadId=");
066                    sb.append(threadId);
067                    sb.append(", rootMessageId=");
068                    sb.append(rootMessageId);
069                    sb.append(", parentMessageId=");
070                    sb.append(parentMessageId);
071                    sb.append(", subject=");
072                    sb.append(subject);
073                    sb.append(", body=");
074                    sb.append(body);
075                    sb.append(", format=");
076                    sb.append(format);
077                    sb.append(", attachments=");
078                    sb.append(attachments);
079                    sb.append(", anonymous=");
080                    sb.append(anonymous);
081                    sb.append(", priority=");
082                    sb.append(priority);
083                    sb.append(", allowPingbacks=");
084                    sb.append(allowPingbacks);
085                    sb.append(", answer=");
086                    sb.append(answer);
087                    sb.append(", status=");
088                    sb.append(status);
089                    sb.append(", statusByUserId=");
090                    sb.append(statusByUserId);
091                    sb.append(", statusByUserName=");
092                    sb.append(statusByUserName);
093                    sb.append(", statusDate=");
094                    sb.append(statusDate);
095                    sb.append("}");
096    
097                    return sb.toString();
098            }
099    
100            public MBMessage toEntityModel() {
101                    MBMessageImpl mbMessageImpl = new MBMessageImpl();
102    
103                    if (uuid == null) {
104                            mbMessageImpl.setUuid(StringPool.BLANK);
105                    }
106                    else {
107                            mbMessageImpl.setUuid(uuid);
108                    }
109    
110                    mbMessageImpl.setMessageId(messageId);
111                    mbMessageImpl.setGroupId(groupId);
112                    mbMessageImpl.setCompanyId(companyId);
113                    mbMessageImpl.setUserId(userId);
114    
115                    if (userName == null) {
116                            mbMessageImpl.setUserName(StringPool.BLANK);
117                    }
118                    else {
119                            mbMessageImpl.setUserName(userName);
120                    }
121    
122                    if (createDate == Long.MIN_VALUE) {
123                            mbMessageImpl.setCreateDate(null);
124                    }
125                    else {
126                            mbMessageImpl.setCreateDate(new Date(createDate));
127                    }
128    
129                    if (modifiedDate == Long.MIN_VALUE) {
130                            mbMessageImpl.setModifiedDate(null);
131                    }
132                    else {
133                            mbMessageImpl.setModifiedDate(new Date(modifiedDate));
134                    }
135    
136                    mbMessageImpl.setClassNameId(classNameId);
137                    mbMessageImpl.setClassPK(classPK);
138                    mbMessageImpl.setCategoryId(categoryId);
139                    mbMessageImpl.setThreadId(threadId);
140                    mbMessageImpl.setRootMessageId(rootMessageId);
141                    mbMessageImpl.setParentMessageId(parentMessageId);
142    
143                    if (subject == null) {
144                            mbMessageImpl.setSubject(StringPool.BLANK);
145                    }
146                    else {
147                            mbMessageImpl.setSubject(subject);
148                    }
149    
150                    if (body == null) {
151                            mbMessageImpl.setBody(StringPool.BLANK);
152                    }
153                    else {
154                            mbMessageImpl.setBody(body);
155                    }
156    
157                    if (format == null) {
158                            mbMessageImpl.setFormat(StringPool.BLANK);
159                    }
160                    else {
161                            mbMessageImpl.setFormat(format);
162                    }
163    
164                    mbMessageImpl.setAttachments(attachments);
165                    mbMessageImpl.setAnonymous(anonymous);
166                    mbMessageImpl.setPriority(priority);
167                    mbMessageImpl.setAllowPingbacks(allowPingbacks);
168                    mbMessageImpl.setAnswer(answer);
169                    mbMessageImpl.setStatus(status);
170                    mbMessageImpl.setStatusByUserId(statusByUserId);
171    
172                    if (statusByUserName == null) {
173                            mbMessageImpl.setStatusByUserName(StringPool.BLANK);
174                    }
175                    else {
176                            mbMessageImpl.setStatusByUserName(statusByUserName);
177                    }
178    
179                    if (statusDate == Long.MIN_VALUE) {
180                            mbMessageImpl.setStatusDate(null);
181                    }
182                    else {
183                            mbMessageImpl.setStatusDate(new Date(statusDate));
184                    }
185    
186                    mbMessageImpl.resetOriginalValues();
187    
188                    return mbMessageImpl;
189            }
190    
191            public void readExternal(ObjectInput objectInput) throws IOException {
192                    uuid = objectInput.readUTF();
193                    messageId = objectInput.readLong();
194                    groupId = objectInput.readLong();
195                    companyId = objectInput.readLong();
196                    userId = objectInput.readLong();
197                    userName = objectInput.readUTF();
198                    createDate = objectInput.readLong();
199                    modifiedDate = objectInput.readLong();
200                    classNameId = objectInput.readLong();
201                    classPK = objectInput.readLong();
202                    categoryId = objectInput.readLong();
203                    threadId = objectInput.readLong();
204                    rootMessageId = objectInput.readLong();
205                    parentMessageId = objectInput.readLong();
206                    subject = objectInput.readUTF();
207                    body = objectInput.readUTF();
208                    format = objectInput.readUTF();
209                    attachments = objectInput.readBoolean();
210                    anonymous = objectInput.readBoolean();
211                    priority = objectInput.readDouble();
212                    allowPingbacks = objectInput.readBoolean();
213                    answer = objectInput.readBoolean();
214                    status = objectInput.readInt();
215                    statusByUserId = objectInput.readLong();
216                    statusByUserName = objectInput.readUTF();
217                    statusDate = objectInput.readLong();
218            }
219    
220            public void writeExternal(ObjectOutput objectOutput)
221                    throws IOException {
222                    if (uuid == null) {
223                            objectOutput.writeUTF(StringPool.BLANK);
224                    }
225                    else {
226                            objectOutput.writeUTF(uuid);
227                    }
228    
229                    objectOutput.writeLong(messageId);
230                    objectOutput.writeLong(groupId);
231                    objectOutput.writeLong(companyId);
232                    objectOutput.writeLong(userId);
233    
234                    if (userName == null) {
235                            objectOutput.writeUTF(StringPool.BLANK);
236                    }
237                    else {
238                            objectOutput.writeUTF(userName);
239                    }
240    
241                    objectOutput.writeLong(createDate);
242                    objectOutput.writeLong(modifiedDate);
243                    objectOutput.writeLong(classNameId);
244                    objectOutput.writeLong(classPK);
245                    objectOutput.writeLong(categoryId);
246                    objectOutput.writeLong(threadId);
247                    objectOutput.writeLong(rootMessageId);
248                    objectOutput.writeLong(parentMessageId);
249    
250                    if (subject == null) {
251                            objectOutput.writeUTF(StringPool.BLANK);
252                    }
253                    else {
254                            objectOutput.writeUTF(subject);
255                    }
256    
257                    if (body == null) {
258                            objectOutput.writeUTF(StringPool.BLANK);
259                    }
260                    else {
261                            objectOutput.writeUTF(body);
262                    }
263    
264                    if (format == null) {
265                            objectOutput.writeUTF(StringPool.BLANK);
266                    }
267                    else {
268                            objectOutput.writeUTF(format);
269                    }
270    
271                    objectOutput.writeBoolean(attachments);
272                    objectOutput.writeBoolean(anonymous);
273                    objectOutput.writeDouble(priority);
274                    objectOutput.writeBoolean(allowPingbacks);
275                    objectOutput.writeBoolean(answer);
276                    objectOutput.writeInt(status);
277                    objectOutput.writeLong(statusByUserId);
278    
279                    if (statusByUserName == null) {
280                            objectOutput.writeUTF(StringPool.BLANK);
281                    }
282                    else {
283                            objectOutput.writeUTF(statusByUserName);
284                    }
285    
286                    objectOutput.writeLong(statusDate);
287            }
288    
289            public String uuid;
290            public long messageId;
291            public long groupId;
292            public long companyId;
293            public long userId;
294            public String userName;
295            public long createDate;
296            public long modifiedDate;
297            public long classNameId;
298            public long classPK;
299            public long categoryId;
300            public long threadId;
301            public long rootMessageId;
302            public long parentMessageId;
303            public String subject;
304            public String body;
305            public String format;
306            public boolean attachments;
307            public boolean anonymous;
308            public double priority;
309            public boolean allowPingbacks;
310            public boolean answer;
311            public int status;
312            public long statusByUserId;
313            public String statusByUserName;
314            public long statusDate;
315    }