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.portlet.messageboards.service.http;
016    
017    import com.liferay.portal.kernel.json.JSONArray;
018    import com.liferay.portal.kernel.json.JSONFactoryUtil;
019    import com.liferay.portal.kernel.json.JSONObject;
020    import com.liferay.portal.kernel.util.StringPool;
021    
022    import com.liferay.portlet.messageboards.model.MBMessageFlag;
023    
024    import java.util.Date;
025    import java.util.List;
026    
027    /**
028     * @author    Brian Wing Shun Chan
029     * @generated
030     */
031    public class MBMessageFlagJSONSerializer {
032            public static JSONObject toJSONObject(MBMessageFlag model) {
033                    JSONObject jsonObj = JSONFactoryUtil.createJSONObject();
034    
035                    jsonObj.put("messageFlagId", model.getMessageFlagId());
036                    jsonObj.put("userId", model.getUserId());
037    
038                    Date modifiedDate = model.getModifiedDate();
039    
040                    String modifiedDateJSON = StringPool.BLANK;
041    
042                    if (modifiedDate != null) {
043                            modifiedDateJSON = String.valueOf(modifiedDate.getTime());
044                    }
045    
046                    jsonObj.put("modifiedDate", modifiedDateJSON);
047                    jsonObj.put("threadId", model.getThreadId());
048                    jsonObj.put("messageId", model.getMessageId());
049                    jsonObj.put("flag", model.getFlag());
050    
051                    return jsonObj;
052            }
053    
054            public static JSONArray toJSONArray(
055                    com.liferay.portlet.messageboards.model.MBMessageFlag[] models) {
056                    JSONArray jsonArray = JSONFactoryUtil.createJSONArray();
057    
058                    for (MBMessageFlag model : models) {
059                            jsonArray.put(toJSONObject(model));
060                    }
061    
062                    return jsonArray;
063            }
064    
065            public static JSONArray toJSONArray(
066                    com.liferay.portlet.messageboards.model.MBMessageFlag[][] models) {
067                    JSONArray jsonArray = JSONFactoryUtil.createJSONArray();
068    
069                    for (MBMessageFlag[] model : models) {
070                            jsonArray.put(toJSONArray(model));
071                    }
072    
073                    return jsonArray;
074            }
075    
076            public static JSONArray toJSONArray(
077                    List<com.liferay.portlet.messageboards.model.MBMessageFlag> models) {
078                    JSONArray jsonArray = JSONFactoryUtil.createJSONArray();
079    
080                    for (MBMessageFlag model : models) {
081                            jsonArray.put(toJSONObject(model));
082                    }
083    
084                    return jsonArray;
085            }
086    }