01: /*
02: * @(#)Binding.java 1.2 04/12/06
03: *
04: * Copyright (c) 1997-2003 Sun Microsystems, Inc. All Rights Reserved.
05: *
06: * See the file "LICENSE.txt" for information on usage and redistribution of
07: * this file, and for a DISCLAIMER OF ALL WARRANTIES.
08: */
09: package pnuts.lang;
10:
11: import java.io.IOException;
12: import java.io.ObjectInputStream;
13: import java.io.Serializable;
14:
15: class Binding implements NamedValue, Cloneable, Serializable {
16:
17: String name;
18: Object value;
19: int hash;
20: Binding chain;
21:
22: Binding(int h, String name, Object v, Binding n) {
23: this .value = v;
24: this .chain = n;
25: this .name = name;
26: this .hash = h;
27: }
28:
29: public Object get() {
30: return this .value;
31: }
32:
33: public void set(Object value) {
34: this .value = value;
35: }
36:
37: public String getName() {
38: return this .name;
39: }
40:
41: /**
42: * Deep copy
43: */
44: protected Object clone() {
45: try {
46: Binding b = (Binding) super .clone();
47: if (chain != null) {
48: b.chain = (Binding) chain.clone();
49: }
50: return b;
51: } catch (CloneNotSupportedException e) {
52: throw new InternalError();
53: }
54: }
55:
56: private void readObject(ObjectInputStream s) throws IOException,
57: ClassNotFoundException {
58: s.defaultReadObject();
59: name = name.intern();
60: }
61: }
|