1 28 29 package com.caucho.jmx.query; 30 31 import javax.management.*; 32 33 36 abstract public class AbstractValueExp extends QueryEval implements ValueExp { 37 40 public ValueExp apply(ObjectName name) 41 throws BadStringOperationException, 42 BadBinaryOpValueExpException, 43 BadAttributeValueExpException, 44 InvalidApplicationException 45 { 46 return this; 47 } 48 49 52 public String getString() 53 { 54 throw new UnsupportedOperationException(); 55 } 56 57 60 public boolean getBoolean() 61 { 62 String value = getString(); 63 64 return value != null && value.equals("true"); 65 } 66 67 70 public long getLong() 71 { 72 String value = getString(); 73 74 if (value == null) 75 return 0; 76 else 77 return Long.parseLong(value); 78 } 79 80 83 public double getDouble() 84 { 85 String value = getString(); 86 87 if (value == null) 88 return 0; 89 else 90 return Double.parseDouble(value); 91 } 92 93 96 public static String toString(ValueExp exp) 97 throws BadBinaryOpValueExpException 98 { 99 return AbstractExp.toString(exp); 100 } 101 102 105 public static long toLong(ValueExp exp) 106 throws BadBinaryOpValueExpException 107 { 108 return AbstractExp.toLong(exp); 109 } 110 111 114 public static boolean toBoolean(ValueExp exp) 115 throws BadBinaryOpValueExpException 116 { 117 return AbstractExp.toBoolean(exp); 118 } 119 120 123 public static double toDouble(ValueExp exp) 124 throws BadBinaryOpValueExpException 125 { 126 return AbstractExp.toDouble(exp); 127 } 128 } 129 | Popular Tags |