1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
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  }