public class SimpleScope extends java.lang.Object implements Scope
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.
Constructor and Description |
---|
SimpleScope(Scope owner)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
boolean |
addScopeListener(ScopeListener listener)
Adds a listener to listen whether this scope is changed.
|
SimpleScope |
clone(Scope owner)
Clones this scope.
|
java.lang.Object |
getAttribute(java.lang.String name)
Returns the custom attribute associated with this object (scope).
|
java.lang.Object |
getAttribute(java.lang.String name,
boolean recurse)
The same as getAttribute(name).
|
java.util.Map<java.lang.String,java.lang.Object> |
getAttributes()
Returns all custom attributes associated with this object (scope).
|
java.util.List<ScopeListener> |
getListeners()
Returns a ist of all scope listners (never null).
|
boolean |
hasAttribute(java.lang.String name)
Returns if a custom attribute is associated with this object (scope).
|
boolean |
hasAttribute(java.lang.String name,
boolean recurse)
The same as hasAttribute(name).
|
void |
notifyIdSpaceChanged(IdSpace newIdSpace)
Invokes
ScopeListener.idSpaceChanged(org.zkoss.zk.ui.ext.Scope, org.zkoss.zk.ui.IdSpace) for registered
listeners. |
void |
notifyParentChanged(Scope newparent)
Invokes
ScopeListener.parentChanged(org.zkoss.zk.ui.ext.Scope, org.zkoss.zk.ui.ext.Scope) for registered
listeners. |
java.lang.Object |
removeAttribute(java.lang.String name)
Removes the attribute from the current scope if any.
|
java.lang.Object |
removeAttribute(java.lang.String name,
boolean recurse)
The same as removeAttribute(name).
|
boolean |
removeScopeListener(ScopeListener listener)
Removes a change listener from this scope.
|
java.lang.Object |
setAttribute(java.lang.String name,
java.lang.Object value)
Sets (a.k.a., associates) the value for a custom attribute with this object (scope).
|
java.lang.Object |
setAttribute(java.lang.String name,
java.lang.Object value,
boolean recurse)
The same as setAttribute(name, value).
|
java.lang.String |
toString() |
public SimpleScope(Scope owner)
owner
- the real scope that an user can access.
If this object is the scope that an user accesses directly, pass null
public java.util.Map<java.lang.String,java.lang.Object> getAttributes()
Scope
getAttributes
in interface Scope
public java.lang.Object getAttribute(java.lang.String name)
Scope
getAttribute
in interface Scope
public java.lang.Object getAttribute(java.lang.String name, boolean recurse)
getAttribute
in interface Scope
recurse
- 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.public boolean hasAttribute(java.lang.String name)
Scope
Notice that null
is a valid value, so you can
tell if an attribute is associated by examining the return value
of Scope.getAttribute(java.lang.String)
.
hasAttribute
in interface Scope
public boolean hasAttribute(java.lang.String name, boolean recurse)
hasAttribute
in interface Scope
recurse
- 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.public java.lang.Object setAttribute(java.lang.String name, java.lang.Object value)
Scope
setAttribute
in interface Scope
public java.lang.Object setAttribute(java.lang.String name, java.lang.Object value, boolean recurse)
setAttribute
in interface Scope
recurse
- whether to look up the parent scope for the
existence of the attribute.Scope.setAttribute(String,Object)
.public java.lang.Object removeAttribute(java.lang.String name)
Scope
removeAttribute
in interface Scope
public java.lang.Object removeAttribute(java.lang.String name, boolean recurse)
removeAttribute
in interface Scope
recurse
- whether to look up the parent scope for the
existence of the attribute.Scope.removeAttribute(String)
.public boolean addScopeListener(ScopeListener listener)
Scope
addScopeListener
in interface Scope
public boolean removeScopeListener(ScopeListener listener)
Scope
removeScopeListener
in interface Scope
public void notifyParentChanged(Scope newparent)
ScopeListener.parentChanged(org.zkoss.zk.ui.ext.Scope, org.zkoss.zk.ui.ext.Scope)
for registered
listeners.public void notifyIdSpaceChanged(IdSpace newIdSpace)
ScopeListener.idSpaceChanged(org.zkoss.zk.ui.ext.Scope, org.zkoss.zk.ui.IdSpace)
for registered
listeners.addScopeListener(org.zkoss.zk.ui.ext.ScopeListener)
public java.util.List<ScopeListener> getListeners()
public SimpleScope clone(Scope owner)
owner
- the owner of the cloned scope.public java.lang.String toString()
toString
in class java.lang.Object
Copyright © 2005-2011 Potix Corporation. All Rights Reserved.