KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > gnu > mapping > PlainLocation


1 // Copyright (c) 2004 Per M.A. Bothner.
2
// This is free software; for terms and warranty disclaimer see ./COPYING.
3

4 package gnu.mapping;
5
6 public class PlainLocation extends NamedLocation
7 {
8   public PlainLocation (Symbol symbol, Object JavaDoc property)
9   {
10     super(symbol, property);
11   }
12
13   public PlainLocation (Symbol symbol, Object JavaDoc property, Object JavaDoc value)
14   {
15     super(symbol, property);
16     this.value = value;
17   }
18
19   public final Object JavaDoc get (Object JavaDoc 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 JavaDoc 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