| CountryJSONSerializer.java |
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.portal.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.model.Country;
21
22 import java.util.List;
23
24 /**
25 * <a href="CountryJSONSerializer.java.html"><b><i>View Source</i></b></a>
26 *
27 * <p>
28 * ServiceBuilder generated this class. Modifications in this class will be
29 * overwritten the next time is generated.
30 * </p>
31 *
32 * <p>
33 * This class is used by {@link CountryServiceJSON} to translate objects.
34 * </p>
35 *
36 * @author Brian Wing Shun Chan
37 * @see com.liferay.portal.service.http.CountryServiceJSON
38 * @generated
39 */
40 public class CountryJSONSerializer {
41 public static JSONObject toJSONObject(Country model) {
42 JSONObject jsonObj = JSONFactoryUtil.createJSONObject();
43
44 jsonObj.put("countryId", model.getCountryId());
45 jsonObj.put("name", model.getName());
46 jsonObj.put("a2", model.getA2());
47 jsonObj.put("a3", model.getA3());
48 jsonObj.put("number", model.getNumber());
49 jsonObj.put("idd", model.getIdd());
50 jsonObj.put("active", model.getActive());
51
52 return jsonObj;
53 }
54
55 public static JSONArray toJSONArray(
56 com.liferay.portal.model.Country[] models) {
57 JSONArray jsonArray = JSONFactoryUtil.createJSONArray();
58
59 for (Country model : models) {
60 jsonArray.put(toJSONObject(model));
61 }
62
63 return jsonArray;
64 }
65
66 public static JSONArray toJSONArray(
67 com.liferay.portal.model.Country[][] models) {
68 JSONArray jsonArray = JSONFactoryUtil.createJSONArray();
69
70 for (Country[] model : models) {
71 jsonArray.put(toJSONArray(model));
72 }
73
74 return jsonArray;
75 }
76
77 public static JSONArray toJSONArray(
78 List<com.liferay.portal.model.Country> models) {
79 JSONArray jsonArray = JSONFactoryUtil.createJSONArray();
80
81 for (Country model : models) {
82 jsonArray.put(toJSONObject(model));
83 }
84
85 return jsonArray;
86 }
87 }