1 18 package org.apache.commons.math.function; 19 20 26 public class DefaultContext implements EvaluationContext { 27 28 31 public DefaultContext() { 32 super(); 33 } 35 36 39 public double doubleValue(Evaluation argument) throws EvaluationException { 40 return ((DefaultValue)argument.evaluate(this)).doubleValue(); 42 } 43 44 47 public float floatValue(Evaluation argument) throws EvaluationException { 48 return ((DefaultValue)argument.evaluate(this)).floatValue(); 50 } 51 52 55 public int intValue(Evaluation argument) throws EvaluationException { 56 return ((DefaultValue)argument.evaluate(this)).intValue(); 58 } 59 60 63 public long longValue(Evaluation argument) throws EvaluationException { 64 return ((DefaultValue)argument.evaluate(this)).longValue(); 66 } 67 68 71 public short shortValue(Evaluation argument) throws EvaluationException { 72 return ((DefaultValue)argument.evaluate(this)).shortValue(); 74 } 75 76 79 public byte byteValue(Evaluation argument) throws EvaluationException { 80 return ((DefaultValue)argument.evaluate(this)).byteValue(); 82 } 83 84 87 public Evaluation evaluate(double d) { 88 return new DefaultValue(d); 90 } 91 92 95 public Evaluation evaluate(float f) { 96 return new DefaultValue(f); 98 } 99 100 103 public Evaluation evaluate(int i) { 104 return new DefaultValue(i); 106 } 107 108 111 public Evaluation evaluate(long l) { 112 return new DefaultValue(l); 114 } 115 116 119 public Evaluation evaluate(short s) { 120 return new DefaultValue(s); 122 } 123 124 127 public Evaluation evaluate(byte b) { 128 return new DefaultValue(b); 130 } 131 132 public class DefaultValue extends Number implements Evaluation { 133 134 Number value; 135 136 139 DefaultValue() { 140 super(); 141 } 143 144 DefaultValue(Number n) { 145 value = n; 146 } 147 148 DefaultValue(double d) { 149 value = new Double (d); 150 } 151 152 DefaultValue(float f) { 153 value = new Float (f); 154 } 155 156 DefaultValue(int i) { 157 value = new Integer (i); 158 } 159 160 DefaultValue(long l) { 161 value = new Long (l); 162 } 163 164 167 public Evaluation evaluate(EvaluationContext context) 168 throws EvaluationException { 169 return this; 170 } 171 172 175 public int intValue() { 176 return value.intValue(); 178 } 179 180 183 public long longValue() { 184 return value.longValue(); 186 } 187 188 191 public float floatValue() { 192 return value.floatValue(); 194 } 195 196 199 public double doubleValue() { 200 return value.doubleValue(); 202 } 203 204 207 public byte byteValue() { 208 return value.byteValue(); 210 } 211 212 215 public short shortValue() { 216 return value.shortValue(); 218 } 219 220 } 221 } 222 | Popular Tags |