throws ELException
{
return getFloatingPoint();
}
public Class<?> getType(EvaluationContext ctx)
throws ELException
{
return getFloatingPoint().getClass();
}
}
+ - * /实现,此处只看+的:
Java代码 package org.apache.el.parser;
import javax.el.ELException;
import org.apache.el.lang.ELArithmetic;
import org.apache.el.lang.EvaluationContext;
public final class AstPlus extends ArithmeticNode
{
public AstPlus(int id)
{
super(id);
}
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);
}
}
其委托给ELArithmetic.add:
Java代码 public static final DoubleDelegate DOUBLE = new DoubleDelegate();
public static final LongDelegate LONG = new LongDelegate();
private static final Long ZERO = Long.valueOf(0L);
public static final Number add(Object obj0, Object obj1) {
if ((obj0 == null) && (obj1 == null))
return Long.valueOf(0L);
ELArithmetic delegate;
if (BIGDECIMAL.matches(obj0, obj1))
delegate = BIGDECIMAL;
else if (DOUBLE.matches(obj0, obj1))
if (BIGINTEGER.matches(obj0, obj1))
delegate = BIGDECIMAL;
else
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);
}
此处委托给了各种delegate计算,其+的实现:
Java代码 public static final class LongDelegate extends ELArithmetic
{
protected Number add(Number num0, Number num1)
本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/jisuanjixue/article-31948-3.html
直接成为一艘在南海核心地区用不沉没的航母
请你永远做千纸鹤心里完美的小王子#1128迈全员加速中#