public final static Number add(final Object obj0, final Object obj1) { if (obj0 == null && obj1 == null) { return new Long(0); } final ELArithmetic delegate; if (BIGDECIMAL.matches(obj0, obj1)) delegate = BIGDECIMAL; else if (DOUBLE.matches(obj0, obj1)) delegate = DOUBLE; else if (BIGINTEGER.matches(obj0, obj1)) delegate = BIGINTEGER; else delegate = LONG; Number num0 = delegate.coerce(obj0); Number num1 = delegate.coerce(obj1); return delegate.add(num0, num1); }
public final static Number divide(final Object obj0, final Object obj1) { if (obj0 == null && obj1 == null) { return ZERO; } final ELArithmetic delegate; if (BIGDECIMAL.matches(obj0, obj1)) delegate = BIGDECIMAL; else if (BIGINTEGER.matches(obj0, obj1)) delegate = BIGDECIMAL; else delegate = DOUBLE; Number num0 = delegate.coerce(obj0); Number num1 = delegate.coerce(obj1); return delegate.divide(num0, num1); }
protected final Number coerce(final Object obj) { if (isNumber(obj)) { return coerce((Number) obj); } if (obj instanceof String) { return coerce((String) obj); } if (obj == null || "".equals(obj)) { return coerce(ZERO); } Class objType = obj.getClass(); if (Character.class.equals(objType) || Character.TYPE == objType) { return coerce(new Short((short) ((Character) obj).charValue())); } throw new IllegalArgumentException(MessageFactory.get("el.convert", obj, objType)); }
public final static Number mod(final Object obj0, final Object obj1) { if (obj0 == null && obj1 == null) { return new Long(0); } final ELArithmetic delegate; if (BIGDECIMAL.matches(obj0, obj1)) delegate = BIGDECIMAL; else if (DOUBLE.matches(obj0, obj1)) delegate = DOUBLE; else if (BIGINTEGER.matches(obj0, obj1)) delegate = BIGINTEGER; else delegate = LONG; Number num0 = delegate.coerce(obj0); Number num1 = delegate.coerce(obj1); return delegate.mod(num0, num1); }
public final static Number subtract(final Object obj0, final Object obj1) { if (obj0 == null && obj1 == null) { return new Long(0); } final ELArithmetic delegate; if (BIGDECIMAL.matches(obj0, obj1)) delegate = BIGDECIMAL; else if (DOUBLE.matches(obj0, obj1)) delegate = DOUBLE; else if (BIGINTEGER.matches(obj0, obj1)) delegate = BIGINTEGER; else delegate = LONG; Number num0 = delegate.coerce(obj0); Number num1 = delegate.coerce(obj1); return delegate.subtract(num0, num1); }
public final static Number multiply(final Object obj0, final Object obj1) { if (obj0 == null && obj1 == null) { return new Long(0); } final ELArithmetic delegate; if (BIGDECIMAL.matches(obj0, obj1)) delegate = BIGDECIMAL; else if (DOUBLE.matches(obj0, obj1)) delegate = DOUBLE; else if (BIGINTEGER.matches(obj0, obj1)) delegate = BIGINTEGER; else delegate = LONG; Number num0 = delegate.coerce(obj0); Number num1 = delegate.coerce(obj1); return delegate.multiply(num0, num1); }
public final static boolean isNumber(final Object obj) { return (obj != null && isNumberType(obj.getClass())); }
public final static Character coerceToCharacter(final Object obj) throws IllegalArgumentException { if (obj == null || "".equals(obj)) { return new Character((char) 0); } if (obj instanceof String) { return new Character(((String) obj).charAt(0)); } if (ELArithmetic.isNumber(obj)) { return new Character((char) ((Number) obj).shortValue()); } Class objType = obj.getClass(); if (obj instanceof Character || objType == Character.TYPE) { return (Character) obj; } throw new IllegalArgumentException(MessageFactory.get("error.convert", obj, objType, Character.class)); }
public Object getValue(EvaluationContext ctx) throws ELException { Object obj0 = this.children[0].getValue(ctx); Object obj1 = this.children[1].getValue(ctx); return ELArithmetic.divide(obj0, obj1); } }
public Object getValue(EvaluationContext ctx) throws ELException { Object obj0 = this.children[0].getValue(ctx); Object obj1 = this.children[1].getValue(ctx); return ELArithmetic.add(obj0, obj1); } }
public Object getValue(EvaluationContext ctx) throws ELException { Object obj0 = this.children[0].getValue(ctx); Object obj1 = this.children[1].getValue(ctx); return ELArithmetic.mod(obj0, obj1); } }
public Object getValue(EvaluationContext ctx) throws ELException { Object obj0 = this.children[0].getValue(ctx); Object obj1 = this.children[1].getValue(ctx); return ELArithmetic.multiply(obj0, obj1); } }
public Object getValue(EvaluationContext ctx) throws ELException { Object obj0 = this.children[0].getValue(ctx); Object obj1 = this.children[1].getValue(ctx); return ELArithmetic.subtract(obj0, obj1); } }
public final static Number mod(final Object obj0, final Object obj1) { if (obj0 == null && obj1 == null) { return new Long(0); } final ELArithmetic delegate; if (BIGDECIMAL.matches(obj0, obj1)) delegate = BIGDECIMAL; else if (DOUBLE.matches(obj0, obj1)) delegate = DOUBLE; else if (BIGINTEGER.matches(obj0, obj1)) delegate = BIGINTEGER; else delegate = LONG; Number num0 = delegate.coerce(obj0); Number num1 = delegate.coerce(obj1); return delegate.mod(num0, num1); }
public final static Number subtract(final Object obj0, final Object obj1) { if (obj0 == null && obj1 == null) { return new Long(0); } final ELArithmetic delegate; if (BIGDECIMAL.matches(obj0, obj1)) delegate = BIGDECIMAL; else if (DOUBLE.matches(obj0, obj1)) delegate = DOUBLE; else if (BIGINTEGER.matches(obj0, obj1)) delegate = BIGINTEGER; else delegate = LONG; Number num0 = delegate.coerce(obj0); Number num1 = delegate.coerce(obj1); return delegate.subtract(num0, num1); }
public final static Number multiply(final Object obj0, final Object obj1) { if (obj0 == null && obj1 == null) { return new Long(0); } final ELArithmetic delegate; if (BIGDECIMAL.matches(obj0, obj1)) delegate = BIGDECIMAL; else if (DOUBLE.matches(obj0, obj1)) delegate = DOUBLE; else if (BIGINTEGER.matches(obj0, obj1)) delegate = BIGINTEGER; else delegate = LONG; Number num0 = delegate.coerce(obj0); Number num1 = delegate.coerce(obj1); return delegate.multiply(num0, num1); }
public final static boolean isNumber(final Object obj) { return (obj != null && isNumberType(obj.getClass())); }
public final static Character coerceToCharacter(final Object obj) throws IllegalArgumentException { if (obj == null || "".equals(obj)) { return new Character((char) 0); } if (obj instanceof String) { return new Character(((String) obj).charAt(0)); } if (ELArithmetic.isNumber(obj)) { return new Character((char) ((Number) obj).shortValue()); } Class objType = obj.getClass(); if (obj instanceof Character || objType == Character.TYPE) { return (Character) obj; } throw new IllegalArgumentException(MessageFactory.get("error.convert", obj, objType, Character.class)); }
public Object getValue(EvaluationContext ctx) throws ELException { Object obj0 = this.children[0].getValue(ctx); Object obj1 = this.children[1].getValue(ctx); return ELArithmetic.divide(obj0, obj1); } }
public Object getValue(EvaluationContext ctx) throws ELException { Object obj0 = this.children[0].getValue(ctx); Object obj1 = this.children[1].getValue(ctx); return ELArithmetic.add(obj0, obj1); } }