Interpret the value object as an integer, returning def if unable.
(Object value, int def)
| 133 | * returning def if unable. |
| 134 | */ |
| 135 | private static int getInt(Object value, int def) { |
| 136 | if (value == null) |
| 137 | return def; |
| 138 | if (value instanceof String) { |
| 139 | try { |
| 140 | String s = (String)value; |
| 141 | if (s.startsWith("0x")) |
| 142 | return Integer.parseInt(s.substring(2), 16); |
| 143 | else |
| 144 | return Integer.parseInt(s); |
| 145 | } catch (NumberFormatException nfex) { } |
| 146 | } |
| 147 | if (value instanceof Integer) |
| 148 | return ((Integer)value).intValue(); |
| 149 | return def; |
| 150 | } |
| 151 | |
| 152 | /** |
| 153 | * Interpret the value object as a boolean, |
no test coverage detected