Java Boolean From toBoolean(String baseString)

Here you can find the source of toBoolean(String baseString)

Description

to Boolean

License

LGPL

Declaration

public static final boolean toBoolean(String baseString) 

Method Source Code

//package com.java2s;
/**/*from  w  w  w. ja  v a2  s .c  o m*/
* Converts a line of text into an array of lower case words using a
* BreakIterator.wordInstance().
* <p>
* 
* This method is under the Jive Open Source Software License and was written
* by Mark Imbriaco.
* 
* @param text
*          a String of text to convert into an array of words
* @return text broken up into an array of words.
*/

public class Main {

    public static final boolean toBoolean(String baseString) {
        return toBoolean(baseString, true);
    }

    public static final boolean toBoolean(String baseString, boolean pbDeault) {
        if (baseString == null)
            return pbDeault;
        else if (equalsIgnoreCase(baseString, "yes") || equalsIgnoreCase(baseString, "true")
                || equalsIgnoreCase(baseString, "on") || equalsIgnoreCase(baseString, "y")
                || equalsIgnoreCase(baseString, "1"))
            return true;
        else if (equalsIgnoreCase(baseString, "no") || equalsIgnoreCase(baseString, "false")
                || equalsIgnoreCase(baseString, "off") || equalsIgnoreCase(baseString, "n")
                || equalsIgnoreCase(baseString, "0"))
            return false;
        else
            return pbDeault;
    }

    public static final boolean equalsIgnoreCase(String baseString, String param1) {
        if (baseString == null) {
            if (param1 == null)
                return true;
            else
                return false;
        } else
            return baseString.equalsIgnoreCase(param1);
    }
}

Related

  1. toBoolean(Object value)
  2. toBoolean(Object value)
  3. toBoolean(Object value)
  4. toBoolean(Object value, Boolean defaultValue)
  5. toBoolean(Object value, boolean defaultValue)
  6. toBoolean(String content)
  7. toBoolean(String flag)
  8. toBoolean(String input, boolean defaultValue)
  9. toBoolean(String inString)