1 package net.sf.twip.parameterhandler;
2
3 import net.sf.twip.util.Parameter;
4
5 public class DoubleParameterHandler extends AbstractFloatingPointNumberParameterHandler {
6
7 private static final Double[] VALUES = new Double[] { 1d, 1.5d, 2d, 2.5d, 3d, 0d, 1.0d / 9,
8 -1d, -1.5d, -2d, -2.5d, -3d, 127d, -127d, 1024d, -1024d, Double.NaN,
9 Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, Double.MAX_VALUE, Double.MIN_VALUE };
10
11 public DoubleParameterHandler(Parameter parameter) {
12 super(parameter);
13 }
14
15 @Override
16 protected Comparable<? extends Number> getComparable(String numberExpression) {
17 return Double.valueOf(numberExpression);
18 }
19
20 @Override
21 protected Object[] getDefaultParameterValues() {
22 return VALUES;
23 }
24
25 @Override
26 protected boolean isNaN(Object value) {
27 return ((Double) value).isNaN();
28 }
29
30 @Override
31 protected boolean isNegativeInfinity(Object value) {
32 final Double d = (Double) value;
33 return d.isInfinite() && d < 0;
34 }
35
36 @Override
37 protected boolean isPositiveInfinity(Object value) {
38 final Double d = (Double) value;
39 return d.isInfinite() && d > 0;
40 }
41
42 @Override
43 public boolean test(Object value) {
44 if (((Double) value).isNaN())
45 return false;
46 return super.test(value);
47 }
48 }