Package org.jabsorb.serializer

Examples of org.jabsorb.serializer.MarshallException


            result = readMethod.invoke(o, (Object[]) null);
          } catch (Throwable e) {
            if (e instanceof InvocationTargetException)
              e = ((InvocationTargetException) e)
                  .getTargetException();
            throw new MarshallException("bean "
                + o.getClass().getName() + " can't invoke "
                + readMethod.getName() + ": " + e.getMessage());
          }

          try {
            if (result != null || ser.getMarshallNullAttributes())
              jso
                  .put(prop.getName(), ser.marshall(state, null,result,new Integer(0)));
          } catch (MarshallException e) {
            throw new MarshallException("bean "
                + o.getClass().getName() + " " + e.getMessage());
          }
        }

        return jso;
      }
    } catch (IntrospectionException e) {
      e.printStackTrace();
      throw new MarshallException(
          "There was an exception while inspecting the class "
              + o.getClass().getName() + ", see stdout");
    } catch (IllegalArgumentException e) {
      e.printStackTrace();
      throw new MarshallException(
          "There was an exception while inspecting the class "
              + o.getClass().getName() + ", see stdout");
    } catch (JSONException e) {
      throw new MarshallException(e.getMessage());
    }
    throw new MarshallException("The specified object ("
        + o.getClass().getName()
        + ") was not an instance of any of the serializable classes");
  }
View Full Code Here


        jso.put("javaClass", bigInteger.getClass().getName());
      }
      jso.put("value", bigInteger.intValue());
      return jso;
    } catch (Throwable t) {
      throw new MarshallException(t.getMessage());
    }
  }
View Full Code Here

      addAttributes(state, eo, obj);
      return obj;
    }
    catch (JSONException e) {
      throw new MarshallException("Failed to marshall EO.", e);
    }
  }
View Full Code Here

        }
      }
      _addCustomAttributes(state, source, destination);
    }
    catch (JSONException e) {
      throw new MarshallException("Failed to marshall EO.", e);
    }
    finally {
      if(useEO) {
        state.pop();
      }
View Full Code Here

    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

      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

          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

    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

      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

    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

TOP

Related Classes of org.jabsorb.serializer.MarshallException

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.