Examples of MarshallException


Examples of org.jabsorb.serializer.MarshallException

    if (ser.getMarshallClassHints()) {
      try {
        obj.put("javaClass", o.getClass().getName());
      }
      catch (JSONException e) {
        throw new MarshallException("javaClass not found!");
      }
    }
    try {
      obj.put("nsdictionary", dictionarydata);
      state.push(o, dictionarydata, "nsdictionary");
    }
    catch (JSONException e) {
      throw new MarshallException("Could not add nsdictionary to object: " + e.getMessage());
    }
    Object key = null;
    try {
      Enumeration keyEnum = dictionary.allKeys().objectEnumerator();
      while (keyEnum.hasMoreElements()) {
        key = keyEnum.nextElement();
        Object value = dictionary.objectForKey(key);
        String keyString = key.toString(); // only support String keys

        Object json = ser.marshall(state, dictionarydata, value, keyString);

        // omit the object entirely if it's a circular reference or duplicate
        // it will be regenerated in the fixups phase
        if (JSONSerializer.CIRC_REF_OR_DUPLICATE != json) {
          dictionarydata.put(keyString, json);
        }
      }
    }
    catch (MarshallException e) {
      throw (MarshallException) new MarshallException("nsdictionary key " + key + " " + e.getMessage()).initCause(e);
    }
    catch (JSONException e) {
      throw (MarshallException) new MarshallException("nsdictionary key " + key + " " + e.getMessage()).initCause(e);
    }
    finally {
      state.pop();
    }
    return obj;
View Full Code Here

Examples of org.jabsorb.serializer.MarshallException

      if (o instanceof NSData) {
        bytes = NSPropertyListSerialization.stringFromPropertyList(o);
      }
      else {
        throw new MarshallException("cannot marshall date using class " + o.getClass());
      }
      JSONObject obj = new JSONObject();
      if (ser.getMarshallClassHints()) {
        obj.put("javaClass", o.getClass().getName());
      }
      obj.put("bytes", bytes);
      return obj;
    }
    catch (JSONException e) {
      throw new MarshallException("Failed to marshall NSData.", e);
    }
  }
View Full Code Here

Examples of org.jabsorb.serializer.MarshallException

          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);
    }
  }
View Full Code Here

Examples of org.jabsorb.serializer.MarshallException

    BeanData bd;
    try {
      bd = getBeanData(o.getClass());
    }
    catch (IntrospectionException e) {
      throw new MarshallException(o.getClass().getName() + " is not a bean", e);
    }

    JSONObject val = new JSONObject();
    if (ser.getMarshallClassHints()) {
      try {
        val.put("javaClass", o.getClass().getName());
      }
      catch (JSONException e) {
        throw new MarshallException("JSONException: " + e.getMessage(), e);
      }
    }
    Object args[] = new Object[0];
    Object result;
    for (Map.Entry<String, Method> ent : bd.readableProps.entrySet()) {
      String prop = ent.getKey();
      Method getMethod = ent.getValue();
      if (log.isDebugEnabled()) {
        log.debug("invoking " + getMethod.getName() + "()");
      }
      try {
        result = getMethod.invoke(o, args);
      }
      catch (Throwable e) {
        if (e instanceof InvocationTargetException) {
          e = ((InvocationTargetException) e).getTargetException();
        }
        throw new MarshallException("bean " + o.getClass().getName() + " can't invoke " + getMethod.getName() + ": " + e.getMessage(), e);
      }
      try {
        if (result != null || ser.getMarshallNullAttributes()) {
          try {
            Object json = ser.marshall(state, o, result, prop);
            val.put(prop, json);
          }
          catch (JSONException e) {
            throw new MarshallException("JSONException: " + e.getMessage(), e);
          }
        }
      }
      catch (MarshallException e) {
        throw new MarshallException("bean " + o.getClass().getName() + " " + e.getMessage(), e);
      }
    }

    return val;
  }
View Full Code Here

Examples of org.jabsorb.serializer.MarshallException

      result.put("value", obj.value());
      result.put("name", obj.name());
      return result;
    }
    catch (JSONException e) {
      throw new MarshallException("Failed to marshall ERXConstant.", e);
    }
  }
View Full Code Here

