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.portal.kernel.json;
016    
017    /**
018     * @author Brian Wing Shun Chan
019     */
020    public class JSONFactoryUtil {
021    
022            public static JSONArray createJSONArray() {
023                    return getJSONFactory().createJSONArray();
024            }
025    
026            public static JSONArray createJSONArray(String json) throws JSONException {
027                    return getJSONFactory().createJSONArray(json);
028            }
029    
030            public static JSONObject createJSONObject() {
031                    return getJSONFactory().createJSONObject();
032            }
033    
034            public static JSONObject createJSONObject(String json)
035                    throws JSONException {
036    
037                    return getJSONFactory().createJSONObject(json);
038            }
039    
040            public static Object deserialize(JSONObject jsonObj) {
041                    return getJSONFactory().deserialize(jsonObj);
042            }
043    
044            public static Object deserialize(String json) {
045                    return getJSONFactory().deserialize(json);
046            }
047    
048            public static JSONFactory getJSONFactory() {
049                    return _jsonFactory;
050            }
051    
052            public static String serialize(Object obj) {
053                    return getJSONFactory().serialize(obj);
054            }
055    
056            public void setJSONFactory(JSONFactory jsonFactory) {
057                    _jsonFactory = jsonFactory;
058            }
059    
060            private static JSONFactory _jsonFactory;
061    
062    }