2007-07-19 21:18:25 -06:00
|
|
|
package java.lang;
|
|
|
|
|
2007-10-28 18:51:08 -06:00
|
|
|
public final class Boolean implements Comparable<Boolean> {
|
2007-07-28 10:55:24 -06:00
|
|
|
public static final Class TYPE = Class.forCanonicalName("Z");
|
2007-07-26 20:39:53 -06:00
|
|
|
|
2007-07-29 17:32:23 -06:00
|
|
|
public static final Boolean FALSE = new Boolean(false);
|
|
|
|
public static final Boolean TRUE = new Boolean(true);
|
|
|
|
|
2007-07-19 21:18:25 -06:00
|
|
|
private final boolean value;
|
|
|
|
|
|
|
|
public Boolean(boolean value) {
|
|
|
|
this.value = value;
|
|
|
|
}
|
|
|
|
|
2007-09-13 20:19:44 -06:00
|
|
|
public Boolean(String s) {
|
|
|
|
this.value = "true".equals(s);
|
|
|
|
}
|
|
|
|
|
2007-08-12 18:50:25 -06:00
|
|
|
public static Boolean valueOf(boolean value) {
|
|
|
|
return (value ? Boolean.TRUE : Boolean.FALSE);
|
|
|
|
}
|
|
|
|
|
2007-08-30 17:31:32 -06:00
|
|
|
public static Boolean valueOf(String s) {
|
2007-11-04 14:15:28 -07:00
|
|
|
Boolean.TRUE.booleanValue();
|
2007-08-30 17:31:32 -06:00
|
|
|
return ("true".equals(s) ? Boolean.TRUE : Boolean.FALSE);
|
|
|
|
}
|
|
|
|
|
2007-10-28 18:51:08 -06:00
|
|
|
public int compareTo(Boolean o) {
|
|
|
|
return (value ? (o.value ? 0 : 1) : (o.value ? -1 : 0));
|
|
|
|
}
|
|
|
|
|
2007-07-29 17:32:23 -06:00
|
|
|
public boolean equals(Object o) {
|
|
|
|
return o instanceof Boolean && ((Boolean) o).value == value;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int hashCode() {
|
|
|
|
return (value ? 1 : 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
public String toString() {
|
|
|
|
return toString(value);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static String toString(boolean v) {
|
|
|
|
return (v ? "true" : "false");
|
|
|
|
}
|
|
|
|
|
2007-07-19 21:18:25 -06:00
|
|
|
public boolean booleanValue() {
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
}
|