Package org.zkoss.zk.ui.impl
Class SimpleScope
java.lang.Object
org.zkoss.zk.ui.impl.SimpleScope
- All Implemented Interfaces:
Scope
- Direct Known Subclasses:
SynchronizedScope
A simple implementation of
Scope.
It supports ScopeListener, but it doesn't support
the concept of parent scope.
Thus, the deriving class can override
getAttribute(String,boolean),
hasAttribute(String,boolean),
and invoke notifyParentChanged(org.zkoss.zk.ui.ext.Scope) if the parent is changed.
Not thread safe.
- Since:
- 5.0.0
- Author:
- tomyeh
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanaddScopeListener(ScopeListener listener) Adds a listener to listen whether this scope is changed.Clones this scope.getAttribute(String name) Returns the custom attribute associated with this object (scope).getAttribute(String name, boolean recurse) The same as getAttribute(name).Returns all custom attributes associated with this object (scope).Returns a list of all scope listeners (never null).booleanhasAttribute(String name) Returns if a custom attribute is associated with this object (scope).booleanhasAttribute(String name, boolean recurse) The same as hasAttribute(name).voidnotifyIdSpaceChanged(IdSpace newIdSpace) InvokesScopeListener.idSpaceChanged(org.zkoss.zk.ui.ext.Scope, org.zkoss.zk.ui.IdSpace)for registered listeners.voidnotifyParentChanged(Scope newparent) InvokesScopeListener.parentChanged(org.zkoss.zk.ui.ext.Scope, org.zkoss.zk.ui.ext.Scope)for registered listeners.removeAttribute(String name) Removes the attribute from the current scope if any.removeAttribute(String name, boolean recurse) The same as removeAttribute(name).booleanremoveScopeListener(ScopeListener listener) Removes a change listener from this scope.setAttribute(String name, Object value) Sets (a.k.a., associates) the value for a custom attribute with this object (scope).setAttribute(String name, Object value, boolean recurse) The same as setAttribute(name, value).toString()
-
Constructor Details
-
SimpleScope
Constructor.- Parameters:
owner- the real scope that an user can access. If this object is the scope that an user accesses directly, passnull
-
-
Method Details
-
getAttributes
Description copied from interface:ScopeReturns all custom attributes associated with this object (scope).- Specified by:
getAttributesin interfaceScope
-
getAttribute
Description copied from interface:ScopeReturns the custom attribute associated with this object (scope).- Specified by:
getAttributein interfaceScope
-
getAttribute
The same as getAttribute(name).- Specified by:
getAttributein interfaceScoperecurse- whether to search its ancestor scope. If true and the current scope doen't define the attribute, it searches up its ancestor to see any of them has defined the specified attribute.
-
hasAttribute
Description copied from interface:ScopeReturns if a custom attribute is associated with this object (scope).Notice that
nullis a valid value, so you can tell if an attribute is associated by examining the return value ofScope.getAttribute(java.lang.String).- Specified by:
hasAttributein interfaceScope
-
hasAttribute
The same as hasAttribute(name).- Specified by:
hasAttributein interfaceScoperecurse- whether to search its ancestor scope. If true and the current scope doen't define the attribute, it searches up its ancestor to see any of them has defined the specified attribute.
-
setAttribute
Description copied from interface:ScopeSets (a.k.a., associates) the value for a custom attribute with this object (scope).- Specified by:
setAttributein interfaceScope- Returns:
- the previous value associated with the attribute, if any
-
setAttribute
The same as setAttribute(name, value).- Specified by:
setAttributein interfaceScoperecurse- whether to look up the parent scope for the existence of the attribute.
If recurse is true and the attribute is defined in one of its ancestor (including page), the attribute is replaced. Otherwise, it is the same asScope.setAttribute(String,Object).
-
removeAttribute
Description copied from interface:ScopeRemoves the attribute from the current scope if any.- Specified by:
removeAttributein interfaceScope- Returns:
- the previous value associated with the attribute, if any,
-
removeAttribute
The same as removeAttribute(name).- Specified by:
removeAttributein interfaceScoperecurse- whether to look up the parent scope for the existence of the attribute.
If recurse is true and the attribute is defined in one of its ancestor (including page), the attribute is removed. Otherwise, it is the same asScope.removeAttribute(String).
-
addScopeListener
Description copied from interface:ScopeAdds a listener to listen whether this scope is changed. The listener is called when a custom attribute is added, removed, or the parent is changed.- Specified by:
addScopeListenerin interfaceScope- Returns:
- weather the listener is added successfully. Note: if the resolver was added before, it won't be added again and this method returns false.
-
removeScopeListener
Description copied from interface:ScopeRemoves a change listener from this scope.- Specified by:
removeScopeListenerin interfaceScope- Returns:
- false if listener is not added before.
-
notifyParentChanged
InvokesScopeListener.parentChanged(org.zkoss.zk.ui.ext.Scope, org.zkoss.zk.ui.ext.Scope)for registered listeners. -
notifyIdSpaceChanged
InvokesScopeListener.idSpaceChanged(org.zkoss.zk.ui.ext.Scope, org.zkoss.zk.ui.IdSpace)for registered listeners.- Since:
- 5.0.1
- See Also:
-
getListeners
Returns a list of all scope listeners (never null). -
clone
Clones this scope.- Parameters:
owner- the owner of the cloned scope.
-
toString
-