home *** CD-ROM | disk | FTP | other *** search
/ Sky at Night 2007 June / SAN CD 6-2007 CD-ROM 25.iso / pc / Software / AstroGrav_Win / Java / jre1.6.0 / lib / rt.jar / javax / management / BinaryOpValueExp.class (.txt) < prev    next >
Encoding:
Java Class File  |  2006-11-29  |  2.1 KB  |  100 lines

  1. package javax.management;
  2.  
  3. class BinaryOpValueExp extends QueryEval implements ValueExp {
  4.    private static final long serialVersionUID = 1216286847881456786L;
  5.    // $FF: renamed from: op int
  6.    private int field_0;
  7.    private ValueExp exp1;
  8.    private ValueExp exp2;
  9.  
  10.    public BinaryOpValueExp() {
  11.    }
  12.  
  13.    public BinaryOpValueExp(int var1, ValueExp var2, ValueExp var3) {
  14.       this.field_0 = var1;
  15.       this.exp1 = var2;
  16.       this.exp2 = var3;
  17.    }
  18.  
  19.    public int getOperator() {
  20.       return this.field_0;
  21.    }
  22.  
  23.    public ValueExp getLeftValue() {
  24.       return this.exp1;
  25.    }
  26.  
  27.    public ValueExp getRightValue() {
  28.       return this.exp2;
  29.    }
  30.  
  31.    public ValueExp apply(ObjectName var1) throws BadStringOperationException, BadBinaryOpValueExpException, BadAttributeValueExpException, InvalidApplicationException {
  32.       ValueExp var2 = this.exp1.apply(var1);
  33.       ValueExp var3 = this.exp2.apply(var1);
  34.       boolean var14 = var2 instanceof NumericValueExp;
  35.       if (var14) {
  36.          if (((NumericValueExp)var2).isLong()) {
  37.             long var10 = ((NumericValueExp)var2).longValue();
  38.             long var12 = ((NumericValueExp)var3).longValue();
  39.             switch (this.field_0) {
  40.                case 0:
  41.                   return Query.value(var10 + var12);
  42.                case 1:
  43.                   return Query.value(var10 - var12);
  44.                case 2:
  45.                   return Query.value(var10 * var12);
  46.                case 3:
  47.                   return Query.value(var10 / var12);
  48.             }
  49.          } else {
  50.             double var6 = ((NumericValueExp)var2).doubleValue();
  51.             double var8 = ((NumericValueExp)var3).doubleValue();
  52.             switch (this.field_0) {
  53.                case 0:
  54.                   return Query.value(var6 + var8);
  55.                case 1:
  56.                   return Query.value(var6 - var8);
  57.                case 2:
  58.                   return Query.value(var6 * var8);
  59.                case 3:
  60.                   return Query.value(var6 / var8);
  61.             }
  62.          }
  63.  
  64.          throw new BadBinaryOpValueExpException(this);
  65.       } else {
  66.          String var4 = ((StringValueExp)var2).getValue();
  67.          String var5 = ((StringValueExp)var3).getValue();
  68.          switch (this.field_0) {
  69.             case 0:
  70.                return new StringValueExp(var4 + var5);
  71.             default:
  72.                throw new BadStringOperationException(this.opString());
  73.          }
  74.       }
  75.    }
  76.  
  77.    public String toString() {
  78.       try {
  79.          return this.exp1 + " " + this.opString() + " " + this.exp2;
  80.       } catch (BadBinaryOpValueExpException var2) {
  81.          return "invalid expression";
  82.       }
  83.    }
  84.  
  85.    private String opString() throws BadBinaryOpValueExpException {
  86.       switch (this.field_0) {
  87.          case 0:
  88.             return "+";
  89.          case 1:
  90.             return "-";
  91.          case 2:
  92.             return "*";
  93.          case 3:
  94.             return "/";
  95.          default:
  96.             throw new BadBinaryOpValueExpException(this);
  97.       }
  98.    }
  99. }
  100.