Back to index

plt-scheme  4.2.1
Boolean.java
Go to the documentation of this file.
00001 /* Boolean.java -- object wrapper for boolean
00002    Copyright (C) 1998, 2001, 2002 Free Software Foundation, Inc.
00003 
00004 This file is part of GNU Classpath.
00005 
00006 GNU Classpath is free software; you can redistribute it and/or modify
00007 it under the terms of the GNU General Public License as published by
00008 the Free Software Foundation; either version 2, or (at your option)
00009 any later version.
00010 
00011 GNU Classpath is distributed in the hope that it will be useful, but
00012 WITHOUT ANY WARRANTY; without even the implied warranty of
00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 General Public License for more details.
00015 
00016 You should have received a copy of the GNU General Public License
00017 along with GNU Classpath; see the file COPYING.  If not, write to the
00018 Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00019 02111-1307 USA.
00020 
00021 Linking this library statically or dynamically with other modules is
00022 making a combined work based on this library.  Thus, the terms and
00023 conditions of the GNU General Public License cover the whole
00024 combination.
00025 
00026 As a special exception, the copyright holders of this library give you
00027 permission to link this library with independent modules to produce an
00028 executable, regardless of the license terms of these independent
00029 modules, and to copy and distribute the resulting executable under
00030 terms of your choice, provided that you also meet, for each linked
00031 independent module, the terms and conditions of the license of that
00032 module.  An independent module is a module which is not derived from
00033 or based on this library.  If you modify this library, you may extend
00034 this exception to your version of the library, but you are not
00035 obligated to do so.  If you do not wish to do so, delete this
00036 exception statement from your version. */
00037 
00038 
00039 package java.lang;
00040 
00041 import java.io.Serializable;
00042 
00052 public final class Boolean implements Serializable
00053 {
00057   private static final long serialVersionUID = -3665804199014368530L;
00058 
00065   public static final Boolean TRUE = new Boolean(true);
00066 
00073   public static final Boolean FALSE = new Boolean(false);
00074 
00081 //  public static final Class TYPE = VMClassLoader.getPrimitiveClass('Z');
00082 
00087   private final boolean value;
00088 
00098   public Boolean(boolean value)
00099   {
00100     this.value = value;
00101   }
00102 
00114   public Boolean(String s)
00115   {
00116     value = "true".equalsIgnoreCase(s);
00117   }
00118 
00125   public boolean booleanValue()
00126   {
00127     return value;
00128   }
00129 
00141   public static Boolean valueOf(boolean b)
00142   {
00143     return b ? TRUE : FALSE;
00144   }
00145 
00154   public static Boolean valueOf(String s)
00155   {
00156     return "true".equalsIgnoreCase(s) ? TRUE : FALSE;
00157   }
00158 
00167   public static String toString(boolean b)
00168   {
00169     return b ? "true" : "false";
00170   }
00171 
00178   public String toString()
00179   {
00180     return value ? "true" : "false";
00181   }
00182 
00190   public int hashCode()
00191   {
00192     return value ? 1231 : 1237;
00193   }
00194 
00204   public boolean equals(Object obj)
00205   {
00206     return obj instanceof Boolean && value == ((Boolean) obj).value;
00207   }
00208 
00218   public static boolean getBoolean(String name)
00219   {
00220       throw new RuntimeException("getBoolean has not been implemented yet");
00221 //    if (name == null || "".equals(name))
00222 //     return false;
00223 //    return "true".equalsIgnoreCase(System.getProperty(name));
00224   }
00225 }