Esempio n. 1
0
 /**
  * @param expr
  * @return
  */
 public static Expr negate(Expr expr) {
   if (expr instanceof ConstExpr) {
     ConstExpr ce = (ConstExpr) expr;
     JsonValue t = ce.value;
     if (t instanceof JsonLong) {
       return new ConstExpr(new JsonLong(-((JsonLong) t).get()));
     }
     if (t instanceof MutableJsonLong) {
       ((MutableJsonLong) t).negate();
       return expr;
     }
     if (t instanceof JsonDouble) {
       return new ConstExpr(new JsonDouble(-((JsonDouble) t).get()));
     }
     if (t instanceof MutableJsonDouble) {
       ((MutableJsonDouble) t).negate();
       return expr;
     }
     if (t instanceof JsonDecimal) {
       return new ConstExpr(new JsonDecimal(((JsonDecimal) t).get().negate()));
     }
     if (t instanceof MutableJsonDecimal) {
       ((MutableJsonDecimal) t).negate();
       return expr;
     }
   }
   return new MathExpr(MathExpr.MINUS, new ConstExpr(JsonLong.ZERO), expr);
 }
Esempio n. 2
0
 /*
  * (non-Javadoc)
  *
  * @see com.ibm.jaql.json.meta.MetaAccessor#get(java.lang.Object,
  *      com.ibm.jaql.json.type.Item)
  */
 @Override
 public JsonValue get(Object obj, JsonValue target)
     throws IllegalArgumentException, IllegalAccessException, InvocationTargetException {
   double x = (Double) getter.invoke(obj);
   ((MutableJsonDouble) target).set(x);
   return target;
 }