01: package sisc.data;
02:
03: import java.io.*;
04:
05: import sisc.io.ValueWriter;
06: import sisc.ser.Serializer;
07: import sisc.ser.Deserializer;
08:
09: public class SchemeBoolean extends Value implements Singleton {
10: public static SchemeBoolean TRUE = new SchemeBoolean(true);
11: public static SchemeBoolean FALSE = new SchemeBoolean(false);
12: public static Boolean JTRUE = new Boolean(true),
13: JFALSE = new Boolean(false);
14: private boolean val;
15:
16: protected SchemeBoolean(boolean v) {
17: val = v;
18: }
19:
20: public void display(ValueWriter w) throws IOException {
21: w.append(val ? "#t" : "#f");
22: }
23:
24: public int hashCode() {
25: return (val ? 0x01010101 : 0x10101010);
26: }
27:
28: public boolean equals(Object o) {
29: return ((o instanceof SchemeBoolean) && ((SchemeBoolean) o).val == val);
30: }
31:
32: public SchemeBoolean() {
33: }
34:
35: public void serialize(Serializer s) throws IOException {
36: s.writeBoolean(val);
37: }
38:
39: public void deserialize(Deserializer s) throws IOException {
40: val = s.readBoolean();
41: }
42:
43: public Value singletonValue() {
44: return val ? TRUE : FALSE;
45: }
46: }
47:
48: /*
49: * The contents of this file are subject to the Mozilla Public
50: * License Version 1.1 (the "License"); you may not use this file
51: * except in compliance with the License. You may obtain a copy of
52: * the License at http://www.mozilla.org/MPL/
53: *
54: * Software distributed under the License is distributed on an "AS
55: * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
56: * implied. See the License for the specific language governing
57: * rights and limitations under the License.
58: *
59: * The Original Code is the Second Interpreter of Scheme Code (SISC).
60: *
61: * The Initial Developer of the Original Code is Scott G. Miller.
62: * Portions created by Scott G. Miller are Copyright (C) 2000-2007
63: * Scott G. Miller. All Rights Reserved.
64: *
65: * Contributor(s):
66: * Matthias Radestock
67: *
68: * Alternatively, the contents of this file may be used under the
69: * terms of the GNU General Public License Version 2 or later (the
70: * "GPL"), in which case the provisions of the GPL are applicable
71: * instead of those above. If you wish to allow use of your
72: * version of this file only under the terms of the GPL and not to
73: * allow others to use your version of this file under the MPL,
74: * indicate your decision by deleting the provisions above and
75: * replace them with the notice and other provisions required by
76: * the GPL. If you do not delete the provisions above, a recipient
77: * may use your version of this file under either the MPL or the
78: * GPL.
79: */
|