Author: tschneider
Date: Sun Nov  4 13:56:45 2007
New Revision: 591846

URL: http://svn.apache.org/viewvc?rev=591846&view=rev
Log:
Adding javadoc and filling out the implementation

Modified:
    
struts/sandbox/trunk/struts2-juel-plugin/src/main/java/com/googlecode/struts2juel/CompoundRootELContext.java
    
struts/sandbox/trunk/struts2-juel-plugin/src/main/java/com/googlecode/struts2juel/CompoundRootVariableMapper.java
    
struts/sandbox/trunk/struts2-juel-plugin/src/main/java/com/googlecode/struts2juel/JuelReflectionContextFactory.java
    
struts/sandbox/trunk/struts2-juel-plugin/src/main/java/com/googlecode/struts2juel/JuelReflectionProvider.java
    
struts/sandbox/trunk/struts2-juel-plugin/src/main/java/com/googlecode/struts2juel/JuelValueStack.java
    
struts/sandbox/trunk/struts2-juel-plugin/src/main/java/com/googlecode/struts2juel/JuelValueStackFactory.java
    
struts/sandbox/trunk/struts2-juel-plugin/src/main/java/com/googlecode/struts2juel/PropertyValueExpression.java

Modified: 
struts/sandbox/trunk/struts2-juel-plugin/src/main/java/com/googlecode/struts2juel/CompoundRootELContext.java
URL: 
http://svn.apache.org/viewvc/struts/sandbox/trunk/struts2-juel-plugin/src/main/java/com/googlecode/struts2juel/CompoundRootELContext.java?rev=591846&r1=591845&r2=591846&view=diff
==============================================================================
--- 
struts/sandbox/trunk/struts2-juel-plugin/src/main/java/com/googlecode/struts2juel/CompoundRootELContext.java
 (original)
+++ 
struts/sandbox/trunk/struts2-juel-plugin/src/main/java/com/googlecode/struts2juel/CompoundRootELContext.java
 Sun Nov  4 13:56:45 2007
@@ -6,6 +6,9 @@
 
 import de.odysseus.el.util.SimpleContext;
 