Examples of org.jabsorb.serializer.MarshallException

    if (ser.getMarshallClassHints()) {
      try {
        obj.put("javaClass", o.getClass().getName());
      }
      catch (JSONException e) {
        throw new MarshallException("javaClass not found!");
      }
    }
    try {
      obj.put("nsarray", arr);
      state.push(o, arr, "nsarray");
    }
    catch (JSONException e) {
      throw new MarshallException("Error setting nsarray: " + e);
    }
    int index = 0;
    try {
      Enumeration e = nsarray.objectEnumerator();
      while (e.hasMoreElements()) {
        Object json = ser.marshall(state, arr, e.nextElement(), Integer.valueOf(index));
        if (JSONSerializer.CIRC_REF_OR_DUPLICATE != json) {
          arr.put(json);
        }
        else {
          // put a slot where the object would go, so it can be fixed up properly in the fix up phase
          arr.put(JSONObject.NULL);
        }
        index++;
      }
    }
    catch (MarshallException e) {
      throw (MarshallException) new MarshallException("element " + index).initCause(e);
    }
    finally {
      state.pop();
    }
    return obj;
View Full Code Here

Examples of org.jabsorb.serializer.MarshallException

      //JSONObject eoData = new JSONObject();
      //obj.put("eo", eoData);
      return obj;
    }
    catch (JSONException e) {
      throw new MarshallException("Failed to marshall EO.", e);
    }
  }
View Full Code Here

Examples of org.jabsorb.serializer.MarshallException

      if (o instanceof NSTimestamp) {
        time = ((NSTimestamp) o).getTime();
        tz = ((NSTimestamp) o).timeZone().getID();
      }
      else {
        throw new MarshallException("cannot marshall date using class " + o.getClass());
      }
      JSONObject obj = new JSONObject();
      if (ser.getMarshallClassHints()) {
        obj.put("javaClass", o.getClass().getName());
      }
      obj.put("time", time);
      obj.put("tz", tz);
      return obj;
    }
    catch (JSONException e) {
      throw new MarshallException("Failed to marshall NSTimestamp.", e);
    }
  }
View Full Code Here

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

     * @throws MarshallException If called when currentLocation is empty
     */
    public void pop() throws MarshallException {
        if (_currentLocation.size() == 0) {
            // this is a sanity check
            throw new MarshallException("scope error, attempt to pop too much off the scope stack.");
        }
        _currentLocation.removeLast();
    }
View Full Code Here

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

        if (null != oclass && !super.isProxy(oclass)) {
            final BeanData bd;
            try {
                bd = BeanSerializer.getBeanData(oclass);
            } catch (IntrospectionException e) {
                throw new MarshallException(oclass.getName()
                        + " is not a bean", e);
            }

            if (_ser.getMarshallClassHints()) {
                try {
                    val.put(IJSONRPCConstants.TAG_JAVACLASS,
                            oclass.getName());
                } catch (Exception e) {
                    throw new MarshallException(
                            "JSONException: " + e.getMessage(), e);
                }
            }
            final Iterator i = bd.readableProps.entrySet().iterator();
            final Object args[] = new Object[0];
            Object result;
            while (i.hasNext()) {
                final Map.Entry ent = (Map.Entry) i.next();
                final String prop = (String) ent.getKey();
                final Method getMethod = (Method) ent.getValue();
                if (logger.isLoggable(Level.FINE)) {
                    logger.log(Level.FINE, "invoking {0}()", getMethod.getName());
                }
                try {
                    result = getMethod.invoke(o, args);
                } catch (Throwable e) {
                    if (e instanceof InvocationTargetException) {
                        e = ((InvocationTargetException) e).getTargetException();
                    }
                    throw new MarshallException("bean " + oclass.getName()
                            + " can't invoke " + getMethod.getName() + ": " + e.getMessage(), e);
                }
                try {
                    if (result != null || _ser.getMarshallNullAttributes()) {
                        try {
                            Object json = _ser.marshall(state, o, result, prop);

                            // omit the object entirely if it's a circular reference or duplicate
                            // it will be regenerated in the fixups phase
                            if (JSONSerializerController.CIRC_REF_OR_DUPLICATE != json) {
                                val.put(prop, json);
                            }
                        } catch (JSONException e) {
                            throw new MarshallException(
                                    "JSONException: " + e.getMessage(), e);
                        }
                    }
                } catch (MarshallException e) {
                    throw new MarshallException("bean " + oclass.getName() + " " + e.getMessage(), e);
                }
            }

        }
        return val;
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.