You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by ra...@apache.org on 2005/10/09 06:54:37 UTC
svn commit: r307364 -
/jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml/env/jsp/ELContext.java
Author: rahul
Date: Sat Oct 8 21:54:35 2005
New Revision: 307364
URL: http://svn.apache.org/viewcvs?rev=307364&view=rev
Log:
Moved most of the implementation to a generic base class.
Modified:
jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml/env/jsp/ELContext.java
Modified: jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml/env/jsp/ELContext.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml/env/jsp/ELContext.java?rev=307364&r1=307363&r2=307364&view=diff
==============================================================================
--- jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml/env/jsp/ELContext.java (original)
+++ jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml/env/jsp/ELContext.java Sat Oct 8 21:54:35 2005
@@ -17,142 +17,33 @@
*/
package org.apache.commons.scxml.env.jsp;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
import javax.servlet.jsp.el.ELException;
import javax.servlet.jsp.el.VariableResolver;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.apache.commons.scxml.Context;
+import org.apache.commons.scxml.env.SimpleContext;
/**
* EL Context for SCXML interpreter.
*
*/
-public class ELContext implements Context , VariableResolver {
-
- /** Implementation independent log category. */
- protected static final Log LOG = LogFactory.getLog(Context.class);
- /** The parent Context to this Context. */
- protected Context parent = null;
- /** The Map of variables and their values in this Context. */
- protected Map vars = new HashMap();
+public class ELContext extends SimpleContext implements VariableResolver {
/**
* Constructor.
*
*/
public ELContext() {
- this(null);
+ super();
}
/**
* Constructor.
*
- * @param parent a parent ELContext, can be null
+ * @param parent A parent Context, can be null
*/
public ELContext(final Context parent) {
- this.parent = parent;
- }
-
- /**
- * Assigns a new value to an existing variable or creates a new one.
- * The method searches the chain of parent Contexts for variable
- * existence.
- *
- * @param name The variable name
- * @param value The variable value
- * @see org.apache.commons.scxml.Context#set(String, Object)
- */
- public void set(final String name, final Object value) {
- if (vars.containsKey(name)) { //first try to override local
- setLocal(name, value);
- } else if (parent != null && parent.has(name)) { //then check for global
- parent.set(name, value);
- } else { //otherwise create a new local variable
- setLocal(name, value);
- }
- }
-
- /**
- * Get the value of this variable; delegating to parent.
- *
- * @param name The variable name
- * @return Object The variable value
- * @see org.apache.commons.scxml.Context#get(java.lang.String)
- */
- public Object get(final String name) {
- if (vars.containsKey(name)) {
- return vars.get(name);
- } else if (parent != null) {
- return parent.get(name);
- } else {
- return null;
- }
- }
-
- /**
- * Check if this variable exists, delegating to parent.
- *
- * @param name The variable name
- * @return boolean true if this variable exists
- * @see org.apache.commons.scxml.Context#has(java.lang.String)
- */
- public boolean has(final String name) {
- if (vars.containsKey(name)) {
- return true;
- } else if (parent != null && parent.has(name)) {
- return true;
- }
- return false;
- }
-
- /**
- * Get an Iterator over all variables in this Context.
- *
- * @return Iterator The Iterator over all variables in this Context
- * @see org.apache.commons.scxml.Context#iterator()
- */
- public Iterator iterator() {
- return vars.entrySet().iterator();
- }
-
- /**
- * Clear this Context.
- *
- * @see org.apache.commons.scxml.Context#reset()
- */
- public void reset() {
- vars.clear();
- }
-
- /**
- * Get the parent Context, may be null.
- *
- * @return Context The parent Context
- * @see org.apache.commons.scxml.Context#getParent()
- */
- public Context getParent() {
- return parent;
- }
-
- /**
- * 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.
- *
- * @param name The variable name
- * @param value The variable value
- * @see org.apache.commons.scxml.Context#setLocal(String, Object)
- */
- public void setLocal(final String name, final Object value) {
- vars.put(name, value);
- if (LOG.isDebugEnabled() && !name.equals("_ALL_STATES")) {
- LOG.debug(name + " = " + String.valueOf(value));
- }
+ super(parent);
}
/**
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org