1 4 package gnu.mapping; 5 6 public class PlainLocation extends NamedLocation 7 { 8 public PlainLocation (Symbol symbol, Object property) 9 { 10 super(symbol, property); 11 } 12 13 public PlainLocation (Symbol symbol, Object property, Object value) 14 { 15 super(symbol, property); 16 this.value = value; 17 } 18 19 public final Object get (Object defaultValue) 20 { 21 return base != null ? base.get(defaultValue) 22 : value == Location.UNBOUND ? defaultValue : value; 23 } 24 25 public boolean isBound () 26 { 27 return base != null ? base.isBound() : value != Location.UNBOUND; 28 } 29 30 public final void set (Object newValue) 31 { 32 if (base == null) 33 value = newValue; 34 else if (value == DIRECT_ON_SET) 35 { 36 base = null; 37 value = newValue; 38 } 39 else if (base.isConstant()) 40 getEnvironment().put(getKeySymbol(), getKeyProperty(), newValue); 41 else 42 base.set(newValue); 43 } 44 } 45 | Popular Tags |