+/**
+ * An implementation of SimpleContext that knows about the CompoundRoot.
+ */
 public class CompoundRootELContext extends SimpleContext {
     private VariableMapper variableMapper;
 

Modified: 
struts/sandbox/trunk/struts2-juel-plugin/src/main/java/com/googlecode/struts2juel/CompoundRootVariableMapper.java
URL: 
http://svn.apache.org/viewvc/struts/sandbox/trunk/struts2-juel-plugin/src/main/java/com/googlecode/struts2juel/CompoundRootVariableMapper.java?rev=591846&r1=591845&r2=591846&view=diff
==============================================================================
--- 
struts/sandbox/trunk/struts2-juel-plugin/src/main/java/com/googlecode/struts2juel/CompoundRootVariableMapper.java
 (original)
+++ 
struts/sandbox/trunk/struts2-juel-plugin/src/main/java/com/googlecode/struts2juel/CompoundRootVariableMapper.java
 Sun Nov  4 13:56:45 2007
@@ -1,12 +1,20 @@
 package com.googlecode.struts2juel;
 
+import java.util.HashMap;
+import java.util.Map;
+
 import javax.el.ValueExpression;
 import javax.el.VariableMapper;
 
 import org.apache.commons.beanutils.PropertyUtils;
 
+import sun.reflect.generics.reflectiveObjects.NotImplementedException;
+
 import com.opensymphony.xwork2.util.CompoundRoot;
 
+/**
+ * Implementation of VariableMapper based on a CompoundRoot.
+ */
 public class CompoundRootVariableMapper extends VariableMapper {
     private CompoundRoot root;
     
@@ -30,8 +38,7 @@
 
     @Override
     public ValueExpression setVariable(String variable, ValueExpression 
valueExpression) {
-        // TODO Auto-generated method stub
-        return null;
+        throw new RuntimeException("Method not implemented!");
     }
 
 }

Modified: 
struts/sandbox/trunk/struts2-juel-plugin/src/main/java/com/googlecode/struts2juel/JuelReflectionContextFactory.java
URL: 
http://svn.apache.org/viewvc/struts/sandbox/trunk/struts2-juel-plugin/src/main/java/com/googlecode/struts2juel/JuelReflectionContextFactory.java?rev=591846&r1=591845&r2=591846&view=diff
==============================================================================
--- 
struts/sandbox/trunk/struts2-juel-plugin/src/main/java/com/googlecode/struts2juel/JuelReflectionContextFactory.java
 (original)
+++ 
struts/sandbox/trunk/struts2-juel-plugin/src/main/java/com/googlecode/struts2juel/JuelReflectionContextFactory.java
 Sun Nov  4 13:56:45 2007
@@ -5,8 +5,10 @@
 
 import com.opensymphony.xwork2.util.reflection.ReflectionContextFactory;
 
+/**
+ * ReflectionContextFactory for Juel.
+ */
 public class JuelReflectionContextFactory implements ReflectionContextFactory {
-
     public Map createDefaultContext(Object root) {
         return new HashMap();
     }

Modified: 
struts/sandbox/trunk/struts2-juel-plugin/src/main/java/com/googlecode/struts2juel/JuelReflectionProvider.java
URL: 
http://svn.apache.org/viewvc/struts/sandbox/trunk/struts2-juel-plugin/src/main/java/com/googlecode/struts2juel/JuelReflectionProvider.java?rev=591846&r1=591845&r2=591846&view=diff
==============================================================================
--- 
struts/sandbox/trunk/struts2-juel-plugin/src/main/java/com/googlecode/struts2juel/JuelReflectionProvider.java
 (original)
+++ 
struts/sandbox/trunk/struts2-juel-plugin/src/main/java/com/googlecode/struts2juel/JuelReflectionProvider.java
 Sun Nov  4 13:56:45 2007
@@ -10,6 +10,9 @@
 import com.opensymphony.xwork2.util.CompoundRoot;
 import com.opensymphony.xwork2.util.reflection.ReflectionException;
 
+/**
+ * A OgnlReflectionProvider based on Juel.
+ */
 public class JuelReflectionProvider extends OgnlReflectionProvider {
     ExpressionFactory factory = new de.odysseus.el.ExpressionFactoryImpl();
 

Modified: 
struts/sandbox/trunk/struts2-juel-plugin/src/main/java/com/googlecode/struts2juel/JuelValueStack.java
URL: 
http://svn.apache.org/viewvc/struts/sandbox/trunk/struts2-juel-plugin/src/main/java/com/googlecode/struts2juel/JuelValueStack.java?rev=591846&r1=591845&r2=591846&view=diff
==============================================================================
--- 
struts/sandbox/trunk/struts2-juel-plugin/src/main/java/com/googlecode/struts2juel/JuelValueStack.java
 (original)
+++ 
struts/sandbox/trunk/struts2-juel-plugin/src/main/java/com/googlecode/struts2juel/JuelValueStack.java
 Sun Nov  4 13:56:45 2007
@@ -12,131 +12,143 @@
 import com.opensymphony.xwork2.util.CompoundRoot;
 import com.opensymphony.xwork2.util.ValueStack;
 
+/**
+ * A ValueStack that uses Juel as the underlying Expression Language.
+ */
 public class JuelValueStack implements ValueStack {
-    private CompoundRoot root = new CompoundRoot();
-    private transient Map context;
-    private Class defaultType;
-    private Map overrides;
-
-    ExpressionFactory factory = new de.odysseus.el.ExpressionFactoryImpl();
-
-    ELContext elContext;
-
-    public JuelValueStack() {
-        setRoot(new CompoundRoot());
-    }
-
-    public JuelValueStack(ValueStack vs) {
-        setRoot(new CompoundRoot(vs.getRoot()));
-    }
-
-    public String findString(String expr) {
-        return (String) findValue(expr, String.class);
-    }
-
-    public Object findValue(String expr) {
-        return findValue(expr, Object.class);
-    }
-
-    public Object findValue(String expr, Class asType) {
-        try {
-            if(expr != null && expr.startsWith("#")) {
-                int firstDot = expr.indexOf('.');
-                String key = expr.substring(1, firstDot);
-                String value = expr.substring(firstDot + 1);
-                Map map = (Map) context.get(key);
-                return map.get(value);
-            }
-            if(expr != null && expr.startsWith("%{")) {
-                // replace %{ with ${
-                expr = expr.substring(1);
-            }
-            if(expr != null && !expr.startsWith("${")) {
-                expr = "${" + expr + "}";
-            }
-            // parse our expression
-            ValueExpression valueExpr = factory.createValueExpression(
-                elContext, expr, asType);
-            Object retVal = valueExpr.getValue(elContext);
-            return retVal;
-        } catch(PropertyNotFoundException e) {
-            // property not found
-            return null;
-        } catch(ELException e) {
-            // fail silently so we don't mess things up
-            return null;
-        }
-    }
-
-    public Map getContext() {
-        return context;
-    }
-
-    public Map getExprOverrides() {
-        return overrides;
-    }
-
-    public CompoundRoot getRoot() {
-        return root;
-    }
-
-    public Object peek() {
-        return root.peek();
-    }
-
-    public Object pop() {
-        return root.pop();
-    }
-
-    public void push(Object o) {
-        root.push(o);
-    }
-
-    public void set(String key, Object o) {
-        // TODO : what to do here?
-    }
-
-    public void setDefaultType(Class defaultType) {
-        this.defaultType = defaultType;
-    }
-
-    public void setExprOverrides(Map overrides) {
-        this.overrides = overrides;
-    }
-
-    public void setValue(String expr, Object value) {
-        setValue(expr, value, false);
-    }
-
-    public void setValue(String expr, Object value,
-        boolean throwExceptionOnFailure) {
-        try {
-            if(expr != null && !expr.startsWith("${")) {
-                expr = "${" + expr + "}";
-            }
-            if(value != null && value instanceof String[]
-                && ((String[]) value).length == 1) {
-                value = ((String[]) value)[0];
-            }
-            // parse our expression
-            ValueExpression valueExpr = factory.createValueExpression(
-                elContext, expr, Object.class);
-            valueExpr.setValue(elContext, value);
-        } catch(ELException e) {
-            if(throwExceptionOnFailure) {
-                throw e;
-            }
-        }
-    }
-
-    public int size() {
-        return root.size();
-    }
-
-    protected void setRoot(CompoundRoot root) {
-        this.context = new TreeMap();
-        context.put(VALUE_STACK, this);
-        this.root = root;
-        this.elContext = new CompoundRootELContext(root);
-    }
+       private CompoundRoot root = new CompoundRoot();
+       private transient Map context;
+       private Class defaultType;
+       private Map overrides;
+
+       private ExpressionFactory factory = new 
de.odysseus.el.ExpressionFactoryImpl();
+
+       private ELContext elContext;
+
+       public JuelValueStack() {
+               setRoot(new CompoundRoot());
+       }
+
+       public JuelValueStack(ValueStack vs) {
+               setRoot(new CompoundRoot(vs.getRoot()));
+       }
+
+       public String findString(String expr) {
+               return (String) findValue(expr, String.class);
+       }
+
+       public Object findValue(String expr) {
+               return findValue(expr, Object.class);
+       }
+
+       public Object findValue(String expr, Class asType) {
+               try {
+                       if (expr != null && expr.startsWith("#")) {
+                               int firstDot = expr.indexOf('.');
+                               String key = expr.substring(1, firstDot);
+                               String value = expr.substring(firstDot + 1);
+                               Map map = (Map) context.get(key);
+                               return map.get(value);
+                       }
+                       if ((overrides != null) && overrides.containsKey(expr)) 
{
+                               expr = (String) overrides.get(expr);
+                       }
+                       if (expr != null && expr.startsWith("%{")) {
+                               // replace %{ with ${
+                               expr = "$" + expr.substring(1);
+                       }
+                       if (expr != null && !expr.startsWith("${")) {
+                               expr = "${" + expr + "}";
+                       }
+                       // parse our expression
+                       ValueExpression valueExpr = 
factory.createValueExpression(
+                                       elContext, expr, asType);
+                       Object retVal = valueExpr.getValue(elContext);
+                       return retVal;
+               } catch (PropertyNotFoundException e) {
+                       // property not found
+                       return null;
+               } catch (ELException e) {
+                       // fail silently so we don't mess things up
+                       return null;
+               }
+       }
+
+       public Map getContext() {
+               return context;
+       }
+
+       public Map getExprOverrides() {
+               return overrides;
+       }
+
+       public CompoundRoot getRoot() {
+               return root;
+       }
+
+       public Object peek() {
+               return root.peek();
+       }
+
+       public Object pop() {
+               return root.pop();
+       }
+
+       public void push(Object o) {
+               root.push(o);
+       }
+
+       public void setDefaultType(Class defaultType) {
+               this.defaultType = defaultType;
+       }
+
+       public void setExprOverrides(Map overrides) {
+               if (this.overrides == null) {
+                       this.overrides = overrides;
+               } else {
+                       this.overrides.putAll(overrides);
+               }
+       }
+
+       public void set(String key, Object o) {
+               overrides.put(key, o);
+       }
+
+       public void setValue(String expr, Object value) {
+               setValue(expr, value, false);
+       }
+
+       public void setValue(String expr, Object value,
+                       boolean throwExceptionOnFailure) {
+               try {
+                       if (expr != null && !expr.startsWith("${")) {
+                               expr = "${" + expr + "}";
+                       }
+                       // hack to allow parameters to be set back
+                       // juel doesn't support setting String[] values on 
String properties
+                       if (value != null && value instanceof String[]
+                                       && ((String[]) value).length == 1) {
+                               value = ((String[]) value)[0];
+                       }
+                       // parse our expression
+                       ValueExpression valueExpr = 
factory.createValueExpression(
+                                       elContext, expr, Object.class);
+                       valueExpr.setValue(elContext, value);
+               } catch (ELException e) {
+                       if (throwExceptionOnFailure) {
+                               throw e;
+                       }
+               }
+       }
+
+       public int size() {
+               return root.size();
+       }
+
+       protected void setRoot(CompoundRoot root) {
+               this.context = new TreeMap();
+               context.put(VALUE_STACK, this);
+               this.root = root;
+               this.elContext = new CompoundRootELContext(root);
+       }
 }

Modified: 
struts/sandbox/trunk/struts2-juel-plugin/src/main/java/com/googlecode/struts2juel/JuelValueStackFactory.java
URL: 
http://svn.apache.org/viewvc/struts/sandbox/trunk/struts2-juel-plugin/src/main/java/com/googlecode/struts2juel/JuelValueStackFactory.java?rev=591846&r1=591845&r2=591846&view=diff
==============================================================================
--- 
struts/sandbox/trunk/struts2-juel-plugin/src/main/java/com/googlecode/struts2juel/JuelValueStackFactory.java
 (original)
+++ 
struts/sandbox/trunk/struts2-juel-plugin/src/main/java/com/googlecode/struts2juel/JuelValueStackFactory.java
 Sun Nov  4 13:56:45 2007
@@ -3,6 +3,9 @@
 import com.opensymphony.xwork2.util.ValueStack;
 import com.opensymphony.xwork2.util.ValueStackFactory;
 
+/**
+ * Creates JuelValueStacks.
+ */
 public class JuelValueStackFactory implements ValueStackFactory {
 
     public ValueStack createValueStack() {

Modified: 
struts/sandbox/trunk/struts2-juel-plugin/src/main/java/com/googlecode/struts2juel/PropertyValueExpression.java
URL: 
http://svn.apache.org/viewvc/struts/sandbox/trunk/struts2-juel-plugin/src/main/java/com/googlecode/struts2juel/PropertyValueExpression.java?rev=591846&r1=591845&r2=591846&view=diff
==============================================================================
--- 
struts/sandbox/trunk/struts2-juel-plugin/src/main/java/com/googlecode/struts2juel/PropertyValueExpression.java
 (original)
+++ 
struts/sandbox/trunk/struts2-juel-plugin/src/main/java/com/googlecode/struts2juel/PropertyValueExpression.java
 Sun Nov  4 13:56:45 2007
@@ -7,96 +7,100 @@
 
 import org.apache.commons.beanutils.PropertyUtils;
 
+/**
+ * A value expression that uses a javabean as the root of the value expression.
+ */
 public class PropertyValueExpression extends ValueExpression {
-    private Object object;
-    private String property;
-    
-    public PropertyValueExpression(Object object, String property) {
-        this.object = object;
-        this.property = property;
-    }
-
-    @Override
-    public Class<?> getExpectedType() {
-        try {
-            return PropertyUtils.getPropertyType(object, property);
-        } catch(IllegalAccessException e) {
-            throw new RuntimeException(e);
-        } catch(InvocationTargetException e) {
-            throw new RuntimeException(e);
-        } catch(NoSuchMethodException e) {
-            throw new RuntimeException(e);
-        }
-    }
-
-    @Override
-    public Class<?> getType(ELContext arg0) {
-        try {
-            return PropertyUtils.getPropertyType(object, property);
-        } catch(IllegalAccessException e) {
-            throw new RuntimeException(e);
-        } catch(InvocationTargetException e) {
-            throw new RuntimeException(e);
-        } catch(NoSuchMethodException e) {
-            throw new RuntimeException(e);
-        }
-    }
-
-    @Override
-    public Object getValue(ELContext arg0) {
-        try {
-            return PropertyUtils.getSimpleProperty(object, property);
-        } catch(IllegalAccessException e) {
-            throw new RuntimeException(e);
-        } catch(InvocationTargetException e) {
-            throw new RuntimeException(e);
-        } catch(NoSuchMethodException e) {
-            throw new RuntimeException(e);
-        }
-    }
-
-    @Override
-    public boolean isReadOnly(ELContext arg0) {
-        return PropertyUtils.isWriteable(object, property);
-    }
-
-    @Override
-    public void setValue(ELContext arg0, Object obj) {
-        try {
-            PropertyUtils.setSimpleProperty(object, property, obj);
-        } catch(IllegalAccessException e) {
-            throw new RuntimeException(e);
-        } catch(InvocationTargetException e) {
-            throw new RuntimeException(e);
-        } catch(NoSuchMethodException e) {
-            throw new RuntimeException(e);
-        }
-    }
-
-    @Override
-    public boolean equals(Object otherObject) {
-        if (otherObject != null && otherObject.getClass() == getClass()) {
-                PropertyValueExpression other = 
(PropertyValueExpression)otherObject;
-                if (property != other.property) {
-                        return false;
-                }
-                return object == other.object || object != null && 
object.equals(other.object);
-        }
-        return false;
-    }
-
-    @Override
-    public String getExpressionString() {
-        return null;
-    }
-
-    @Override
-    public int hashCode() {
-        return property.hashCode();
-    }
-
-    @Override
-    public boolean isLiteralText() {
-        return false;
-    }
+       private Object object;
+       private String property;
+
+       public PropertyValueExpression(Object object, String property) {
+               this.object = object;
+               this.property = property;
+       }
+
+       @Override
+       public Class<?> getExpectedType() {
+               try {
+                       return PropertyUtils.getPropertyType(object, property);
+               } catch (IllegalAccessException e) {
+                       throw new RuntimeException(e);
+               } catch (InvocationTargetException e) {
+                       throw new RuntimeException(e);
+               } catch (NoSuchMethodException e) {
+                       throw new RuntimeException(e);
+               }
+       }
+
+       @Override
+       public Class<?> getType(ELContext arg0) {
+               try {
+                       return PropertyUtils.getPropertyType(object, property);
+               } catch (IllegalAccessException e) {
+                       throw new RuntimeException(e);
+               } catch (InvocationTargetException e) {
+                       throw new RuntimeException(e);
+               } catch (NoSuchMethodException e) {
+                       throw new RuntimeException(e);
+               }
+       }
+
+       @Override
+       public Object getValue(ELContext arg0) {
+               try {
+                       return PropertyUtils.getSimpleProperty(object, 
property);
+               } catch (IllegalAccessException e) {
+                       throw new RuntimeException(e);
+               } catch (InvocationTargetException e) {
+                       throw new RuntimeException(e);
+               } catch (NoSuchMethodException e) {
+                       throw new RuntimeException(e);
+               }
+       }
+
+       @Override
+       public boolean isReadOnly(ELContext arg0) {
+               return PropertyUtils.isWriteable(object, property);
+       }
+
+       @Override
+       public void setValue(ELContext arg0, Object obj) {
+               try {
+                       PropertyUtils.setSimpleProperty(object, property, obj);
+               } catch (IllegalAccessException e) {
+                       throw new RuntimeException(e);
+               } catch (InvocationTargetException e) {
+                       throw new RuntimeException(e);
+               } catch (NoSuchMethodException e) {
+                       throw new RuntimeException(e);
+               }
+       }
+
+       @Override
+       public boolean equals(Object otherObject) {
+               if (otherObject != null && otherObject.getClass() == 
getClass()) {
+                       PropertyValueExpression other = 
(PropertyValueExpression) otherObject;
+                       if (property != other.property) {
+                               return false;
+                       }
+                       return object == other.object || object != null
+                                       && object.equals(other.object);
+               }
+               return false;
+       }
+
+       @Override
+       public String getExpressionString() {
+               return property;
+       }
+
+       @Override
+       public int hashCode() {
+               return property.hashCode();
+       }
+
+       @Override
+       public boolean isLiteralText() {
+               return false;
+       }
 }


Reply via email to