com.sun.el_2.2.0.v201108011116

16:34:32.723 INFO  jd.cli.Main - Decompiling com.sun.el_2.2.0.v201108011116.jar
package com.sun.el;

import com.sun.el.lang.ELSupport;
import com.sun.el.lang.ExpressionBuilder;
import com.sun.el.util.MessageFactory;
import javax.el.ELContext;
import javax.el.ELException;
import javax.el.ExpressionFactory;
import javax.el.MethodExpression;
import javax.el.ValueExpression;

public class ExpressionFactoryImpl
  extends ExpressionFactory
{
  public Object coerceToType(Object obj, Class type)
  {
    Object ret;
    try
    {
      ret = ELSupport.coerceToType(obj, type);
    }
    catch (IllegalArgumentException ex)
    {
      throw new ELException(ex);
    }
    return ret;
  }
  
  public MethodExpression createMethodExpression(ELContext context, String expression, Class expectedReturnType, Class[] expectedParamTypes)
  {
    ExpressionBuilder builder = new ExpressionBuilder(expression, context);
    MethodExpression me = builder.createMethodExpression(expectedReturnType, expectedParamTypes);
    if ((expectedParamTypes == null) && (!me.isParmetersProvided())) {
      throw new NullPointerException(MessageFactory.get("error.method.nullParms"));
    }
    return me;
  }
  
  public ValueExpression createValueExpression(ELContext context, String expression, Class expectedType)
  {
    if (expectedType == null) {
      throw new NullPointerException(MessageFactory.get("error.value.expectedType"));
    }
    ExpressionBuilder builder = new ExpressionBuilder(expression, context);
    return builder.createValueExpression(expectedType);
  }
  
  public ValueExpression createValueExpression(Object instance, Class expectedType)
  {
    if (expectedType == null) {
      throw new NullPointerException(MessageFactory.get("error.value.expectedType"));
    }
    return new ValueExpressionLiteral(instance, expectedType);
  }
}

