001    /**
002     * Copyright (c) 2000-2013 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.portal.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    import com.liferay.portal.model.Website;
021    
022    import java.io.Externalizable;
023    import java.io.IOException;
024    import java.io.ObjectInput;
025    import java.io.ObjectOutput;
026    
027    import java.util.Date;
028    
029    /**
030     * The cache model class for representing Website in entity cache.
031     *
032     * @author Brian Wing Shun Chan
033     * @see Website
034     * @generated
035     */
036    public class WebsiteCacheModel implements CacheModel<Website>, Externalizable {
037            @Override
038            public String toString() {
039                    StringBundler sb = new StringBundler(23);
040    
041                    sb.append("{websiteId=");
042                    sb.append(websiteId);
043                    sb.append(", companyId=");
044                    sb.append(companyId);
045                    sb.append(", userId=");
046                    sb.append(userId);
047                    sb.append(", userName=");
048                    sb.append(userName);
049                    sb.append(", createDate=");
050                    sb.append(createDate);
051                    sb.append(", modifiedDate=");
052                    sb.append(modifiedDate);
053                    sb.append(", classNameId=");
054                    sb.append(classNameId);
055                    sb.append(", classPK=");
056                    sb.append(classPK);
057                    sb.append(", url=");
058                    sb.append(url);
059                    sb.append(", typeId=");
060                    sb.append(typeId);
061                    sb.append(", primary=");
062                    sb.append(primary);
063                    sb.append("}");
064    
065                    return sb.toString();
066            }
067    
068            public Website toEntityModel() {
069                    WebsiteImpl websiteImpl = new WebsiteImpl();
070    
071                    websiteImpl.setWebsiteId(websiteId);
072                    websiteImpl.setCompanyId(companyId);
073                    websiteImpl.setUserId(userId);
074    
075                    if (userName == null) {
076                            websiteImpl.setUserName(StringPool.BLANK);
077                    }
078                    else {
079                            websiteImpl.setUserName(userName);
080                    }
081    
082                    if (createDate == Long.MIN_VALUE) {
083                            websiteImpl.setCreateDate(null);
084                    }
085                    else {
086                            websiteImpl.setCreateDate(new Date(createDate));
087                    }
088    
089                    if (modifiedDate == Long.MIN_VALUE) {
090                            websiteImpl.setModifiedDate(null);
091                    }
092                    else {
093                            websiteImpl.setModifiedDate(new Date(modifiedDate));
094                    }
095    
096                    websiteImpl.setClassNameId(classNameId);
097                    websiteImpl.setClassPK(classPK);
098    
099                    if (url == null) {
100                            websiteImpl.setUrl(StringPool.BLANK);
101                    }
102                    else {
103                            websiteImpl.setUrl(url);
104                    }
105    
106                    websiteImpl.setTypeId(typeId);
107                    websiteImpl.setPrimary(primary);
108    
109                    websiteImpl.resetOriginalValues();
110    
111                    return websiteImpl;
112            }
113    
114            public void readExternal(ObjectInput objectInput) throws IOException {
115                    websiteId = objectInput.readLong();
116                    companyId = objectInput.readLong();
117                    userId = objectInput.readLong();
118                    userName = objectInput.readUTF();
119                    createDate = objectInput.readLong();
120                    modifiedDate = objectInput.readLong();
121                    classNameId = objectInput.readLong();
122                    classPK = objectInput.readLong();
123                    url = objectInput.readUTF();
124                    typeId = objectInput.readInt();
125                    primary = objectInput.readBoolean();
126            }
127    
128            public void writeExternal(ObjectOutput objectOutput)
129                    throws IOException {
130                    objectOutput.writeLong(websiteId);
131                    objectOutput.writeLong(companyId);
132                    objectOutput.writeLong(userId);
133    
134                    if (userName == null) {
135                            objectOutput.writeUTF(StringPool.BLANK);
136                    }
137                    else {
138                            objectOutput.writeUTF(userName);
139                    }
140    
141                    objectOutput.writeLong(createDate);
142                    objectOutput.writeLong(modifiedDate);
143                    objectOutput.writeLong(classNameId);
144                    objectOutput.writeLong(classPK);
145    
146                    if (url == null) {
147                            objectOutput.writeUTF(StringPool.BLANK);
148                    }
149                    else {
150                            objectOutput.writeUTF(url);
151                    }
152    
153                    objectOutput.writeInt(typeId);
154                    objectOutput.writeBoolean(primary);
155            }
156    
157            public long websiteId;
158            public long companyId;
159            public long userId;
160            public String userName;
161            public long createDate;
162            public long modifiedDate;
163            public long classNameId;
164            public long classPK;
165            public String url;
166            public int typeId;
167            public boolean primary;
168    }