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