commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hen...@apache.org
Subject svn commit: r1243028 - /commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/ObjectContext.java
Date Sat, 11 Feb 2012 11:22:24 GMT
Author: henrib
Date: Sat Feb 11 11:22:23 2012
New Revision: 1243028

URL: http://svn.apache.org/viewvc?rev=1243028&view=rev
Log:
JEXL-128; ObjectContext implements VariableResolver

Modified:
    commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/ObjectContext.java

Modified: commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/ObjectContext.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/ObjectContext.java?rev=1243028&r1=1243027&r2=1243028&view=diff
==============================================================================
--- commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/ObjectContext.java (original)
+++ commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/ObjectContext.java Sat
Feb 11 11:22:23 2012
@@ -17,15 +17,15 @@
 package org.apache.commons.jexl3;
 
 /**
- * Wraps an Object as a Jexl context.
+ * Wraps an Object as a Jexl context and NamespaceResolver.
  * @param <T> the wrapped object type to use
  * @since 3.0
  */
-public class ObjectContext<T> implements JexlContext {
+public class ObjectContext<T> implements JexlContext, JexlContext.NamespaceResolver
{
     /** The property solving jexl engine. */
     private final JexlEngine jexl;
     /** The object serving as context provider. */
-    private final T object;
+    protected final T object;
 
     /**
      * Creates a new ObjectContext.
@@ -51,4 +51,13 @@ public class ObjectContext<T> implements
     public boolean has(String name) {
         return jexl.getUberspect().getPropertyGet(object, name) != null;
     }
+
+    @Override
+    public Object resolveNamespace(String name) {
+        if (name == null || name.isEmpty()) {
+            return object;
+        } else {
+            return null;
+        }
+    }
 }



Mime
View raw message