Java Boolean From toBoolean(Object bool)

Here you can find the source of toBoolean(Object bool)

Description

to Boolean

License

Open Source License

Declaration

public static boolean toBoolean(Object bool) 

Method Source Code

//package com.java2s;

public class Main {
    public static boolean toBoolean(Object bool) {
        if (bool == null)
            return false;
        if (bool instanceof Boolean) {
            boolean b = ((Boolean) bool).booleanValue();
            return b;
        }/*from www .  j  av  a  2 s.c om*/
        bool = bool.toString();
        if (bool.equals("true") || bool.equals("y") || bool.equals("on")
                || bool.equals("1"))
            return true;
        return false;
    }
}

Related

  1. toBoolean(int i)
  2. toBoolean(int value)
  3. toBoolean(Integer value, Integer trueValue, Integer falseValue)
  4. toBoolean(Number value)
  5. toBoolean(Object anObj)
  6. toBoolean(Object o)
  7. toBoolean(Object o)
  8. toBoolean(Object o)
  9. toBoolean(Object o)