org.zkoss.zk.scripting.util
Class SimpleNamespace

java.lang.Object
  extended by org.zkoss.zk.scripting.util.AbstractNamespace
      extended by org.zkoss.zk.scripting.util.SimpleNamespace
All Implemented Interfaces:
Namespace

public class SimpleNamespace
extends AbstractNamespace

A simple implementation of Namespace.

Author:
tomyeh

Constructor Summary
SimpleNamespace()
           
SimpleNamespace(Component owner)
           
 
Method Summary
 boolean containsVariable(java.lang.String name, boolean local)
          Returns whether the specified variable is defined.
 void copy(Namespace ns)
          Copies all variables from the specified namespace.
 Namespace getParent()
          Returns the parent name space, or null if this is topmost.
 java.lang.Object getVariable(java.lang.String name, boolean local)
          Returns the variable of the specified name, or null if not defined or the value is null.
 java.util.Set getVariableNames()
          Returns a set of variable names stored in this name space.
 void setParent(Namespace parent)
          Sets the parent name space.
 void setVariable(java.lang.String name, java.lang.Object value, boolean local)
          Sets the variable of the specified name.
 void unsetVariable(java.lang.String name, boolean local)
          Unsets a variable from the current ID space.
 
Methods inherited from class org.zkoss.zk.scripting.util.AbstractNamespace
addChangeListener, notifyAdd, notifyParentChanged, notifyRemove, removeChangeListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleNamespace

public SimpleNamespace()

SimpleNamespace

public SimpleNamespace(Component owner)
Parameters:
owner - the owner of this namespace. If not null, the fellow of the owner is considered as part of this namespace. In other words, containsVariable(java.lang.String, boolean) and getVariable(java.lang.String, boolean) will check Component.getFellow(java.lang.String).
Since:
3.0.0
Method Detail

copy

public void copy(Namespace ns)
Copies all variables from the specified namespace. Note: only variables local to the specified namespace is copied.


getVariableNames

public java.util.Set getVariableNames()
Description copied from interface: Namespace
Returns a set of variable names stored in this name space.

Note: it doesn't include the parent's varaibles.


containsVariable

public boolean containsVariable(java.lang.String name,
                                boolean local)
Description copied from interface: Namespace
Returns whether the specified variable is defined.

local - whether not to search its ancestor. If false and the current ID space doen't define the variable, it searches up its ancestor (via Namespace.getParent()) to see any of them has defined the specified variable.

getVariable

public java.lang.Object getVariable(java.lang.String name,
                                    boolean local)
Description copied from interface: Namespace
Returns the variable of the specified name, or null if not defined or the value is null.

local - whether not to search its ancestor. If false and the current ID space doen't define the variable, it searches up its ancestor (via Namespace.getParent()) to see any of them has defined the specified variable.

setVariable

public void setVariable(java.lang.String name,
                        java.lang.Object value,
                        boolean local)
Description copied from interface: Namespace
Sets the variable of the specified name.

local - whether not to set the variable to this name space directly. If false, it searches whether the variable is defined in any of its ancestor (via Namespace.getParent()). If local = false and the ancestor is found, the value is stored to the ancestor instead of this.

unsetVariable

public void unsetVariable(java.lang.String name,
                          boolean local)
Description copied from interface: Namespace
Unsets a variable from the current ID space.

Unlike Namespace.setVariable(java.lang.String, java.lang.Object, boolean), this method removed only the variable defined in the ID space cotnaining this component.


getParent

public Namespace getParent()
Description copied from interface: Namespace
Returns the parent name space, or null if this is topmost.


setParent

public void setParent(Namespace parent)
Description copied from interface: Namespace
Sets the parent name space.



Copyright © 2005-2007 Potix Corporation. All Rights Reserved.