001    /**
002     * Copyright (c) 2000-2012 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    import java.io.Writer;
018    
019    import java.util.Date;
020    import java.util.Iterator;
021    
022    /**
023     * @author Brian Wing Shun Chan
024     */
025    public interface JSONObject {
026    
027            public boolean getBoolean(String key);
028    
029            public boolean getBoolean(String key, boolean defaultValue);
030    
031            public double getDouble(String key);
032    
033            public double getDouble(String key, double defaultValue);
034    
035            public int getInt(String key);
036    
037            public int getInt(String key, int defaultValue);
038    
039            public JSONArray getJSONArray(String key);
040    
041            public JSONObject getJSONObject(String key);
042    
043            public long getLong(String key);
044    
045            public long getLong(String key, long defaultValue);
046    
047            public String getString(String key);
048    
049            public String getString(String key, String defaultValue);
050    
051            public boolean has(String key);
052    
053            public boolean isNull(String key);
054    
055            public Iterator<String> keys();
056    
057            public int length();
058    
059            public JSONArray names();
060    
061            public JSONObject put(String key, boolean value);
062    
063            public JSONObject put(String key, Date value);
064    
065            public JSONObject put(String key, double value);
066    
067            public JSONObject put(String key, int value);
068    
069            public JSONObject put(String key, JSONArray value);
070    
071            public JSONObject put(String key, JSONObject value);
072    
073            public JSONObject put(String key, long value);
074    
075            public JSONObject put(String key, String value);
076    
077            public JSONObject putException(Exception exception);
078    
079            public Object remove(String key);
080    
081            public String toString();
082    
083            public String toString(int indentFactor) throws JSONException;
084    
085            public Writer write(Writer writer) throws JSONException;
086    
087    }