示例#1
0
    @Override
    public Object invoke(Object proxy, Method m, Object[] args) throws Throwable {
      // try {
      String key = m.getName();

      if (args.length == 0) {
        // built-in
        if ("objectData".equals(key)) return new ParseObjectData(obj);
        if (ParseBase.PARSE_OBJECT.equals(key)) return obj;

        // user define
        final Class<?> returnType = m.getReturnType();
        String typeName = returnType.getName();
        if (typeName.equalsIgnoreCase("float")) {
          return (float) obj.getDouble(key);
        } else {
          Object object = obj.get(key);
          if (returnType.isPrimitive() && object == null) {
            return 0;
          } else if (object != null
              && ParseObject.class.isInstance(object)
              && ParseBase.class.isAssignableFrom(returnType)) {
            return ((ParseFacade<?>) ParseFacade.get(returnType)).wrap((ParseObject) object);
          } else if (object != null
              && !returnType.isInstance(object)
              && !returnType.isPrimitive()) {
            return null;
          } else {
            return object;
          }
        }
      } else { // arg.length == 1
        // set value
        Object object = args[0];
        if (key.equals("objectId")) System.out.println("value " + object);

        if (object instanceof ParseBase) {
          obj.put(key, ((ParseBase) object).parseObject());
        } else {
          obj.put(key, object);
        }

        return null;
      }
      // } catch (InvocationTargetException e) {
      // throw e.getTargetException();
      // } catch (Exception e) {
      // throw e;
      // }
      // return something
    }
示例#2
0
 //		@Override
 //		@Override
 public List<T> find() throws ParseException {
   return facade.wrap(pq.find());
 }