Arch4J 1.1

org.arch4j.clientcontroller
Class ContextImpl

java.lang.Object
  |
  +--org.arch4j.clientcontroller.ContextImpl
All Implemented Interfaces:
ContextView, StateContext

public class ContextImpl
extends Object
implements ContextView, StateContext

This class specifies the state context interface used by State and Transition objects. It will be implemented by an adaptor class for a specific client realm.

Version:
1.0
Author:
David Colwell

Constructor Summary
protected ContextImpl(StateContext theParentContext)
          Constructor
 
Method Summary
protected  void cleanup()
          Removes all values and removes the child context.
 boolean containsValue(String aKey)
          Determines if the specified value exists in the context set.
 Map getAllValues()
          Retrieves all key-value pairs from this context set, assuming that this context is the root.
 Object getSingleValue(String aKey)
          Retrieves the value mapped by aKey.
 Object getValue(String aKey)
          Retrieves the value mapped by aKey.
protected  void removeChildContext()
          Sets the child context to null.
 void removeValue(String aKey)
          Removes the value mapped by aKey.
protected  void setChildContext(ContextImpl aChildContext)
          Sets the child context reference.
 void setValue(String aKey, Object aValue)
          Sets the specified key-value under the local context.
 void updateValue(String aKey, Object aValue)
          Updates the value mapped by aKey.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ContextImpl

protected ContextImpl(StateContext theParentContext)
Constructor

Method Detail

setChildContext

protected void setChildContext(ContextImpl aChildContext)
Sets the child context reference.


removeChildContext

protected void removeChildContext()
Sets the child context to null.


getValue

public Object getValue(String aKey)
                throws ValueNotFoundException
Retrieves the value mapped by aKey. If the value is not found in the local context then ancestor contexts are searched including the root context.

This satisfies the StateContext interface and is intended to be used by states and transitions.

Specified by:
getValue in interface StateContext
Returns:
The value object.
Throws:
ValueNotFoundException - if the key-value cannot be found.

setValue

public void setValue(String aKey,
                     Object aValue)
Sets the specified key-value under the local context. This will overwrite any existing value in the local context with the same key.

Specified by:
setValue in interface StateContext

removeValue

public void removeValue(String aKey)
                 throws ValueNotFoundException
Removes the value mapped by aKey. If the value is not found in the local context, an exception is thrown.

Specified by:
removeValue in interface StateContext
Throws:
ValueNotFoundException - if the key-value cannot be found in the local context.

updateValue

public void updateValue(String aKey,
                        Object aValue)
                 throws ValueNotFoundException
Updates the value mapped by aKey. If the value is not found in the local context then ancestor contexts are searched including the root context. The value will be updated at the context level in which it is found.

Specified by:
updateValue in interface StateContext
Throws:
ValueNotFoundException - if the key-value cannot be found.

containsValue

public boolean containsValue(String aKey)
Determines if the specified value exists in the context set. If the value is not found in the local context, ancestor contexts are searched.

Specified by:
containsValue in interface StateContext
Returns:
true if the value is found, otherwise false.

getAllValues

public Map getAllValues()
Retrieves all key-value pairs from this context set, assuming that this context is the root.

Specified by:
getAllValues in interface ContextView

getSingleValue

public Object getSingleValue(String aKey)
Retrieves the value mapped by aKey. If the value is not found in the local context then child contexts are searched.

This satisfies the StateView interface and is intended to be used by users of a state machine that always have a reference to the root context.

Specified by:
getSingleValue in interface ContextView
Returns:
the object at the specified key, null if it isn't found.

cleanup

protected void cleanup()
Removes all values and removes the child context.


Arch4J 1.1

Copyright © 2000-2004 SpiderLogic, a service of Wipfli Ullrich Bertelson LLP.