|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.threerings.expr.DynamicScope
public class DynamicScope
A Scope that allows dynamic reparenting and the addition and removal of symbols. Can be
used either as a base class or as a contained object.
| Field Summary | |
|---|---|
protected int |
_compoundDepth
The compound update depth. |
protected WeakObserverList<ScopeUpdateListener> |
_listeners
The listeners to this scope. |
protected Object |
_owner
The owner of this scope. |
protected Scope |
_parentScope
A reference to the parent scope. |
protected String |
_scopeName
The name of this scope. |
protected HashMap<String,Object> |
_symbols
The mappings for the dynamic symbols in this scope. |
protected static Scope |
INVALID_SCOPE
Used to force initialization. |
| Fields inherited from interface com.threerings.expr.Scope |
|---|
EPOCH, NOW |
| Constructor Summary | |
|---|---|
DynamicScope(Object owner,
String name)
Creates a new scope. |
|
DynamicScope(Object owner,
String name,
Scope parent)
Creates a new scope with the supplied scope as its parent. |
|
DynamicScope(String name)
Creates a new scope that is its own owner. |
|
DynamicScope(String name,
Scope parent)
Creates a new scope that is its own owner with the supplied scope as its parent. |
|
| Method Summary | ||
|---|---|---|
void |
addListener(ScopeUpdateListener listener)
Adds a listener for changes in scope. |
|
void |
dispose()
Releases the resources associated with this scope. |
|
void |
endCompoundUpdate()
Ends a compound update. |
|
|
get(String name,
Class<T> clazz)
Looks up a symbol in this scope. |
|
Scope |
getParentScope()
Returns a reference to the parent scope, or null if this is the top level. |
|
String |
getScopeName()
Returns the name of this scope for purposes of qualification. |
|
void |
put(String name,
Object value)
Sets the mapping for the named symbol in this scope. |
|
void |
remove(String name)
Removes the named symbol from this scope. |
|
void |
removeListener(ScopeUpdateListener listener)
Removes a listener for changes in scope. |
|
void |
scopeUpdated(ScopeEvent event)
Called when the scope has been updated. |
|
void |
setParentScope(Scope parent)
Sets the parent of this scope. |
|
void |
startCompoundUpdate()
Starts a compound update. |
|
void |
wasUpdated()
Notes that this scope has been updated. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected Object _owner
protected String _scopeName
protected Scope _parentScope
protected int _compoundDepth
protected HashMap<String,Object> _symbols
protected WeakObserverList<ScopeUpdateListener> _listeners
protected static final Scope INVALID_SCOPE
| Constructor Detail |
|---|
public DynamicScope(String name)
public DynamicScope(String name,
Scope parent)
public DynamicScope(Object owner,
String name)
public DynamicScope(Object owner,
String name,
Scope parent)
| Method Detail |
|---|
public void setParentScope(Scope parent)
public void put(String name,
Object value)
public void remove(String name)
public void startCompoundUpdate()
endCompoundUpdate() is called.
public void endCompoundUpdate()
public void wasUpdated()
public void dispose()
public String getScopeName()
Scopenull
if qualified symbols cannot specifically address this scope.
getScopeName in interface Scopepublic Scope getParentScope()
Scopenull if this is the top level.
getParentScope in interface Scope
public <T> T get(String name,
Class<T> clazz)
Scope
get in interface Scopenull if not found.public void addListener(ScopeUpdateListener listener)
Scope
addListener in interface Scopepublic void removeListener(ScopeUpdateListener listener)
Scope
removeListener in interface Scopepublic void scopeUpdated(ScopeEvent event)
ScopeUpdateListener
scopeUpdated in interface ScopeUpdateListener
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||