List of utility methods to do Boolean From
Boolean | toBoolean(String s) to Boolean s = s.toLowerCase(); if (s.equals("yes") || s.equals("y") || s.equals("true") || s.equals("t") || s.equals("1")) return Boolean.TRUE; if (s.equals("no") || s.equals("n") || s.equals("false") || s.equals("f") || s.equals("0")) return Boolean.FALSE; return null; |
boolean | toBoolean(String str) Converts a string to a boolean return str != null && str.equalsIgnoreCase("true"); |
Boolean | toBoolean(String str) to Boolean if (isTrue(str)) return true; if (isFalse(str)) return false; return null; |
Boolean | toBoolean(String str) to Boolean try { return Boolean.parseBoolean(str); } catch (Throwable e) { return null; |
boolean | toBoolean(String str) Converts a String to a boolean (optimised for performance). if (str == "true") { return true; if (str == null) { return false; switch (str.length()) { case 2: { ... |
boolean | toBoolean(String string) to Boolean return new Boolean(string).booleanValue(); |
boolean | toBoolean(String string) Returns a boolean from a string. if (string.equals("false") || string.equals("no")) return false; else if (string.equals("true") || string.equals("yes")) return true; else throw new IllegalArgumentException("Invalid boolean specifier: \"" + string + "\""); |
boolean | toBoolean(String string, boolean defaultValue) to Boolean if (isEmpty(string)) { return defaultValue; try { return Boolean.parseBoolean(string); } catch (NumberFormatException ex) { return defaultValue; |
Boolean | toBoolean(String text) Parses a JSON formatted boolean from text. if (text == null) { return null; } else if ("true".equals(text)) { return Boolean.TRUE; } else if ("false".equals(text)) { return Boolean.FALSE; } else { throw new IllegalArgumentException("Cannot parse '" + text + "' into JSON boolean"); ... |
boolean | toBoolean(String val) to Boolean return val != null && (val.equals("1") || val.equalsIgnoreCase("Y") || val.equalsIgnoreCase("T") || val.equalsIgnoreCase("YES") || val.equalsIgnoreCase("TRUE")); |