home *** CD-ROM | disk | FTP | other *** search
- package javax.management;
-
- class BinaryOpValueExp extends QueryEval implements ValueExp {
- private static final long serialVersionUID = 1216286847881456786L;
- // $FF: renamed from: op int
- private int field_0;
- private ValueExp exp1;
- private ValueExp exp2;
-
- BinaryOpValueExp(int op, ValueExp exp1, ValueExp exp2) {
- this.field_0 = op;
- this.exp1 = exp1;
- this.exp2 = exp2;
- }
-
- public void setMBeanServer(MBeanServer server) {
- super.setMBeanServer(server);
- if (this.exp1 != null) {
- this.exp1.setMBeanServer(server);
- }
-
- if (this.exp2 != null) {
- this.exp2.setMBeanServer(server);
- }
-
- }
-
- public ValueExp apply(ObjectName name) throws BadStringOperationException, BadBinaryOpValueExpException, BadAttributeValueExpException, InvalidApplicationException {
- if (this.exp1 != null && this.exp2 != null) {
- ValueExp val1 = this.exp1.apply(name);
- ValueExp val2 = this.exp2.apply(name);
- if (!(val1 instanceof NumericValueExp)) {
- if (val1 instanceof StringValueExp) {
- if (val2 instanceof StringValueExp) {
- String s1 = ((StringValueExp)val1).getValue();
- String s2 = ((StringValueExp)val2).getValue();
- switch (this.field_0) {
- case 0:
- return Query.value(s1 + s2);
- default:
- throw new BadStringOperationException("Trying to perform an operation on Strings that is not concatenation");
- }
- }
-
- throw new BadBinaryOpValueExpException(val2);
- }
-
- throw new BadBinaryOpValueExpException(val1);
- }
-
- if (!(val2 instanceof NumericValueExp)) {
- throw new BadBinaryOpValueExpException(val2);
- }
-
- NumericValueExp num1 = (NumericValueExp)val1;
- NumericValueExp num2 = (NumericValueExp)val2;
- if (!num1.isDouble() && !num2.isDouble()) {
- long l1 = num1.longValue();
- long l2 = num2.longValue();
- switch (this.field_0) {
- case 0:
- return Query.value(l1 + l2);
- case 1:
- return Query.value(l1 - l2);
- case 2:
- return Query.value(l1 * l2);
- case 3:
- return Query.value(l1 / l2);
- }
- } else {
- double d1 = num1.doubleValue();
- double d2 = num2.doubleValue();
- switch (this.field_0) {
- case 0:
- return Query.value(d1 + d2);
- case 1:
- return Query.value(d1 - d2);
- case 2:
- return Query.value(d1 * d2);
- case 3:
- return Query.value(d1 / d2);
- }
- }
- }
-
- throw new BadBinaryOpValueExpException((ValueExp)null);
- }
- }
-