ecologylab.appframework
Class Scope<T>
java.lang.Object
ecologylab.appframework.Scope<T>
- Direct Known Subclasses:
- ClassRegistry
public class Scope<T>
- extends java.lang.Object
A lexical Scope of bindings from names to values.
Lexical Scopes can be nested. However, bind operations are only performed on the current Scope.
Lookup operations chain through parents, as necessary, when a binding is not found locally.
These replace statics and are much more flexible.
|
Method Summary |
T |
bind(java.lang.String name,
T value)
Bind an object to a name. |
boolean |
isBound(java.lang.String key)
|
T |
lookup(java.lang.String name)
Lookup an object in this. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Scope
public Scope()
Scope
public Scope(Scope<T> parent)
bind
public T bind(java.lang.String name,
T value)
- Bind an object to a name.
- Parameters:
name - value -
- Returns:
- Previous value, or null if there wasn't one.
lookup
public T lookup(java.lang.String name)
- Lookup an object in this.
- Parameters:
name -
- Returns:
- The object associated with this name, found in the registry,
or null if there is none.
isBound
public boolean isBound(java.lang.String key)
- Parameters:
key -
- Returns:
- true if there is already a binding for key in this Scope.