Examples of UnmarshallException


Examples of org.sf.bee.commons.remoting.jrpc.exceptions.impl.UnmarshallException

        JSONObject jso = (JSONObject) o;
        String java_class;
        try {
            java_class = jso.getString(TAG_JAVACLASS);
        } catch (JSONException e) {
            throw new UnmarshallException("Could not read javaClass", e);
        }
        if (java_class == null) {
            throw new UnmarshallException("no type hint");
        }
        AbstractSet abset = null;
        if (java_class.equals("java.util.Set") || java_class.equals("java.util.AbstractSet") || java_class.equals("java.util.HashSet")) {
            abset = new HashSet();
        } else if (java_class.equals("java.util.TreeSet")) {
            abset = new TreeSet();
        } else if (java_class.equals("java.util.LinkedHashSet")) {
            abset = new LinkedHashSet();
        } else {
            throw new UnmarshallException("not a Set");
        }
        JSONObject jsonset;
        try {
            jsonset = jso.getJSONObject("set");
        } catch (JSONException e) {
            throw new UnmarshallException("set missing", e);
        }

        if (jsonset == null) {
            throw new UnmarshallException("set missing");
        }

        Iterator i = jsonset.keys();
        String key = null;
        state.setSerialized(o, abset);
        try {
            while (i.hasNext()) {
                key = (String) i.next();
                Object setElement = jsonset.get(key);
                abset.add(_ser.unmarshall(state, null, setElement));
            }
        } catch (UnmarshallException e) {
            throw new UnmarshallException("key " + i + e.getMessage(), e);
        } catch (JSONException e) {
            throw new UnmarshallException("key " + key + " " + e.getMessage(), e);
        }
        return abset;
    }
View Full Code Here

Examples of org.sf.bee.commons.remoting.jrpc.exceptions.impl.UnmarshallException

    public ObjectMatch tryUnmarshall(SerializerState state, Class clazz,
            Object jso) throws UnmarshallException {
        try {
            toNumber(clazz, jso);
        } catch (NumberFormatException e) {
            throw new UnmarshallException("not a number", e);
        }
        state.setSerialized(jso, ObjectMatch.OKAY);
        return ObjectMatch.OKAY;
    }
View Full Code Here

Examples of org.sf.bee.commons.remoting.jrpc.exceptions.impl.UnmarshallException

            }
            Object num = toNumber(clazz, jso);
            state.setSerialized(jso, num);
            return num;
        } catch (NumberFormatException e) {
            throw new UnmarshallException("cannot convert object " + jso + " to type " + clazz.getName(), e);
        }
    }
View Full Code Here

Examples of org.sf.bee.commons.remoting.jrpc.exceptions.impl.UnmarshallException

        if (jso instanceof String) {
            try {
                returnValue = new Boolean((String) jso);
            } catch (Exception e) {
                throw new UnmarshallException("Cannot convert " + jso + " to Boolean", e);
            }
        } else if (jso instanceof Boolean || clazz == boolean.class) {
            returnValue = (Boolean) jso;
        }
View Full Code Here

Examples of org.sf.bee.commons.remoting.jrpc.exceptions.impl.UnmarshallException

        JSONObject jso = (JSONObject) o;
        String java_class;
        try {
            java_class = jso.getString(TAG_JAVACLASS);
        } catch (JSONException e) {
            throw new UnmarshallException("Could not read javaClass", e);
        }
        if (java_class == null) {
            throw new UnmarshallException("no type hint");
        }
        if (!(java_class.equals("java.util.Map") ||
                java_class.equals("java.util.AbstractMap") ||
                java_class.equals("java.util.LinkedHashMap") ||
                java_class.equals("java.util.TreeMap") ||
                java_class.equals("java.util.HashMap"))) {
            throw new UnmarshallException("'" + java_class + "' is not a Map");
        }
        JSONObject jsonmap;
        try {
            jsonmap = jso.getJSONObject("map");
        } catch (JSONException e) {
            throw new UnmarshallException("Could not read map: " + e.getMessage(), e);
        }
        if (jsonmap == null) {
            throw new UnmarshallException("map missing");
        }
        ObjectMatch m = new ObjectMatch(-1);
        Iterator i = jsonmap.keys();
        String key = null;
        state.setSerialized(o, m);
        try {
            while (i.hasNext()) {
                key = (String) i.next();
                m.setMismatch(_ser.tryUnmarshall(state, null, jsonmap.get(key)).max(m).getMismatch());
            }
        } catch (UnmarshallException e) {
            throw new UnmarshallException("key " + key + " " + e.getMessage(), e);
        } catch (JSONException e) {
            throw new UnmarshallException("key " + key + " " + e.getMessage(), e);
        }
        return m;
    }
View Full Code Here

