Search in sources :

Example 1 with NSSet

use of com.webobjects.foundation.NSSet in project wonder-slim by undur.

the class NSSetSerializer method marshall.

public Object marshall(SerializerState state, Object p, Object o) throws MarshallException {
    try {
        NSSet set = (NSSet) o;
        JSONObject obj = new JSONObject();
        JSONObject setdata = new JSONObject();
        obj.put("javaClass", o.getClass().getName());
        obj.put("set", setdata);
        String key = null;
        try {
            int index = 0;
            Enumeration i = set.objectEnumerator();
            while (i.hasMoreElements()) {
                Object value = i.nextElement();
                setdata.put(key, ser.marshall(state, o, value, Integer.valueOf(index)));
                index++;
            }
        } catch (MarshallException e) {
            throw new MarshallException("set key " + key + e.getMessage());
        }
        return obj;
    } catch (JSONException e) {
        throw new MarshallException("Failed to marshall NSSet.", e);
    }
}
Also used : Enumeration(java.util.Enumeration) JSONObject(org.json.JSONObject) MarshallException(org.jabsorb.serializer.MarshallException) JSONException(org.json.JSONException) JSONObject(org.json.JSONObject) NSSet(com.webobjects.foundation.NSSet)

Aggregations

NSSet (com.webobjects.foundation.NSSet)1 Enumeration (java.util.Enumeration)1 MarshallException (org.jabsorb.serializer.MarshallException)1 JSONException (org.json.JSONException)1 JSONObject (org.json.JSONObject)1