01: /*
02: * Created on Aug 7, 2005
03: *
04: */
05: package com.jofti.model;
06:
07: /**
08: *
09: *
10: * Comparable wrapper object for Boolean class. This is superceeded in 1.5 but for 1.4 code we have to use it.
11:
12: * @author xenephon (xenephon@jofti.com)
13: *
14: */
15: public class ComparableBoolean implements Comparable {
16: private Boolean value = Boolean.FALSE;
17:
18: public ComparableBoolean(String value) {
19: this .value = Boolean.valueOf(value);
20: }
21:
22: public ComparableBoolean(Boolean value) {
23: this .value = value;
24: }
25:
26: public ComparableBoolean(boolean value) {
27: this .value = Boolean.valueOf(value);
28: }
29:
30: /* (non-Javadoc)
31: * @see java.lang.Comparable#compareTo(java.lang.Object)
32: */
33: public int compareTo(Object arg0) {
34: if (arg0 instanceof ComparableBoolean) {
35: ComparableBoolean temp = (ComparableBoolean) arg0;
36: if (value.equals(Boolean.FALSE)) {
37: if (temp.value.equals(Boolean.FALSE)) {
38: return 0;
39: } else {
40: return -1;
41: }
42: } else {
43: if (temp.value.equals(Boolean.TRUE)) {
44: return 0;
45: } else {
46: return 1;
47: }
48: }
49: } else {
50: return -1;
51: }
52:
53: }
54:
55: public int hashCode() {
56: return value.hashCode();
57: }
58:
59: public boolean equals(Object obj) {
60: return value.equals(obj);
61: }
62:
63: public String toString() {
64: return value.toString();
65: }
66: }
|