1 28 29 package com.caucho.jmx.query; 30 31 import javax.management.*; 32 33 36 public class PlusExp extends AbstractValueExp { 37 private ValueExp _v1; 38 private ValueExp _v2; 39 40 43 public PlusExp(ValueExp v1, ValueExp v2) 44 { 45 _v1 = v1; 46 _v2 = v2; 47 } 48 49 56 public ValueExp apply(ObjectName name) 57 throws BadStringOperationException, BadBinaryOpValueExpException, 58 BadAttributeValueExpException, InvalidApplicationException 59 { 60 ValueExp v1 = _v1.apply(name); 61 ValueExp v2 = _v2.apply(name); 62 63 if (v1 instanceof DoubleValueExp || v2 instanceof DoubleValueExp) 64 return new DoubleValueExp(toDouble(v1) + toDouble(v2)); 65 else 66 return new LongValueExp(toLong(v1) + toLong(v2)); 67 } 68 69 72 public String toString() 73 { 74 return "(" + _v1 + " + " + _v2 + ")"; 75 } 76 } 77 | Popular Tags |