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