Here you can find the source of toBoolean(Object val)
public static boolean toBoolean(Object val)
//package com.java2s; /*/*from w w w.j ava 2s. c om*/ * Scriptographer * * This file is part of Scriptographer, a Scripting Plugin for Adobe Illustrator * http://scriptographer.org/ * * Copyright (c) 2002-2010, Juerg Lehni * http://scratchdisk.com/ * * All rights reserved. See LICENSE file for details. * * File created on May 23, 2007. */ public class Main { public static boolean toBoolean(Object val) { return toBoolean(val, false); } public static boolean toBoolean(Object val, boolean defaultValue) { if (val instanceof Boolean) return ((Boolean) val).booleanValue(); if (val == null) return defaultValue; if (val instanceof String) return ((String) val).length() != 0; if (val instanceof Number) { double d = ((Number) val).doubleValue(); return d != 0.0 && !Double.isNaN(d); } return true; } }