Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
License Agreement. JBoss RichFaces - Ajax4jsf Component Library Copyright (C) 2007 Exadel, Inc. This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1 as published by the Free Software Foundation. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
package org.richfaces.json;
final class JSONAccessor {
    private JSONAccessor() {
    static boolean putValue(JSONObject objectString keyObject value) {
        try {
            if (value instanceof Boolean) {
                object.put(key, ((Booleanvalue).booleanValue());
            } else if (value instanceof Double) {
                object.put(key, ((Doublevalue).doubleValue());
            } else if (value instanceof Integer) {
                object.put(key, ((Integervalue).intValue());
            } else if (value instanceof Long) {
                object.put(key, ((Longvalue).longValue());
            } else if (value instanceof Collection) {
                object.put(key, (Collectionvalue);
            } else if (value instanceof Map) {
                object.put(key, (Mapvalue);
            } else {
        } catch (JSONException e) {
            return false;
        // no exception - suppose it's added
        return true;
    static Object unwrapValue(Object valuethrows JSONException {
        if (value instanceof JSONObject) {
            return new JSONMap((JSONObjectvalue);
        } else if (value instanceof JSONArray) {
            return new JSONCollection((JSONArrayvalue);
        return value;
    static Object getValue(JSONObject objectString keythrows JSONException {
        return unwrapValue(object.get(key));
New to GrepCode? Check out our FAQ X