org.sapia.gumby
Interface GuiEnv

All Known Implementing Classes:
DefaultGuiEnv

public interface GuiEnv

This interface specifies "environment" behavior, as some shared state that is scoped and made available to some parts of an application.

Implementations of this interface are expected to follow a delegation model where given instances can have other instances as ancesters, and where the ancestors are "consulted" after a given operation is performed at a child - and if that operation fails at the child.

Author:
Yanick Duchesne
Copyright:
Copyright © 2002-2005 Sapia Open Source Software. All Rights Reserved.
License:
Read the license.txt file of the jar or visit the license page at the Sapia OSS web site

Method Summary
 Object acquire(String name)
           
 Object acquire(String name, String scope)
           
 void addScope(String name, Scope scope)
          This methods internally binds the given scope under the given name within this instance.
 Object get(String name)
          This method attempts to retrieve the object bound under the given name.
 Object get(String name, String scope)
          This method looks for the object of the given name in the specified scope.
 Scope getScope(String name)
          Returns the scope that corresponds to the given name.
 boolean hasScope(String name)
           
 void put(String name, Object obj, String scope)
          Puts the given object in the given scope, under the given name.
 void removeScope(String name)
          Removes the scope with the given name from this instance.
 

Method Detail

get

public Object get(String name)
This method attempts to retrieve the object bound under the given name. This method delegates the call to the ancestor of this instance if it cannot find the object at its level (and so on).

This method looks for the object in all scopes, in the order in which the scopes where created.

Parameters:
name - the name of an object.
Returns:
the desired Object, or null if no such object was found.
See Also:
addScope(String, Scope), put(String, Object, String)

get

public Object get(String name,
                  String scope)
This method looks for the object of the given name in the specified scope.

See Also:
get(String)

acquire

public Object acquire(String name)
               throws IllegalArgumentException
Throws:
IllegalArgumentException - if the desired object could not be found.
See Also:
get(String)

acquire

public Object acquire(String name,
                      String scope)
               throws IllegalArgumentException
Throws:
IllegalArgumentException - if the desired object could not be found.
See Also:
get(String, String)

put

public void put(String name,
                Object obj,
                String scope)
Puts the given object in the given scope, under the given name. If no scope currently exists for the scope name that is specified, the parent environment is searched - and so on; if still no scope exist that correspond to the given scope name, new one is created within this instance. If an object is already bound under the given name (in the specified scope), it is overwritten.

Parameters:
name - the name under which to bind the object.
obj - the Object to bind.
scope - the name of the scope under which to bind the object.

addScope

public void addScope(String name,
                     Scope scope)
This methods internally binds the given scope under the given name within this instance. If a scope with an identical name exists in a parent environment, that it will become invisible to clients of this instance (this instance's identically named scope will prevail).

In addition, if a scope with the given name already exists within this instance, it is overwritten.

Parameters:
name - the name under which the given scope should be kept within this instance.
scope - a Scope.

removeScope

public void removeScope(String name)
Removes the scope with the given name from this instance. Parent environments are not affected by this operation, even if no such scope exists at this instance's level.

Parameters:
name - the name of a scope.

getScope

public Scope getScope(String name)
Returns the scope that corresponds to the given name. If no such scope is found at this instance's level, ancestors are searched.

Parameters:
name - the name of a scope.
Returns:
the Scope corresponding to the given name, or null if no such scope exists.

hasScope

public boolean hasScope(String name)
Parameters:
name - the name of a scope.
Returns:
true if this instance or one of its ancestors has such a scope.


Copyright © 2002 Sapia Open Community, Inc. All Rights Reserved.