01: package gnu.mapping;
02:
03: /* Abstract class from mappings to Strings to bindings. */
04:
05: public abstract class NameMap extends Procedure1 implements HasSetter
06: // implements java.util.Map
07: {
08: /** Get the value bound to the given name.
09: * @exception gnu.mapping.UnboundSymbol the name has no binding
10: * @see Environment#get(Object)
11: */
12: public final Object getChecked(String name) {
13: Object value = get(name, Binding.UNBOUND);
14: if (value == Binding.UNBOUND)
15: throw new UnboundSymbol(name);
16: return value;
17: }
18:
19: /** Get the value bound to the given name.
20: * Returns null if the name has no binding
21: * (for compatibility with Java2 Collections framework).
22: * @see Environment#getChecked(String)
23: */
24: public final Object get(Object name) {
25: return get((String) name, null);
26: }
27:
28: public abstract Object get(String key, Object defaultValue);
29:
30: public abstract Object put(String key, Object value);
31:
32: public Object apply1(Object arg) {
33: return get((String) arg);
34: }
35:
36: public void set1(Object arg, Object value) {
37: put((String) arg, value);
38: }
39:
40: }
|