(Object number)
| 2510 | /// |
| 2511 | /// a float value or an exception |
| 2512 | public static float toFloatValue(Object number) { |
| 2513 | // we should convert this to use Number |
| 2514 | if (number instanceof Float) { |
| 2515 | return ((Float) number).floatValue(); |
| 2516 | } |
| 2517 | if (number instanceof Long) { |
| 2518 | return ((Long) number).floatValue(); |
| 2519 | } |
| 2520 | if (number instanceof Integer) { |
| 2521 | return ((Integer) number).floatValue(); |
| 2522 | } |
| 2523 | if (number instanceof String) { |
| 2524 | return Float.parseFloat((String) number); |
| 2525 | } |
| 2526 | if (number instanceof Double) { |
| 2527 | return ((Double) number).floatValue(); |
| 2528 | } |
| 2529 | /*if(number instanceof Short) { |
| 2530 | return ((Short)number).floatValue(); |
| 2531 | } |
| 2532 | if(number instanceof Byte) { |
| 2533 | return ((Byte)number).floatValue(); |
| 2534 | }*/ |
| 2535 | if (number instanceof Boolean) { |
| 2536 | Boolean b = (Boolean) number; |
| 2537 | if (b.booleanValue()) { |
| 2538 | return 1; |
| 2539 | } |
| 2540 | return 0; |
| 2541 | } |
| 2542 | throw new IllegalArgumentException("Not a number: " + number); |
| 2543 | } |
| 2544 | |
| 2545 | /// Returns the number object as a double |
| 2546 | /// |
no test coverage detected