Here you can find the source of valueOfBoolean(final String s)
Parameter | Description |
---|---|
s | a parameter |
public static final Boolean valueOfBoolean(final String s)
//package com.java2s; public class Main { public static final String STR_EMP = ""; /***// w w w . j av a 2 s. c om * * @param s * @return */ public static final Boolean valueOfBoolean(final String s) { return Boolean.valueOf(parseBoolean(s)); } /** * * @param o * @return */ public static final String valueOf(final Object o) { return (o instanceof String) ? (String) o : (o == null ? "null" : o.toString()); } /** * * @param s * @return */ public static final boolean parseBoolean(final String s) { if ("true".equalsIgnoreCase(s)) { return true; } if (s == null) { return false; } switch (s.length()) { case 2: { char ch0 = s.charAt(0); char ch1 = s.charAt(1); return (ch0 == 'o' || ch0 == 'O') && (ch1 == 'n' || ch1 == 'N'); } case 3: { char ch = s.charAt(0); return (ch == 'y') ? (s.charAt(1) == 'e' || s.charAt(1) == 'E') && (s.charAt(2) == 's' || s.charAt(2) == 'S') : (s.charAt(1) == 'E' || s.charAt(1) == 'e') && (s.charAt(2) == 'S' || s.charAt(2) == 's'); } case 4: { char ch = s.charAt(0); return ch == 't' ? (s.charAt(1) == 'r' || s.charAt(1) == 'R') && (s.charAt(2) == 'u' || s.charAt(2) == 'U') && (s.charAt(3) == 'e' || s.charAt(3) == 'E') : (s.charAt(1) == 'R' || s.charAt(1) == 'r') && (s.charAt(2) == 'U' || s.charAt(2) == 'u') && (s.charAt(3) == 'E' || s.charAt(3) == 'e'); } } return false; } /** * * @param objs * @return */ public static String toString(final Object[] objs) { if (objs == null) { return STR_EMP; } final int len = objs.length; if (len == 0) { return STR_EMP; } final StringBuilder buf = new StringBuilder(len * 12); for (int i = 0; i < len - 1; i++) { buf.append(objs[i]).append(", "); } return buf.append(objs[len - 1]).toString(); } }