Java Boolean to String booleanToString_1(String str)

Here you can find the source of booleanToString_1(String str)

Description

boolean To Strin_

License

Open Source License

Declaration

public static final String booleanToString_1(String str) 

Method Source Code

//package com.java2s;
/*//w w  w  .  j a  v a2 s. c  o  m
 * ====================================================================
 * Copyright (C) 1997-2008 by Naijatek.com
 *
 * All copyright notices regarding MyAlumni MUST remain 
 * intact in the scripts and in the outputted HTML.
 * The "powered by" text/logo with a link back to
 * http://www.naijatek.com in 
 * the footer of the pages MUST remain visible when the pages
 * are viewed on the internet or intranet.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 * Support can be obtained from support forums at:
 * http://www.naijatek.com/myalumni/forum
 *
 * Correspondence and Marketing Questions can be sent to:
 * info at naijatek com
 *
 * <p>Title: MyAlumni </p>
 * <p>Description: This system helps keep alive the line of communications between alumni/alumnus</p>
 * <p>Copyright: Copyright (c) 1997-2008</p>
 * <p>Company: Naijatek Solutions (http://www.naijatek.com)</p>
 * @author Folashade Adeyosoye (shardayyy@naijatek.com)
 * @version 1.0
 */

public class Main {
    public static final String booleanToString_1(String str) {
        if (str == null) {
            return "0";
        }

        if (str.equals("0")) {
            return "0";
        }
        str = str.toLowerCase();
        if (str.equals("false")) {
            return "0";
        }
        if (str.equals("no")) {
            return "0";
        }
        if (str.equals("")) {
            return "0";
        }

        //if it's non false, it's true by definition
        return "1";
    }
}

Related

  1. booleanToSTRING(boolean value)
  2. booleanToString(boolean value)
  3. booleanToString(boolean[] values)
  4. booleanToString(String boolVal)
  5. booleanToString1(boolean bool)
  6. boolToStr(Boolean value)
  7. boolToString(boolean x)
  8. boolToString(final boolean b)
  9. BoolToStringEx(Boolean bValue)