Here you can find the source of toBoolean(final String booleanString, final boolean defaultValue)
Parameter | Description |
---|---|
booleanString | the value |
defaultValue | the default if the value is unspecified or not a boolean value |
public final static boolean toBoolean(final String booleanString, final boolean defaultValue)
//package com.java2s; /**//from ww w . j a va 2 s .c o m * The contents of this file are subject to the Regenstrief Public License * Version 1.0 (the "License"); you may not use this file except in compliance with the License. * Please contact Regenstrief Institute if you would like to obtain a copy of the license. * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the * License for the specific language governing rights and limitations * under the License. * * Copyright (C) Regenstrief Institute. All Rights Reserved. */ public class Main { public final static String TRUE = Boolean.toString(true); public final static String FALSE = Boolean.toString(false); /** * Retrieves whether the given value is true * * @param booleanString the value * @param defaultValue the default if the value is unspecified or not a boolean value * @return whether the given value is true **/ public final static boolean toBoolean(final String booleanString, final boolean defaultValue) { return toBoolean(booleanString, TRUE, FALSE, defaultValue); } public final static boolean toBoolean(final String in, final String tru, final String fls, final boolean defVal) { return defVal ? !fls.equalsIgnoreCase(in) : tru.equalsIgnoreCase(in); } /** * Determines if two Strings are equal, ignoring case (true if both are null) * * @param s1 String 1 * @param s2 String 2 * @return whether s1 equals s2, ignoring case **/ public final static boolean equalsIgnoreCase(final String s1, final String s2) { return s1 == null ? s2 == null : s1.equalsIgnoreCase(s2); } }