1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   *
12   *
13   */
14  
15  package com.liferay.portlet.messageboards.service.http;
16  
17  import com.liferay.portal.kernel.json.JSONArray;
18  import com.liferay.portal.kernel.json.JSONFactoryUtil;
19  import com.liferay.portal.kernel.json.JSONObject;
20  import com.liferay.portal.kernel.util.StringPool;
21  
22  import com.liferay.portlet.messageboards.model.MBMessageFlag;
23  
24  import java.util.Date;
25  import java.util.List;
26  
27  /**
28   * <a href="MBMessageFlagJSONSerializer.java.html"><b><i>View Source</i></b></a>
29   *
30   * <p>
31   * ServiceBuilder generated this class. Modifications in this class will be
32   * overwritten the next time is generated.
33   * </p>
34   *
35   * <p>
36   * This class is used by {@link MBMessageFlagServiceJSON} to translate objects.
37   * </p>
38   *
39   * @author    Brian Wing Shun Chan
40   * @see       com.liferay.portlet.messageboards.service.http.MBMessageFlagServiceJSON
41   * @generated
42   */
43  public class MBMessageFlagJSONSerializer {
44      public static JSONObject toJSONObject(MBMessageFlag model) {
45          JSONObject jsonObj = JSONFactoryUtil.createJSONObject();
46  
47          jsonObj.put("messageFlagId", model.getMessageFlagId());
48          jsonObj.put("userId", model.getUserId());
49  
50          Date modifiedDate = model.getModifiedDate();
51  
52          String modifiedDateJSON = StringPool.BLANK;
53  
54          if (modifiedDate != null) {
55              modifiedDateJSON = String.valueOf(modifiedDate.getTime());
56          }
57  
58          jsonObj.put("modifiedDate", modifiedDateJSON);
59          jsonObj.put("threadId", model.getThreadId());
60          jsonObj.put("messageId", model.getMessageId());
61          jsonObj.put("flag", model.getFlag());
62  
63          return jsonObj;
64      }
65  
66      public static JSONArray toJSONArray(
67          com.liferay.portlet.messageboards.model.MBMessageFlag[] models) {
68          JSONArray jsonArray = JSONFactoryUtil.createJSONArray();
69  
70          for (MBMessageFlag model : models) {
71              jsonArray.put(toJSONObject(model));
72          }
73  
74          return jsonArray;
75      }
76  
77      public static JSONArray toJSONArray(
78          com.liferay.portlet.messageboards.model.MBMessageFlag[][] models) {
79          JSONArray jsonArray = JSONFactoryUtil.createJSONArray();
80  
81          for (MBMessageFlag[] model : models) {
82              jsonArray.put(toJSONArray(model));
83          }
84  
85          return jsonArray;
86      }
87  
88      public static JSONArray toJSONArray(
89          List<com.liferay.portlet.messageboards.model.MBMessageFlag> models) {
90          JSONArray jsonArray = JSONFactoryUtil.createJSONArray();
91  
92          for (MBMessageFlag model : models) {
93              jsonArray.put(toJSONObject(model));
94          }
95  
96          return jsonArray;
97      }
98  }