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