FileDocCategorySizeDatePackage
Boolean.javaAPI DocAndroid 1.5 API8078Wed May 06 22:41:04 BST 2009java.lang

Boolean

public final class Boolean extends Object implements Serializable, Comparable
The wrapper for the primitive type {@code boolean}.
since
Android 1.0

Fields Summary
private static final long
serialVersionUID
private final boolean
value
The boolean value of the receiver.
public static final Class
TYPE
The {@link Class} object that represents the primitive type {@code boolean}.
public static final Boolean
TRUE
The {@code Boolean} object that represents the primitive value {@code true}.
public static final Boolean
FALSE
The {@code Boolean} object that represents the primitive value {@code false}.
Constructors Summary
public Boolean(String string)
Constructs a new {@code Boolean} with its boolean value specified by {@code string}. If {@code string} is not {@code null} and is equal to "true" using a non-case sensitive comparison, the result will be a Boolean representing the primitive value {@code true}, otherwise it will be a Boolean representing the primitive value {@code false}.

param
string the string representing a boolean value.
since
Android 1.0


                                                                                      
       
        this(parseBoolean(string));
    
public Boolean(boolean value)
Constructs a new {@code Boolean} with the specified primitive boolean value.

param
value the primitive boolean value, {@code true} or {@code false}.
since
Android 1.0

        this.value = value;
    
Methods Summary
public booleanbooleanValue()
Gets the primitive value of this boolean, either {@code true} or {@code false}.

return
this object's primitive value, {@code true} or {@code false}.
since
Android 1.0

        return value;
    
public intcompareTo(java.lang.Boolean that)
Compares this object to the specified boolean object to determine their relative order.

param
that the boolean object to compare this object to.
return
0 if the value of this boolean and the value of {@code that} are equal; a positive value if the value of this boolean is {@code true} and the value of {@code that} is {@code false}; a negative value if the value if this boolean is {@code false} and the value of {@code that} is {@code true}.
see
java.lang.Comparable
since
Android 1.0

        if (that == null) {
            throw new NullPointerException();
        }

        if (this.value == that.value) {
            return 0;
        }

        return this.value ? 1 : -1;
    
public booleanequals(java.lang.Object o)
Compares this instance with the specified object and indicates if they are equal. In order to be equal, {@code o} must be an instance of {@code Boolean} and have the same boolean value as this object.

param
o the object to compare this boolean with.
return
{@code true} if the specified object is equal to this {@code Boolean}; {@code false} otherwise.
since
Android 1.0

        return (o == this)
                || ((o instanceof Boolean) && (value == ((Boolean) o).value));
    
public static booleangetBoolean(java.lang.String string)
Returns the {@code boolean} value of the system property identified by {@code string}.

param
string the name of the requested system property.
return
{@code true} if the system property named by {@code string} exists and it is equal to "true" using case insensitive comparison, {@code false} otherwise.
see
System#getProperty(String)
since
Android 1.0

        if (string == null || string.length() == 0) {
            return false;
        }
        return (parseBoolean(System.getProperty(string)));
    
public inthashCode()
Returns an integer hash code for this boolean.

return
this boolean's hash code, which is {@code 1231} for {@code true} values and {@code 1237} for {@code false} values.
since
Android 1.0

        return value ? 1231 : 1237;
    
public static booleanparseBoolean(java.lang.String s)
Parses the specified string as a {@code boolean}.

param
s the string representation of a boolean value.
return
{@code true} if {@code s} is not {@code null} and is equal to {@code "true"} using case insensitive comparison, {@code false} otherwise.
since
Android 1.0

        return "true".equalsIgnoreCase(s); //$NON-NLS-1$
    
public static java.lang.StringtoString(boolean value)
Converts the specified boolean to its string representation.

param
value the boolean to convert.
return
"true" if {@code value} is {@code true}, "false" otherwise.
since
Android 1.0

        return String.valueOf(value);
    
public java.lang.StringtoString()
Returns a string containing a concise, human-readable description of this boolean.

return
"true" if the value of this boolean is {@code true}, "false" otherwise.
since
Android 1.0

        return String.valueOf(value);
    
public static java.lang.BooleanvalueOf(java.lang.String string)
Parses the specified string as a boolean value.

param
string the string representation of a boolean value.
return
{@code Boolean.TRUE} if {@code string} is equal to "true" using case insensitive comparison, {@code Boolean.FALSE} otherwise.
see
#parseBoolean(String)
since
Android 1.0

        return parseBoolean(string) ? Boolean.TRUE : Boolean.FALSE;
    
public static java.lang.BooleanvalueOf(boolean b)
Returns a {@code Boolean} instance for the specified boolean value.

If it is not necessary to get a new {@code Boolean} instance, it is recommended to use this method instead of the constructor, since it returns its static instances, which results in better performance.

param
b the boolean to convert to a {@code Boolean}.
return
{@code Boolean.TRUE} if {@code b} is equal to {@code true}, {@code Boolean.FALSE} otherwise.
since
Android 1.0

        return b ? Boolean.TRUE : Boolean.FALSE;