Package org.sf.bee.commons.remoting.jrpc.exceptions.impl

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.Dictionary") || java_class.equals("java.util.Hashtable"))) {
            throw new UnmarshallException("not a Dictionary");
        }
        JSONObject jsonmap;
        try {
            jsonmap = jso.getJSONObject("map");
        } catch (JSONException e) {
            throw new UnmarshallException("map missing", e);
        }
        if (jsonmap == null) {
            throw new UnmarshallException("map missing");
        }
        ObjectMatch m = new ObjectMatch(-1);
        state.setSerialized(o, m);

        Iterator i = jsonmap.keys();
        String key = null;
        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


        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");
        }
        Hashtable ht;
        if (java_class.equals("java.util.Dictionary") || java_class.equals("java.util.Hashtable")) {
            ht = new Hashtable();
        } else {
            throw new UnmarshallException("not a Dictionary");
        }
        JSONObject jsonmap;
        try {
            jsonmap = jso.getJSONObject("map");
        } catch (JSONException e) {
            throw new UnmarshallException("map missing", e);
        }
        if (jsonmap == null) {
            throw new UnmarshallException("map missing");
        }

        state.setSerialized(o, ht);

        Iterator i = jsonmap.keys();
        String key = null;
        try {
            while (i.hasNext()) {
                key = (String) i.next();
                ht.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 ht;
    }
View Full Code Here

        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.Set") || java_class.equals("java.util.AbstractSet") || java_class.equals("java.util.LinkedHashSet") || java_class.equals("java.util.TreeSet") || java_class.equals("java.util.HashSet"))) {
            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");
        }

        ObjectMatch m = new ObjectMatch(-1);
        state.setSerialized(o, m);
        Iterator i = jsonset.keys();
        String key = null;

        try {
            while (i.hasNext()) {
                key = (String) i.next();
                m.setMismatch(_ser.tryUnmarshall(state, null, jsonset.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

        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

    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

            }
            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

        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

        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

        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

        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

TOP

Related Classes of org.sf.bee.commons.remoting.jrpc.exceptions.impl.UnmarshallException

Copyright © 2018 www.massapicom. 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.