(Object o)
| 263 | } |
| 264 | |
| 265 | public static Boolean toBoolean(Object o) { |
| 266 | // 9.2 |
| 267 | if (o instanceof Boolean) { |
| 268 | return (Boolean) o; |
| 269 | } |
| 270 | |
| 271 | if (o == Types.UNDEFINED || o == Types.NULL) { |
| 272 | return false; |
| 273 | } |
| 274 | if (o instanceof Double) { |
| 275 | if (((Double) o).isNaN() || ((Double) o).doubleValue() == 0.0) { |
| 276 | return false; |
| 277 | } |
| 278 | return true; |
| 279 | } |
| 280 | |
| 281 | if (o instanceof Number) { |
| 282 | if (((Number) o).intValue() == 0) { |
| 283 | return false; |
| 284 | } |
| 285 | return true; |
| 286 | } |
| 287 | if (o instanceof String) { |
| 288 | return (((String) o).length() != 0); |
| 289 | } |
| 290 | |
| 291 | if (o instanceof JSObject) { |
| 292 | return true; |
| 293 | } |
| 294 | |
| 295 | return true; |
| 296 | } |
| 297 | |
| 298 | public static Long toInteger(ExecutionContext context, Object o) { |
| 299 | Number number = toNumber(context, o); |
no test coverage detected