01: // Copyright (c) 2004 Per M.A. Bothner.
02: // This is free software; for terms and warranty disclaimer see ./COPYING.
03:
04: package gnu.mapping;
05:
06: public class PlainLocation extends NamedLocation {
07: public PlainLocation(Symbol symbol, Object property) {
08: super (symbol, property);
09: }
10:
11: public PlainLocation(Symbol symbol, Object property, Object value) {
12: super (symbol, property);
13: this .value = value;
14: }
15:
16: public final Object get(Object defaultValue) {
17: return base != null ? base.get(defaultValue)
18: : value == Location.UNBOUND ? defaultValue : value;
19: }
20:
21: public boolean isBound() {
22: return base != null ? base.isBound()
23: : value != Location.UNBOUND;
24: }
25:
26: public final void set(Object newValue) {
27: if (base == null)
28: value = newValue;
29: else if (value == DIRECT_ON_SET) {
30: base = null;
31: value = newValue;
32: } else if (base.isConstant())
33: getEnvironment().put(getKeySymbol(), getKeyProperty(),
34: newValue);
35: else
36: base.set(newValue);
37: }
38: }
|