/* Location:
 * Qualified Name:     com.sun.el.ExpressionFactoryImpl
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.sun.el;

import com.sun.el.lang.EvaluationContext;
import com.sun.el.lang.ExpressionBuilder;
import com.sun.el.parser.Node;
import com.sun.el.util.ReflectionUtil;
import java.io.Externalizable;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
import javax.el.ELContext;
import javax.el.ELException;
import javax.el.FunctionMapper;
import javax.el.MethodExpression;
import javax.el.MethodInfo;
import javax.el.MethodNotFoundException;
import javax.el.PropertyNotFoundException;
import javax.el.VariableMapper;

public final class MethodExpressionImpl
  extends MethodExpression
  implements Externalizable
{
  private Class expectedType;
  private String expr;
  private FunctionMapper fnMapper;
  private VariableMapper varMapper;
  private transient Node node;
  private Class[] paramTypes;
  
  public MethodExpressionImpl() {}
  
  public MethodExpressionImpl(String expr, Node node, FunctionMapper fnMapper, VariableMapper varMapper, Class expectedType, Class[] paramTypes)
  {
    this.expr = expr;
    this.node = node;
    this.fnMapper = fnMapper;
    this.varMapper = varMapper;
    this.expectedType = expectedType;
    this.paramTypes = paramTypes;
  }
  
  public boolean equals(Object obj)
  {
    if ((obj instanceof MethodExpressionImpl))
    {
      MethodExpressionImpl me = (MethodExpressionImpl)obj;
      return getNode().equals(me.getNode());
    }
    return false;
  }
  
  public String getExpressionString()
  {
    return expr;
  }
  
  public MethodInfo getMethodInfo(ELContext context)
    throws PropertyNotFoundException, MethodNotFoundException, ELException
  {
    Node n = getNode();
    EvaluationContext ctx = new EvaluationContext(context, fnMapper, varMapper);
    
    return n.getMethodInfo(ctx, paramTypes);
  }
  
  private Node getNode()
    throws ELException
  {
    if (node == null) {
      node = ExpressionBuilder.createNode(expr);
    }
    return node;
  }
  
  public int hashCode()
  {
    return getNode().hashCode();
  }
  
  public Object invoke(ELContext context, Object[] params)
    throws PropertyNotFoundException, MethodNotFoundException, ELException
  {
    EvaluationContext ctx = new EvaluationContext(context, fnMapper, varMapper);
    
    return getNode().invoke(ctx, paramTypes, params);
  }
  
  public void readExternal(ObjectInput in)
    throws IOException, ClassNotFoundException
  {
    expr = in.readUTF();
    String type = in.readUTF();
    if (!"".equals(type)) {
      expectedType = ReflectionUtil.forName(type);
    }
    paramTypes = ReflectionUtil.toTypeArray((String[])in.readObject());
    
    fnMapper = ((FunctionMapper)in.readObject());
    varMapper = ((VariableMapper)in.readObject());
  }
  
  public void writeExternal(ObjectOutput out)
    throws IOException
  {
    out.writeUTF(expr);
    out.writeUTF(expectedType != null ? expectedType.getName() : "");
    
    out.writeObject(ReflectionUtil.toTypeNameArray(paramTypes));
    out.writeObject(fnMapper);
    out.writeObject(varMapper);
  }
  
  public boolean isLiteralText()
  {
    return false;
  }
  
  public boolean isParmetersProvided()
  {
    return getNode().isParametersProvided();
  }
}

/* Location:
 * Qualified Name:     com.sun.el.MethodExpressionImpl
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.sun.el;

import com.sun.el.lang.ELSupport;
import com.sun.el.util.ReflectionUtil;
import java.io.Externalizable;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
import javax.el.ELContext;
import javax.el.ELException;
import javax.el.MethodExpression;
import javax.el.MethodInfo;

public class MethodExpressionLiteral
  extends MethodExpression
  implements Externalizable
{
  private Class expectedType;
  private String expr;
  private Class[] paramTypes;
  
  public MethodExpressionLiteral() {}
  
  public MethodExpressionLiteral(String expr, Class expectedType, Class[] paramTypes)
  {
    this.expr = expr;
    this.expectedType = expectedType;
    this.paramTypes = paramTypes;
  }
  
  public MethodInfo getMethodInfo(ELContext context)
    throws ELException
  {
    return new MethodInfo(expr, expectedType, paramTypes);
  }
  
  public Object invoke(ELContext context, Object[] params)
    throws ELException
  {
    if (expectedType == null) {
      return expr;
    }
    try
    {
      return ELSupport.coerceToType(expr, expectedType);
    }
    catch (Exception ex)
    {
      throw new ELException(ex);
    }
  }
  
  public String getExpressionString()
  {
    return expr;
  }
  
  public boolean equals(Object obj)
  {
    return ((obj instanceof MethodExpressionLiteral)) && (hashCode() == obj.hashCode());
  }
  
  public int hashCode()
  {
    return expr.hashCode();
  }
  
  public boolean isLiteralText()
  {
    return true;
  }
  
  public void readExternal(ObjectInput in)
    throws IOException, ClassNotFoundException
  {
    expr = in.readUTF();
    String type = in.readUTF();
    if (!"".equals(type)) {
      expectedType = ReflectionUtil.forName(type);
    }
    paramTypes = ReflectionUtil.toTypeArray((String[])in.readObject());
  }
  
  public void writeExternal(ObjectOutput out)
    throws IOException
  {
    out.writeUTF(expr);
    out.writeUTF(expectedType != null ? expectedType.getName() : "");
    
    out.writeObject(ReflectionUtil.toTypeNameArray(paramTypes));
  }
}

/* Location:
 * Qualified Name:     com.sun.el.MethodExpressionLiteral
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.sun.el;

import com.sun.el.lang.ELSupport;
import com.sun.el.lang.EvaluationContext;
import com.sun.el.lang.ExpressionBuilder;
import com.sun.el.parser.AstLiteralExpression;
import com.sun.el.parser.Node;
import com.sun.el.util.ReflectionUtil;
import java.io.Externalizable;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
import javax.el.ELContext;
import javax.el.ELException;
import javax.el.FunctionMapper;
import javax.el.PropertyNotFoundException;
import javax.el.PropertyNotWritableException;
import javax.el.ValueExpression;
import javax.el.ValueReference;
import javax.el.VariableMapper;

public final class ValueExpressionImpl
  extends ValueExpression
  implements Externalizable
{
  private Class expectedType;
  private String expr;
  private FunctionMapper fnMapper;
  private VariableMapper varMapper;
  private transient Node node;
  
  public ValueExpressionImpl() {}
  
  public ValueExpressionImpl(String expr, Node node, FunctionMapper fnMapper, VariableMapper varMapper, Class expectedType)
  {
    this.expr = expr;
    this.node = node;
    this.fnMapper = fnMapper;
    this.varMapper = varMapper;
    this.expectedType = expectedType;
  }
  
  public boolean equals(Object obj)
  {
    if ((obj instanceof ValueExpressionImpl))
    {
      ValueExpressionImpl v = (ValueExpressionImpl)obj;
      return getNode().equals(v.getNode());
    }
    return false;
  }
  
  public Class getExpectedType()
  {
    return expectedType;
  }
  
  public String getExpressionString()
  {
    return expr;
  }
  
  private Node getNode()
    throws ELException
  {
    if (node == null) {
      node = ExpressionBuilder.createNode(expr);
    }
    return node;
  }
  
  public Class getType(ELContext context)
    throws PropertyNotFoundException, ELException
  {
    EvaluationContext ctx = new EvaluationContext(context, fnMapper, varMapper);
    
    return getNode().getType(ctx);
  }
  
  public ValueReference getValueReference(ELContext context)
    throws PropertyNotFoundException, ELException
  {
    EvaluationContext ctx = new EvaluationContext(context, fnMapper, varMapper);
    
    return getNode().getValueReference(ctx);
  }
  
  public Object getValue(ELContext context)
    throws PropertyNotFoundException, ELException
  {
    EvaluationContext ctx = new EvaluationContext(context, fnMapper, varMapper);
    
    Object value = getNode().getValue(ctx);
    if (expectedType != null) {
      try
      {
        value = ELSupport.coerceToType(value, expectedType);
      }
      catch (IllegalArgumentException ex)
      {
        throw new ELException(ex);
      }
    }
    return value;
  }
  
  public int hashCode()
  {
    return getNode().hashCode();
  }
  
  public boolean isLiteralText()
  {
    try
    {
      return getNode() instanceof AstLiteralExpression;
    }
    catch (ELException ele) {}
    return false;
  }
  
  public boolean isReadOnly(ELContext context)
    throws PropertyNotFoundException, ELException
  {
    EvaluationContext ctx = new EvaluationContext(context, fnMapper, varMapper);
    
    return getNode().isReadOnly(ctx);
  }
  
  public void readExternal(ObjectInput in)
    throws IOException, ClassNotFoundException
  {
    expr = in.readUTF();
    String type = in.readUTF();
    if (!"".equals(type)) {
      expectedType = ReflectionUtil.forName(type);
    }
    fnMapper = ((FunctionMapper)in.readObject());
    varMapper = ((VariableMapper)in.readObject());
  }
  
  public void setValue(ELContext context, Object value)
    throws PropertyNotFoundException, PropertyNotWritableException, ELException
  {
    EvaluationContext ctx = new EvaluationContext(context, fnMapper, varMapper);
    
    getNode().setValue(ctx, value);
  }
  
  public void writeExternal(ObjectOutput out)
    throws IOException
  {
    out.writeUTF(expr);
    out.writeUTF(expectedType != null ? expectedType.getName() : "");
    
    out.writeObject(fnMapper);
    out.writeObject(varMapper);
  }
  
  public String toString()
  {
    return "ValueExpression[" + expr + "]";
  }
}

/* Location:
 * Qualified Name:     com.sun.el.ValueExpressionImpl
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.sun.el;

import com.sun.el.lang.ELSupport;
import com.sun.el.util.MessageFactory;
import com.sun.el.util.ReflectionUtil;
import java.io.Externalizable;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
import javax.el.ELContext;
import javax.el.ELException;
import javax.el.PropertyNotWritableException;
import javax.el.ValueExpression;

public final class ValueExpressionLiteral
  extends ValueExpression
  implements Externalizable
{
  private static final long serialVersionUID = 1L;
  private Object value;
  private Class expectedType;
  
  public ValueExpressionLiteral() {}
  
  public ValueExpressionLiteral(Object value, Class expectedType)
  {
    this.value = value;
    this.expectedType = expectedType;
  }
  
  public Object getValue(ELContext context)
  {
    if (expectedType != null) {
      try
      {
        return ELSupport.coerceToType(value, expectedType);
      }
      catch (IllegalArgumentException ex)
      {
        throw new ELException(ex);
      }
    }
    return value;
  }
  
  public void setValue(ELContext context, Object value)
  {
    throw new PropertyNotWritableException(MessageFactory.get("error.value.literal.write", this.value));
  }
  
  public boolean isReadOnly(ELContext context)
  {
    return true;
  }
  
  public Class getType(ELContext context)
  {
    return value != null ? value.getClass() : null;
  }
  
  public Class getExpectedType()
  {
    return expectedType;
  }
  
  public String getExpressionString()
  {
    return value != null ? value.toString() : null;
  }
  
  public boolean equals(Object obj)
  {
    return ((obj instanceof ValueExpressionLiteral)) && (equals((ValueExpressionLiteral)obj));
  }
  
  public boolean equals(ValueExpressionLiteral ve)
  {
    return (ve != null) && (value != null) && (value != null) && ((value == value) || (value.equals(value)));
  }
  
  public int hashCode()
  {
    return value != null ? value.hashCode() : 0;
  }
  
  public boolean isLiteralText()
  {
    return true;
  }
  
  public void writeExternal(ObjectOutput out)
    throws IOException
  {
    out.writeObject(value);
    out.writeUTF(expectedType != null ? expectedType.getName() : "");
  }
  
  public void readExternal(ObjectInput in)
    throws IOException, ClassNotFoundException
  {
    value = in.readObject();
    String type = in.readUTF();
    if (!"".equals(type)) {
      expectedType = ReflectionUtil.forName(type);
    }
  }
}

/* Location:
 * Qualified Name:     com.sun.el.ValueExpressionLiteral
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.sun.el.lang;

import java.math.BigDecimal;
import java.math.BigInteger;

public final class ELArithmetic$BigDecimalDelegate
  extends ELArithmetic
{
  protected Number add(Number num0, Number num1)
  {
    return ((BigDecimal)num0).add((BigDecimal)num1);
  }
  
  protected Number coerce(Number num)
  {
    if ((num instanceof BigDecimal)) {
      return num;
    }
    if ((num instanceof BigInteger)) {
      return new BigDecimal((BigInteger)num);
    }
    return new BigDecimal(num.doubleValue());
  }
  
  protected Number coerce(String str)
  {
    return new BigDecimal(str);
  }
  
  protected Number divide(Number num0, Number num1)
  {
    return ((BigDecimal)num0).divide((BigDecimal)num1, 4);
  }
  
  protected Number subtract(Number num0, Number num1)
  {
    return ((BigDecimal)num0).subtract((BigDecimal)num1);
  }
  
  protected Number mod(Number num0, Number num1)
  {
    return Double.valueOf(num0.doubleValue() % num1.doubleValue());
  }
  
  protected Number multiply(Number num0, Number num1)
  {
    return ((BigDecimal)num0).multiply((BigDecimal)num1);
  }
  
  public boolean matches(Object obj0, Object obj1)
  {
    return ((obj0 instanceof BigDecimal)) || ((obj1 instanceof BigDecimal));
  }
}

/* Location:
 * Qualified Name:     com.sun.el.lang.ELArithmetic.BigDecimalDelegate
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.sun.el.lang;

import java.math.BigDecimal;
import java.math.BigInteger;

public final class ELArithmetic$BigIntegerDelegate
  extends ELArithmetic
{
  protected Number add(Number num0, Number num1)
  {
    return ((BigInteger)num0).add((BigInteger)num1);
  }
  
  protected Number coerce(Number num)
  {
    if ((num instanceof BigInteger)) {
      return num;
    }
    return new BigInteger(num.toString());
  }
  
  protected Number coerce(String str)
  {
    return new BigInteger(str);
  }
  
  protected Number divide(Number num0, Number num1)
  {
    return new BigDecimal((BigInteger)num0).divide(new BigDecimal((BigInteger)num1), 4);
  }
  
  protected Number multiply(Number num0, Number num1)
  {
    return ((BigInteger)num0).multiply((BigInteger)num1);
  }
  
  protected Number mod(Number num0, Number num1)
  {
    return ((BigInteger)num0).mod((BigInteger)num1);
  }
  
  protected Number subtract(Number num0, Number num1)
  {
    return ((BigInteger)num0).subtract((BigInteger)num1);
  }
  
  public boolean matches(Object obj0, Object obj1)
  {
    return ((obj0 instanceof BigInteger)) || ((obj1 instanceof BigInteger));
  }
}

/* Location:
 * Qualified Name:     com.sun.el.lang.ELArithmetic.BigIntegerDelegate
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.sun.el.lang;

import java.math.BigDecimal;
import java.math.BigInteger;

public final class ELArithmetic$DoubleDelegate
  extends ELArithmetic
{
  protected Number add(Number num0, Number num1)
  {
    if ((num0 instanceof BigDecimal)) {
      return ((BigDecimal)num0).add(new BigDecimal(num1.doubleValue()));
    }
    if ((num1 instanceof BigDecimal)) {
      return new BigDecimal(num0.doubleValue()).add((BigDecimal)num1);
    }
    return Double.valueOf(num0.doubleValue() + num1.doubleValue());
  }
  
  protected Number coerce(Number num)
  {
    if ((num instanceof Double)) {
      return num;
    }
    if ((num instanceof BigInteger)) {
      return new BigDecimal((BigInteger)num);
    }
    return Double.valueOf(num.doubleValue());
  }
  
  protected Number coerce(String str)
  {
    return Double.valueOf(str);
  }
  
  protected Number divide(Number num0, Number num1)
  {
    return Double.valueOf(num0.doubleValue() / num1.doubleValue());
  }
  
  protected Number mod(Number num0, Number num1)
  {
    return Double.valueOf(num0.doubleValue() % num1.doubleValue());
  }
  
  protected Number subtract(Number num0, Number num1)
  {
    if ((num0 instanceof BigDecimal)) {
      return ((BigDecimal)num0).subtract(new BigDecimal(num1.doubleValue()));
    }
    if ((num1 instanceof BigDecimal)) {
      return new BigDecimal(num0.doubleValue()).subtract((BigDecimal)num1);
    }
    return Double.valueOf(num0.doubleValue() - num1.doubleValue());
  }
  
  protected Number multiply(Number num0, Number num1)
  {
    if ((num0 instanceof BigDecimal)) {
      return ((BigDecimal)num0).multiply(new BigDecimal(num1.doubleValue()));
    }
    if ((num1 instanceof BigDecimal)) {
      return new BigDecimal(num0.doubleValue()).multiply((BigDecimal)num1);
    }
    return Double.valueOf(num0.doubleValue() * num1.doubleValue());
  }
  
  public boolean matches(Object obj0, Object obj1)
  {
    return ((obj0 instanceof Double)) || ((obj1 instanceof Double)) || ((obj0 instanceof Float)) || ((obj1 instanceof Float)) || ((obj0 != null) && ((Double.TYPE == obj0.getClass()) || (Float.TYPE == obj0.getClass()))) || ((obj1 != null) && ((Double.TYPE == obj1.getClass()) || (Float.TYPE == obj1.getClass()))) || (((obj0 instanceof String)) && (ELSupport.isStringFloat((String)obj0))) || (((obj1 instanceof String)) && (ELSupport.isStringFloat((String)obj1)));
  }
}

/* Location:
 * Qualified Name:     com.sun.el.lang.ELArithmetic.DoubleDelegate
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.sun.el.lang;

public final class ELArithmetic$LongDelegate
  extends ELArithmetic
{
  protected Number add(Number num0, Number num1)
  {
    return Long.valueOf(num0.longValue() + num1.longValue());
  }
  
  protected Number coerce(Number num)
  {
    if ((num instanceof Long)) {
      return num;
    }
    return Long.valueOf(num.longValue());
  }
  
  protected Number coerce(String str)
  {
    return Long.valueOf(str);
  }
  
  protected Number divide(Number num0, Number num1)
  {
    return Long.valueOf(num0.longValue() / num1.longValue());
  }
  
  protected Number mod(Number num0, Number num1)
  {
    return Long.valueOf(num0.longValue() % num1.longValue());
  }
  
  protected Number subtract(Number num0, Number num1)
  {
    return Long.valueOf(num0.longValue() - num1.longValue());
  }
  
  protected Number multiply(Number num0, Number num1)
  {
    return Long.valueOf(num0.longValue() * num1.longValue());
  }
  
  public boolean matches(Object obj0, Object obj1)
  {
    return ((obj0 instanceof Long)) || ((obj1 instanceof Long));
  }
}

/* Location:
 * Qualified Name:     com.sun.el.lang.ELArithmetic.LongDelegate
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.sun.el.lang;

import com.sun.el.util.MessageFactory;
import java.math.BigDecimal;
import java.math.BigInteger;

public abstract class ELArithmetic
{
  public static final class BigDecimalDelegate
    extends ELArithmetic
  {
    protected Number add(Number num0, Number num1)
    {
      return ((BigDecimal)num0).add((BigDecimal)num1);
    }
    
    protected Number coerce(Number num)
    {
      if ((num instanceof BigDecimal)) {
        return num;
      }
      if ((num instanceof BigInteger)) {
        return new BigDecimal((BigInteger)num);
      }
      return new BigDecimal(num.doubleValue());
    }
    
    protected Number coerce(String str)
    {
      return new BigDecimal(str);
    }
    
    protected Number divide(Number num0, Number num1)
    {
      return ((BigDecimal)num0).divide((BigDecimal)num1, 4);
    }
    
    protected Number subtract(Number num0, Number num1)
    {
      return ((BigDecimal)num0).subtract((BigDecimal)num1);
    }
    
    protected Number mod(Number num0, Number num1)
    {
      return Double.valueOf(num0.doubleValue() % num1.doubleValue());
    }
    
    protected Number multiply(Number num0, Number num1)
    {
      return ((BigDecimal)num0).multiply((BigDecimal)num1);
    }
    
    public boolean matches(Object obj0, Object obj1)
    {
      return ((obj0 instanceof BigDecimal)) || ((obj1 instanceof BigDecimal));
    }
  }
  
  public static final class BigIntegerDelegate
    extends ELArithmetic
  {
    protected Number add(Number num0, Number num1)
    {
      return ((BigInteger)num0).add((BigInteger)num1);
    }
    
    protected Number coerce(Number num)
    {
      if ((num instanceof BigInteger)) {
        return num;
      }
      return new BigInteger(num.toString());
    }
    
    protected Number coerce(String str)
    {
      return new BigInteger(str);
    }
    
    protected Number divide(Number num0, Number num1)
    {
      return new BigDecimal((BigInteger)num0).divide(new BigDecimal((BigInteger)num1), 4);
    }
    
    protected Number multiply(Number num0, Number num1)
    {
      return ((BigInteger)num0).multiply((BigInteger)num1);
    }
    
    protected Number mod(Number num0, Number num1)
    {
      return ((BigInteger)num0).mod((BigInteger)num1);
    }
    
    protected Number subtract(Number num0, Number num1)
    {
      return ((BigInteger)num0).subtract((BigInteger)num1);
    }
    
    public boolean matches(Object obj0, Object obj1)
    {
      return ((obj0 instanceof BigInteger)) || ((obj1 instanceof BigInteger));
    }
  }
  
  public static final class DoubleDelegate
    extends ELArithmetic
  {
    protected Number add(Number num0, Number num1)
    {
      if ((num0 instanceof BigDecimal)) {
        return ((BigDecimal)num0).add(new BigDecimal(num1.doubleValue()));
      }
      if ((num1 instanceof BigDecimal)) {
        return new BigDecimal(num0.doubleValue()).add((BigDecimal)num1);
      }
      return Double.valueOf(num0.doubleValue() + num1.doubleValue());
    }
    
    protected Number coerce(Number num)
    {
      if ((num instanceof Double)) {
        return num;
      }
      if ((num instanceof BigInteger)) {
        return new BigDecimal((BigInteger)num);
      }
      return Double.valueOf(num.doubleValue());
    }
    
    protected Number coerce(String str)
    {
      return Double.valueOf(str);
    }
    
    protected Number divide(Number num0, Number num1)
    {
      return Double.valueOf(num0.doubleValue() / num1.doubleValue());
    }
    
    protected Number mod(Number num0, Number num1)
    {
      return Double.valueOf(num0.doubleValue() % num1.doubleValue());
    }
    
    protected Number subtract(Number num0, Number num1)
    {
      if ((num0 instanceof BigDecimal)) {
        return ((BigDecimal)num0).subtract(new BigDecimal(num1.doubleValue()));
      }
      if ((num1 instanceof BigDecimal)) {
        return new BigDecimal(num0.doubleValue()).subtract((BigDecimal)num1);
      }
      return Double.valueOf(num0.doubleValue() - num1.doubleValue());
    }
    
    protected Number multiply(Number num0, Number num1)
    {
      if ((num0 instanceof BigDecimal)) {
        return ((BigDecimal)num0).multiply(new BigDecimal(num1.doubleValue()));
      }
      if ((num1 instanceof BigDecimal)) {
        return new BigDecimal(num0.doubleValue()).multiply((BigDecimal)num1);
      }
      return Double.valueOf(num0.doubleValue() * num1.doubleValue());
    }
    
    public boolean matches(Object obj0, Object obj1)
    {
      return ((obj0 instanceof Double)) || ((obj1 instanceof Double)) || ((obj0 instanceof Float)) || ((obj1 instanceof Float)) || ((obj0 != null) && ((Double.TYPE == obj0.getClass()) || (Float.TYPE == obj0.getClass()))) || ((obj1 != null) && ((Double.TYPE == obj1.getClass()) || (Float.TYPE == obj1.getClass()))) || (((obj0 instanceof String)) && (ELSupport.isStringFloat((String)obj0))) || (((obj1 instanceof String)) && (ELSupport.isStringFloat((String)obj1)));
    }
  }
  
  public static final class LongDelegate
    extends ELArithmetic
  {
    protected Number add(Number num0, Number num1)
    {
      return Long.valueOf(num0.longValue() + num1.longValue());
    }
    
    protected Number coerce(Number num)
    {
      if ((num instanceof Long)) {
        return num;
      }
      return Long.valueOf(num.longValue());
    }
    
    protected Number coerce(String str)
    {
      return Long.valueOf(str);
    }
    
    protected Number divide(Number num0, Number num1)
    {
      return Long.valueOf(num0.longValue() / num1.longValue());
    }
    
    protected Number mod(Number num0, Number num1)
    {
      return Long.valueOf(num0.longValue() % num1.longValue());
    }
    
    protected Number subtract(Number num0, Number num1)
    {
      return Long.valueOf(num0.longValue() - num1.longValue());
    }
    
    protected Number multiply(Number num0, Number num1)
    {
      return Long.valueOf(num0.longValue() * num1.longValue());
    }
    
    public boolean matches(Object obj0, Object obj1)
    {
      return ((obj0 instanceof Long)) || ((obj1 instanceof Long));
    }
  }
  
  public static final BigDecimalDelegate BIGDECIMAL = new BigDecimalDelegate();
  public static final BigIntegerDelegate BIGINTEGER = new BigIntegerDelegate();
  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;
    ELArithmetic delegate;
    if (BIGDECIMAL.matches(obj0, obj1))
    {
      delegate = BIGDECIMAL;
    }
    else
    {
      ELArithmetic delegate;
      if (DOUBLE.matches(obj0, obj1))
      {
        delegate = DOUBLE;
      }
      else
      {
        ELArithmetic delegate;
        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 static final Number mod(Object obj0, Object obj1)
  {
    if ((obj0 == null) && (obj1 == null)) {
      return Long.valueOf(0L);
    }
    ELArithmetic delegate;
    ELArithmetic delegate;
    if (BIGDECIMAL.matches(obj0, obj1))
    {
      delegate = BIGDECIMAL;
    }
    else
    {
      ELArithmetic delegate;
      if (DOUBLE.matches(obj0, obj1))
      {
        delegate = DOUBLE;
      }
      else
      {
        ELArithmetic delegate;
        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 static final Number subtract(Object obj0, Object obj1)
  {
    if ((obj0 == null) && (obj1 == null)) {
      return Long.valueOf(0L);
    }
    ELArithmetic delegate;
    ELArithmetic delegate;
    if (BIGDECIMAL.matches(obj0, obj1))
    {
      delegate = BIGDECIMAL;
    }
    else
    {
      ELArithmetic delegate;
      if (DOUBLE.matches(obj0, obj1))
      {
        delegate = DOUBLE;
      }
      else
      {
        ELArithmetic delegate;
        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 static final Number divide(Object obj0, Object obj1)
  {
    if ((obj0 == null) && (obj1 == null)) {
      return ZERO;
    }
    ELArithmetic delegate;
    ELArithmetic delegate;
    if (BIGDECIMAL.matches(obj0, obj1))
    {
      delegate = BIGDECIMAL;
    }
    else
    {
      ELArithmetic delegate;
      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);
  }
  
  public static final Number multiply(Object obj0, Object obj1)
  {
    if ((obj0 == null) && (obj1 == null)) {
      return Long.valueOf(0L);
    }
    ELArithmetic delegate;
    ELArithmetic delegate;
    if (BIGDECIMAL.matches(obj0, obj1))
    {
      delegate = BIGDECIMAL;
    }
    else
    {
      ELArithmetic delegate;
      if (DOUBLE.matches(obj0, obj1))
      {
        delegate = DOUBLE;
      }
      else
      {
        ELArithmetic delegate;
        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 static final boolean isNumber(Object obj)
  {
    return (obj != null) && (isNumberType(obj.getClass()));
  }
  
  public static final boolean isNumberType(Class type)
  {
    return (type == Long.class) || (type == Long.TYPE) || (type == Double.class) || (type == Double.TYPE) || (type == Byte.class) || (type == Byte.TYPE) || (type == Short.class) || (type == Short.TYPE) || (type == Integer.class) || (type == Integer.TYPE) || (type == Float.class) || (type == Float.TYPE) || (type == BigInteger.class) || (type == BigDecimal.class);
  }
  
  protected abstract Number add(Number paramNumber1, Number paramNumber2);
  
  protected abstract Number multiply(Number paramNumber1, Number paramNumber2);
  
  protected abstract Number subtract(Number paramNumber1, Number paramNumber2);
  
  protected abstract Number mod(Number paramNumber1, Number paramNumber2);
  
  protected abstract Number coerce(Number paramNumber);
  
  protected final Number coerce(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(Short.valueOf((short)((Character)obj).charValue()));
    }
    throw new IllegalArgumentException(MessageFactory.get("el.convert", obj, objType));
  }
  
  protected abstract Number coerce(String paramString);
  
  protected abstract Number divide(Number paramNumber1, Number paramNumber2);
  
  protected abstract boolean matches(Object paramObject1, Object paramObject2);
}

/* Location:
 * Qualified Name:     com.sun.el.lang.ELArithmetic
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.sun.el.lang;

import com.sun.el.util.MessageFactory;
import java.beans.PropertyEditor;
import java.beans.PropertyEditorManager;
import java.math.BigDecimal;
import java.math.BigInteger;
import javax.el.ELException;
import javax.el.PropertyNotFoundException;

public class ELSupport
{
  private static final Long ZERO = Long.valueOf(0L);
  
  public static final void throwUnhandled(Object base, Object property)
    throws ELException
  {
    if (base == null) {
      throw new PropertyNotFoundException(MessageFactory.get("error.resolver.unhandled.null", property));
    }
    throw new PropertyNotFoundException(MessageFactory.get("error.resolver.unhandled", base.getClass(), property));
  }
  
  public static final int compare(Object obj0, Object obj1)
    throws ELException
  {
    if ((obj0 == obj1) || (equals(obj0, obj1))) {
      return 0;
    }
    if (isBigDecimalOp(obj0, obj1))
    {
      BigDecimal bd0 = (BigDecimal)coerceToNumber(obj0, BigDecimal.class);
      BigDecimal bd1 = (BigDecimal)coerceToNumber(obj1, BigDecimal.class);
      return bd0.compareTo(bd1);
    }
    if (isDoubleOp(obj0, obj1))
    {
      Double d0 = (Double)coerceToNumber(obj0, Double.class);
      Double d1 = (Double)coerceToNumber(obj1, Double.class);
      return d0.compareTo(d1);
    }
    if (isBigIntegerOp(obj0, obj1))
    {
      BigInteger bi0 = (BigInteger)coerceToNumber(obj0, BigInteger.class);
      BigInteger bi1 = (BigInteger)coerceToNumber(obj1, BigInteger.class);
      return bi0.compareTo(bi1);
    }
    if (isLongOp(obj0, obj1))
    {
      Long l0 = (Long)coerceToNumber(obj0, Long.class);
      Long l1 = (Long)coerceToNumber(obj1, Long.class);
      return l0.compareTo(l1);
    }
    if (((obj0 instanceof String)) || ((obj1 instanceof String))) {
      return coerceToString(obj0).compareTo(coerceToString(obj1));
    }
    if ((obj0 instanceof Comparable)) {
      return obj1 != null ? ((Comparable)obj0).compareTo(obj1) : 1;
    }
    if ((obj1 instanceof Comparable)) {
      return obj0 != null ? -((Comparable)obj1).compareTo(obj0) : -1;
    }
    throw new ELException(MessageFactory.get("error.compare", obj0, obj1));
  }
  
  public static final boolean equals(Object obj0, Object obj1)
    throws ELException
  {
    if (obj0 == obj1) {
      return true;
    }
    if ((obj0 == null) || (obj1 == null)) {
      return false;
    }
    if (((obj0 instanceof Boolean)) || ((obj1 instanceof Boolean))) {
      return coerceToBoolean(obj0).equals(coerceToBoolean(obj1));
    }
    if (obj0.getClass().isEnum()) {
      return obj0.equals(coerceToEnum(obj1, obj0.getClass()));
    }
    if (obj1.getClass().isEnum()) {
      return obj1.equals(coerceToEnum(obj0, obj1.getClass()));
    }
    if (((obj0 instanceof String)) || ((obj1 instanceof String))) {
      return coerceToString(obj0).equals(coerceToString(obj1));
    }
    if (isBigDecimalOp(obj0, obj1))
    {
      BigDecimal bd0 = (BigDecimal)coerceToNumber(obj0, BigDecimal.class);
      BigDecimal bd1 = (BigDecimal)coerceToNumber(obj1, BigDecimal.class);
      return bd0.equals(bd1);
    }
    if (isDoubleOp(obj0, obj1))
    {
      Double d0 = (Double)coerceToNumber(obj0, Double.class);
      Double d1 = (Double)coerceToNumber(obj1, Double.class);
      return d0.equals(d1);
    }
    if (isBigIntegerOp(obj0, obj1))
    {
      BigInteger bi0 = (BigInteger)coerceToNumber(obj0, BigInteger.class);
      BigInteger bi1 = (BigInteger)coerceToNumber(obj1, BigInteger.class);
      return bi0.equals(bi1);
    }
    if (isLongOp(obj0, obj1))
    {
      Long l0 = (Long)coerceToNumber(obj0, Long.class);
      Long l1 = (Long)coerceToNumber(obj1, Long.class);
      return l0.equals(l1);
    }
    return obj0.equals(obj1);
  }
  
  public static final Boolean coerceToBoolean(Object obj)
    throws IllegalArgumentException
  {
    if ((obj == null) || ("".equals(obj))) {
      return Boolean.FALSE;
    }
    if ((obj instanceof Boolean)) {
      return (Boolean)obj;
    }
    if ((obj instanceof String)) {
      return Boolean.valueOf((String)obj);
    }
    throw new IllegalArgumentException(MessageFactory.get("error.convert", obj, obj.getClass(), Boolean.class));
  }
  
  public static final Enum coerceToEnum(Object obj, Class type)
  {
    if ((obj == null) || ("".equals(obj))) {
      return null;
    }
    if (obj.getClass().isEnum()) {
      return (Enum)obj;
    }
    return Enum.valueOf(type, obj.toString());
  }
  
  public static final Character coerceToCharacter(Object obj)
    throws IllegalArgumentException
  {
    if ((obj == null) || ("".equals(obj))) {
      return Character.valueOf('\000');
    }
    if ((obj instanceof String)) {
      return Character.valueOf(((String)obj).charAt(0));
    }
    if (ELArithmetic.isNumber(obj)) {
      return Character.valueOf((char)((Number)obj).shortValue());
    }
    Class objType = obj.getClass();
    if ((obj instanceof Character)) {
      return (Character)obj;
    }
    throw new IllegalArgumentException(MessageFactory.get("error.convert", obj, objType, Character.class));
  }
  
  public static final Number coerceToNumber(Object obj)
  {
    if (obj == null) {
      return ZERO;
    }
    if ((obj instanceof Number)) {
      return (Number)obj;
    }
    String str = coerceToString(obj);
    if (isStringFloat(str)) {
      return toFloat(str);
    }
    return toNumber(str);
  }
  
  protected static final Number coerceToNumber(Number number, Class type)
    throws IllegalArgumentException
  {
    if ((Long.TYPE == type) || (Long.class.equals(type))) {
      return Long.valueOf(number.longValue());
    }
    if ((Double.TYPE == type) || (Double.class.equals(type))) {
      return Double.valueOf(number.doubleValue());
    }
    if ((Integer.TYPE == type) || (Integer.class.equals(type))) {
      return Integer.valueOf(number.intValue());
    }
    if (BigInteger.class.equals(type))
    {
      if ((number instanceof BigDecimal)) {
        return ((BigDecimal)number).toBigInteger();
      }
      if ((number instanceof BigInteger)) {
        return number;
      }
      return BigInteger.valueOf(number.longValue());
    }
    if (BigDecimal.class.equals(type))
    {
      if ((number instanceof BigDecimal)) {
        return number;
      }
      if ((number instanceof BigInteger)) {
        return new BigDecimal((BigInteger)number);
      }
      if ((number instanceof Long)) {
        return new BigDecimal(((Long)number).longValue());
      }
      return new BigDecimal(number.doubleValue());
    }
    if ((Byte.TYPE == type) || (Byte.class.equals(type))) {
      return Byte.valueOf(number.byteValue());
    }
    if ((Short.TYPE == type) || (Short.class.equals(type))) {
      return Short.valueOf(number.shortValue());
    }
    if ((Float.TYPE == type) || (Float.class.equals(type))) {
      return Float.valueOf(number.floatValue());
    }
    throw new IllegalArgumentException(MessageFactory.get("error.convert", number, number.getClass(), type));
  }
  
  public static final Number coerceToNumber(Object obj, Class type)
    throws IllegalArgumentException
  {
    if ((obj == null) || ("".equals(obj))) {
      return coerceToNumber(ZERO, type);
    }
    if ((obj instanceof String)) {
      return coerceToNumber((String)obj, type);
    }
    if (ELArithmetic.isNumber(obj))
    {
      if (obj.getClass().equals(type)) {
        
1 2 3 4 5 6

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2017. Infinite Loop Ltd