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