org.apache.commons.scxml.env
Class SimpleContext

java.lang.Object
  extended by org.apache.commons.scxml.env.SimpleContext
All Implemented Interfaces:
Serializable, Context
Direct Known Subclasses:
ELContext, JexlContext, SessionContext

public class SimpleContext
extends Object
implements Context, Serializable

Simple Context wrapping a map of variables.

See Also:
Serialized Form

Constructor Summary
SimpleContext()
          Constructor.
SimpleContext(Context parent)
          Constructor.
SimpleContext(Context parent, Map initialVars)
          Constructor.
SimpleContext(Map initialVars)
          Constructor.
 
Method Summary
 Object get(String name)
          Get the value of this variable; delegating to parent.
protected  org.apache.commons.logging.Log getLog()
          Get the log used by this Context instance.
 Context getParent()
          Get the parent Context, may be null.
 Map getVars()
          Get the Map of all local variables in this Context.
 boolean has(String name)
          Check if this variable exists, delegating to parent.
 void reset()
          Clear this Context.
 void set(String name, Object value)
          Assigns a new value to an existing variable or creates a new one.
 void setLocal(String name, Object value)
          Assigns a new value to an existing variable or creates a new one.
protected  void setLog(org.apache.commons.logging.Log log)
          Set the log used by this Context instance.
protected  void setVars(Map vars)
          Set the variables map.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleContext

public SimpleContext()
Constructor.


SimpleContext

public SimpleContext(Context parent)
Constructor.

Parameters:
parent - A parent Context, can be null

SimpleContext

public SimpleContext(Map initialVars)
Constructor.

Parameters:
initialVars - A pre-populated initial variables map

SimpleContext

public SimpleContext(Context parent,
                     Map initialVars)
Constructor.

Parameters:
parent - A parent Context, can be null
initialVars - A pre-populated initial variables map
Method Detail

set

public void set(String name,
                Object value)
Assigns a new value to an existing variable or creates a new one. The method searches the chain of parent Contexts for variable existence.

Specified by:
set in interface Context
Parameters:
name - The variable name
value - The variable value
See Also:
Context.set(String, Object)

get

public Object get(String name)
Get the value of this variable; delegating to parent.

Specified by:
get in interface Context
Parameters:
name - The variable name
Returns:
Object The variable value
See Also:
Context.get(java.lang.String)

has

public boolean has(String name)
Check if this variable exists, delegating to parent.

Specified by:
has in interface Context
Parameters:
name - The variable name
Returns:
boolean true if this variable exists
See Also:
Context.has(java.lang.String)

reset

public void reset()
Clear this Context.

Specified by:
reset in interface Context
See Also:
Context.reset()

getParent

public Context getParent()
Get the parent Context, may be null.

Specified by:
getParent in interface Context
Returns:
Context The parent Context
See Also:
Context.getParent()

setLocal

public void setLocal(String name,
                     Object value)
Assigns a new value to an existing variable or creates a new one. The method allows to shaddow a variable of the same name up the Context chain.

Specified by:
setLocal in interface Context
Parameters:
name - The variable name
value - The variable value
See Also:
Context.setLocal(String, Object)

setVars

protected void setVars(Map vars)
Set the variables map.

Parameters:
vars - The new Map of variables.

getVars

public Map getVars()
Get the Map of all local variables in this Context.

Specified by:
getVars in interface Context
Returns:
Returns the vars.
See Also:
Context.getParent()

setLog

protected void setLog(org.apache.commons.logging.Log log)
Set the log used by this Context instance.

Parameters:
log - The new log.

getLog

protected org.apache.commons.logging.Log getLog()
Get the log used by this Context instance.

Returns:
Log The log being used.


Copyright © 2005-2008 The Apache Software Foundation. All Rights Reserved.