Examples of org.sf.bee.commons.remoting.jrpc.exceptions.impl.UnmarshallException

        JSONObject jso = (JSONObject) o;
        String java_class;
        try {
            java_class = jso.getString(TAG_JAVACLASS);
        } catch (JSONException e) {
            throw new UnmarshallException("Could not read javaClass", e);
        }
        if (java_class == null) {
            throw new UnmarshallException("no type hint");
        }
        AbstractMap abmap;
        if (java_class.equals("java.util.Map") || java_class.equals("java.util.AbstractMap") || java_class.equals("java.util.HashMap")) {
            abmap = new HashMap();
        } else if (java_class.equals("java.util.TreeMap")) {
            abmap = new TreeMap();
        } else if (java_class.equals("java.util.LinkedHashMap")) {
            abmap = new LinkedHashMap();
        } else {
            throw new UnmarshallException("'" + java_class + "' is not a Map");
        }
        JSONObject jsonmap;
        try {
            jsonmap = jso.getJSONObject("map");
        } catch (JSONException e) {
            throw new UnmarshallException("Could not read map: " + e.getMessage(), e);
        }
        if (jsonmap == null) {
            throw new UnmarshallException("map missing");
        }
        state.setSerialized(o, abmap);
        Iterator i = jsonmap.keys();
        String key = null;
        try {
            while (i.hasNext()) {
                key = (String) i.next();
                abmap.put(key, _ser.unmarshall(state, null, jsonmap.get(key)));
            }
        } catch (UnmarshallException e) {
            throw new UnmarshallException("key " + key + " " + e.getMessage(), e);
        } catch (JSONException e) {
            throw new UnmarshallException("key " + key + " " + e.getMessage(), e);
        }

        return abmap;
    }
View Full Code Here

Examples of org.sf.bee.commons.remoting.jrpc.exceptions.impl.UnmarshallException

        JSONObject jso = (JSONObject) o;
        String java_class;
        try {
            java_class = jso.getString(TAG_JAVACLASS);
        } catch (JSONException e) {
            throw new UnmarshallException("no type hint", e);
        }
        if (java_class == null) {
            throw new UnmarshallException("no type hint");
        }
        if (!(java_class.equals("java.util.Date")) &&
                !(java_class.equals("java.sql.Timestamp")) &&
                !(java_class.equals("java.sql.Time")) &&
                !(java_class.equals("java.sql.Date"))) {
            throw new UnmarshallException("not a Date");
        }
        state.setSerialized(o, ObjectMatch.OKAY);
        return ObjectMatch.OKAY;
    }
View Full Code Here

Examples of org.sf.bee.commons.remoting.jrpc.exceptions.impl.UnmarshallException

        JSONObject jso = (JSONObject) o;
        long time;
        try {
            time = jso.getLong("time");
        } catch (JSONException e) {
            throw new UnmarshallException("Could not get the time in date serialiser", e);
        }
        if (jso.has(TAG_JAVACLASS)) {
            try {
                clazz = Class.forName(jso.getString(TAG_JAVACLASS));
            } catch (ClassNotFoundException e) {
                throw new UnmarshallException(e.getMessage(), e);
            } catch (JSONException e) {
                throw new UnmarshallException("Could not find javaClass", e);
            }
        }
        Object returnValue = null;
        if (Date.class.equals(clazz)) {
            returnValue = new Date(time);
        } else if (Timestamp.class.equals(clazz)) {
            returnValue = new Timestamp(time);
        } else if (java.sql.Date.class.equals(clazz)) {
            returnValue = new java.sql.Date(time);
        } else if (java.sql.Time.class.equals(clazz)) {
            returnValue = new Time(time);
        }
        if (returnValue == null) {
            throw new UnmarshallException("invalid class " + clazz);
        }
        state.setSerialized(o, returnValue);
        return returnValue;
    }
View Full Code Here

Examples of org.sf.bee.commons.remoting.jrpc.exceptions.impl.UnmarshallException

        int object_id;
        try {
            json_type = jso.getString("JSONRPCType");
            object_id = jso.getInt("objectID");
        } catch (JSONException e) {
            throw new UnmarshallException(e.getMessage(), e);
        }
        if (json_type != null) {
            if ((json_type.equals("Reference")) || (json_type.equals("CallableReference"))) {
                ref = bridge.getReference(object_id);
            }
View Full Code Here

Examples of org.sf.bee.commons.remoting.jrpc.exceptions.impl.UnmarshallException

        JSONObject jso = (JSONObject) o;
        String java_class;
        try {
            java_class = jso.getString(TAG_JAVACLASS);
        } catch (JSONException e) {
            throw new UnmarshallException("Could not read javaClass", e);
        }
        if (java_class == null) {
            throw new UnmarshallException("no type hint");
        }
        if (!this.isCompatible(java_class)) {
            throw new UnmarshallException("not a List");
        }
        JSONArray jsonlist;
        try {
            jsonlist = jso.getJSONArray("list");
        } catch (JSONException e) {
            throw new UnmarshallException("Could not read list: " + e.getMessage(), e);
        }
        if (jsonlist == null) {
            throw new UnmarshallException("list missing");
        }
        int i = 0;
        ObjectMatch m = new ObjectMatch(-1);
        state.setSerialized(o, m);
        try {
            for (; i < jsonlist.length(); i++) {
                m.setMismatch(_ser.tryUnmarshall(state, null, jsonlist.get(i)).max(m).getMismatch());
            }
        } catch (UnmarshallException e) {
            throw new UnmarshallException("element " + i + " " + e.getMessage(), e);
        } catch (JSONException e) {
            throw new UnmarshallException("element " + i + " " + e.getMessage(), e);
        }
        return m;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.