You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ibatis.apache.org by cb...@apache.org on 2009/01/23 07:32:46 UTC
svn commit: r736963 [7/21] - in /ibatis/trunk/java/ibatis-3:
ibatis-3-compat/src/main/java/com/ibatis/common/jdbc/
ibatis-3-compat/src/main/java/com/ibatis/common/resources/
ibatis-3-compat/src/main/java/com/ibatis/common/util/
ibatis-3-compat/src/main...
Modified: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/NullHandler.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/NullHandler.java?rev=736963&r1=736962&r2=736963&view=diff
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/NullHandler.java (original)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/NullHandler.java Thu Jan 22 22:32:36 2009
@@ -36,20 +36,20 @@
* Interface for handling null results from Chains.
* Object has the opportunity to substitute an object for the
* null and continue.
+ *
* @author Luke Blanshard (blanshlu@netscape.net)
* @author Drew Davidson (drew@ognl.org)
*/
-public interface NullHandler
-{
- /**
- Method called on target returned null.
- */
- public Object nullMethodResult(Map context, Object target, String methodName, Object[] args);
+public interface NullHandler {
+ /**
+ * Method called on target returned null.
+ */
+ public Object nullMethodResult(Map context, Object target, String methodName, Object[] args);
- /**
- Property in target evaluated to null. Property can be a constant
- String property name or a DynamicSubscript.
- */
- public Object nullPropertyValue(Map context, Object target, Object property);
+ /**
+ * Property in target evaluated to null. Property can be a constant
+ * String property name or a DynamicSubscript.
+ */
+ public Object nullPropertyValue(Map context, Object target, Object property);
}
Modified: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/NumberElementsAccessor.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/NumberElementsAccessor.java?rev=736963&r1=736962&r2=736963&view=diff
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/NumberElementsAccessor.java (original)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/NumberElementsAccessor.java Thu Jan 22 22:32:36 2009
@@ -30,32 +30,32 @@
//--------------------------------------------------------------------------
package org.apache.ibatis.ognl;
-import java.util.*;
+import java.util.Enumeration;
+import java.util.NoSuchElementException;
/**
* Implementation of ElementsAccessor that returns an iterator over integers from 0 up to
* the given target.
+ *
* @author Luke Blanshard (blanshlu@netscape.net)
* @author Drew Davidson (drew@ognl.org)
*/
-public class NumberElementsAccessor implements ElementsAccessor, NumericTypes
-{
- public Enumeration getElements( final Object target )
- {
- return new Enumeration() {
- private int type = OgnlOps.getNumericType( target );
- private long next = 0;
- private long finish = OgnlOps.longValue( target );
+public class NumberElementsAccessor implements ElementsAccessor, NumericTypes {
+ public Enumeration getElements(final Object target) {
+ return new Enumeration() {
+ private int type = OgnlOps.getNumericType(target);
+ private long next = 0;
+ private long finish = OgnlOps.longValue(target);
- public boolean hasMoreElements() {
- return next < finish;
- }
+ public boolean hasMoreElements() {
+ return next < finish;
+ }
- public Object nextElement() {
- if ( next >= finish )
- throw new NoSuchElementException();
- return OgnlOps.newInteger( type, next++ );
- }
- };
- }
+ public Object nextElement() {
+ if (next >= finish)
+ throw new NoSuchElementException();
+ return OgnlOps.newInteger(type, next++);
+ }
+ };
+ }
}
Modified: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/NumericTypes.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/NumericTypes.java?rev=736963&r1=736962&r2=736963&view=diff
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/NumericTypes.java (original)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/NumericTypes.java Thu Jan 22 22:32:36 2009
@@ -34,42 +34,64 @@
/**
* This interface defines some useful constants for describing the various possible
* numeric types of OGNL.
+ *
* @author Luke Blanshard (blanshlu@netscape.net)
* @author Drew Davidson (drew@ognl.org)
*/
-public interface NumericTypes
-{
- // Order does matter here... see the getNumericType methods in ognl.g.
+public interface NumericTypes {
+ // Order does matter here... see the getNumericType methods in ognl.g.
- /** Type tag meaning boolean. */
- int BOOL = 0;
- /** Type tag meaning byte. */
- int BYTE = 1;
- /** Type tag meaning char. */
- int CHAR = 2;
- /** Type tag meaning short. */
- int SHORT = 3;
- /** Type tag meaning int. */
- int INT = 4;
- /** Type tag meaning long. */
- int LONG = 5;
- /** Type tag meaning java.math.BigInteger. */
- int BIGINT = 6;
- /** Type tag meaning float. */
- int FLOAT = 7;
- /** Type tag meaning double. */
- int DOUBLE = 8;
- /** Type tag meaning java.math.BigDecimal. */
- int BIGDEC = 9;
- /** Type tag meaning something other than a number. */
- int NONNUMERIC = 10;
+ /**
+ * Type tag meaning boolean.
+ */
+ int BOOL = 0;
+ /**
+ * Type tag meaning byte.
+ */
+ int BYTE = 1;
+ /**
+ * Type tag meaning char.
+ */
+ int CHAR = 2;
+ /**
+ * Type tag meaning short.
+ */
+ int SHORT = 3;
+ /**
+ * Type tag meaning int.
+ */
+ int INT = 4;
+ /**
+ * Type tag meaning long.
+ */
+ int LONG = 5;
+ /**
+ * Type tag meaning java.math.BigInteger.
+ */
+ int BIGINT = 6;
+ /**
+ * Type tag meaning float.
+ */
+ int FLOAT = 7;
+ /**
+ * Type tag meaning double.
+ */
+ int DOUBLE = 8;
+ /**
+ * Type tag meaning java.math.BigDecimal.
+ */
+ int BIGDEC = 9;
+ /**
+ * Type tag meaning something other than a number.
+ */
+ int NONNUMERIC = 10;
- /**
- * The smallest type tag that represents reals as opposed to integers. You can see
- * whether a type tag represents reals or integers by comparing the tag to this
- * constant: all tags less than this constant represent integers, and all tags
- * greater than or equal to this constant represent reals. Of course, you must also
- * check for NONNUMERIC, which means it is not a number at all.
+ /**
+ * The smallest type tag that represents reals as opposed to integers. You can see
+ * whether a type tag represents reals or integers by comparing the tag to this
+ * constant: all tags less than this constant represent integers, and all tags
+ * greater than or equal to this constant represent reals. Of course, you must also
+ * check for NONNUMERIC, which means it is not a number at all.
*/
int MIN_REAL_TYPE = FLOAT;
}
Modified: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ObjectArrayPool.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ObjectArrayPool.java?rev=736963&r1=736962&r2=736963&view=diff
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ObjectArrayPool.java (original)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ObjectArrayPool.java Thu Jan 22 22:32:36 2009
@@ -30,186 +30,167 @@
//--------------------------------------------------------------------------
package org.apache.ibatis.ognl;
-import java.util.*;
-
-public final class ObjectArrayPool extends Object
-{
- private IntHashMap pools = new IntHashMap(23);
-
- public static class SizePool extends Object
- {
- private List arrays = new ArrayList();
- private int arraySize;
- private int size;
- private int created = 0;
- private int recovered = 0;
- private int recycled = 0;
-
- public SizePool(int arraySize)
- {
- this(arraySize, 0);
- }
-
- public SizePool(int arraySize, int initialSize)
- {
- super();
- this.arraySize = arraySize;
- for (int i = 0; i < initialSize; i++) {
- arrays.add(new Object[arraySize]);
- }
- created = size = initialSize;
- }
-
- public int getArraySize()
- {
- return arraySize;
- }
-
- public Object[] create()
- {
- Object[] result;
-
- if (size > 0) {
- result = (Object[])arrays.remove(size - 1);
- size--;
- recovered++;
- } else {
- result = new Object[arraySize];
- created++;
- }
- return result;
- }
-
- public synchronized void recycle(Object[] value)
- {
- if (value != null) {
- if (value.length != arraySize) {
- throw new IllegalArgumentException("recycled array size " + value.length + " inappropriate for pool array size " + arraySize);
- }
- Arrays.fill(value, null);
- arrays.add(value);
- size++;
- recycled++;
- } else {
- throw new IllegalArgumentException("cannot recycle null object");
- }
- }
-
- /**
- Returns the number of items in the pool
- */
- public int getSize()
- {
- return size;
- }
-
- /**
- Returns the number of items this pool has created since
- it's construction.
- */
- public int getCreatedCount()
- {
- return created;
- }
-
- /**
- Returns the number of items this pool has recovered from
- the pool since its construction.
- */
- public int getRecoveredCount()
- {
- return recovered;
- }
-
- /**
- Returns the number of items this pool has recycled since
- it's construction.
- */
- public int getRecycledCount()
- {
- return recycled;
- }
- }
-
- public ObjectArrayPool()
- {
- super();
- }
-
- public IntHashMap getSizePools()
- {
- return pools;
- }
-
- public synchronized SizePool getSizePool(int arraySize)
- {
- SizePool result = (SizePool)pools.get(arraySize);
-
- if (result == null) {
- pools.put(arraySize, result = new SizePool(arraySize));
- }
- return result;
- }
-
- public synchronized Object[] create(int arraySize)
- {
- return getSizePool(arraySize).create();
- }
-
- public synchronized Object[] create(Object singleton)
- {
- Object[] result = create(1);
-
- result[0] = singleton;
- return result;
- }
-
- public synchronized Object[] create(Object object1, Object object2)
- {
- Object[] result = create(2);
-
- result[0] = object1;
- result[1] = object2;
- return result;
- }
-
- public synchronized Object[] create(Object object1, Object object2, Object object3)
- {
- Object[] result = create(3);
-
- result[0] = object1;
- result[1] = object2;
- result[2] = object3;
- return result;
- }
-
- public synchronized Object[] create(Object object1, Object object2, Object object3, Object object4)
- {
- Object[] result = create(4);
-
- result[0] = object1;
- result[1] = object2;
- result[2] = object3;
- result[3] = object4;
- return result;
- }
-
- public synchronized Object[] create(Object object1, Object object2, Object object3, Object object4, Object object5)
- {
- Object[] result = create(5);
-
- result[0] = object1;
- result[1] = object2;
- result[2] = object3;
- result[3] = object4;
- result[4] = object5;
- return result;
- }
-
- public synchronized void recycle(Object[] value)
- {
- if (value != null) {
- getSizePool(value.length).recycle(value);
- }
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+public final class ObjectArrayPool extends Object {
+ private IntHashMap pools = new IntHashMap(23);
+
+ public static class SizePool extends Object {
+ private List arrays = new ArrayList();
+ private int arraySize;
+ private int size;
+ private int created = 0;
+ private int recovered = 0;
+ private int recycled = 0;
+
+ public SizePool(int arraySize) {
+ this(arraySize, 0);
+ }
+
+ public SizePool(int arraySize, int initialSize) {
+ super();
+ this.arraySize = arraySize;
+ for (int i = 0; i < initialSize; i++) {
+ arrays.add(new Object[arraySize]);
+ }
+ created = size = initialSize;
+ }
+
+ public int getArraySize() {
+ return arraySize;
+ }
+
+ public Object[] create() {
+ Object[] result;
+
+ if (size > 0) {
+ result = (Object[]) arrays.remove(size - 1);
+ size--;
+ recovered++;
+ } else {
+ result = new Object[arraySize];
+ created++;
+ }
+ return result;
+ }
+
+ public synchronized void recycle(Object[] value) {
+ if (value != null) {
+ if (value.length != arraySize) {
+ throw new IllegalArgumentException("recycled array size " + value.length + " inappropriate for pool array size " + arraySize);
+ }
+ Arrays.fill(value, null);
+ arrays.add(value);
+ size++;
+ recycled++;
+ } else {
+ throw new IllegalArgumentException("cannot recycle null object");
+ }
+ }
+
+ /**
+ * Returns the number of items in the pool
+ */
+ public int getSize() {
+ return size;
+ }
+
+ /**
+ * Returns the number of items this pool has created since
+ * it's construction.
+ */
+ public int getCreatedCount() {
+ return created;
+ }
+
+ /**
+ * Returns the number of items this pool has recovered from
+ * the pool since its construction.
+ */
+ public int getRecoveredCount() {
+ return recovered;
+ }
+
+ /**
+ * Returns the number of items this pool has recycled since
+ * it's construction.
+ */
+ public int getRecycledCount() {
+ return recycled;
+ }
+ }
+
+ public ObjectArrayPool() {
+ super();
+ }
+
+ public IntHashMap getSizePools() {
+ return pools;
+ }
+
+ public synchronized SizePool getSizePool(int arraySize) {
+ SizePool result = (SizePool) pools.get(arraySize);
+
+ if (result == null) {
+ pools.put(arraySize, result = new SizePool(arraySize));
+ }
+ return result;
+ }
+
+ public synchronized Object[] create(int arraySize) {
+ return getSizePool(arraySize).create();
+ }
+
+ public synchronized Object[] create(Object singleton) {
+ Object[] result = create(1);
+
+ result[0] = singleton;
+ return result;
+ }
+
+ public synchronized Object[] create(Object object1, Object object2) {
+ Object[] result = create(2);
+
+ result[0] = object1;
+ result[1] = object2;
+ return result;
+ }
+
+ public synchronized Object[] create(Object object1, Object object2, Object object3) {
+ Object[] result = create(3);
+
+ result[0] = object1;
+ result[1] = object2;
+ result[2] = object3;
+ return result;
+ }
+
+ public synchronized Object[] create(Object object1, Object object2, Object object3, Object object4) {
+ Object[] result = create(4);
+
+ result[0] = object1;
+ result[1] = object2;
+ result[2] = object3;
+ result[3] = object4;
+ return result;
+ }
+
+ public synchronized Object[] create(Object object1, Object object2, Object object3, Object object4, Object object5) {
+ Object[] result = create(5);
+
+ result[0] = object1;
+ result[1] = object2;
+ result[2] = object3;
+ result[3] = object4;
+ result[4] = object5;
+ return result;
+ }
+
+ public synchronized void recycle(Object[] value) {
+ if (value != null) {
+ getSizePool(value.length).recycle(value);
}
+ }
}
Modified: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ObjectElementsAccessor.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ObjectElementsAccessor.java?rev=736963&r1=736962&r2=736963&view=diff
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ObjectElementsAccessor.java (original)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ObjectElementsAccessor.java Thu Jan 22 22:32:36 2009
@@ -30,36 +30,35 @@
//--------------------------------------------------------------------------
package org.apache.ibatis.ognl;
-import java.util.*;
+import java.util.Enumeration;
/**
* Implementation of ElementsAccessor that returns a single-element iterator, containing
* the original target object.
+ *
* @author Luke Blanshard (blanshlu@netscape.net)
* @author Drew Davidson (drew@ognl.org)
*/
-public class ObjectElementsAccessor implements ElementsAccessor
-{
- public Enumeration getElements( Object target )
- {
- final Object object = target;
-
- return new Enumeration() {
- private boolean seen = false;
-
- public boolean hasMoreElements() {
- return !seen;
- }
-
- public Object nextElement() {
- Object result = null;
-
- if (!seen) {
- result = object;
- seen = true;
- }
- return result;
- }
- };
- }
+public class ObjectElementsAccessor implements ElementsAccessor {
+ public Enumeration getElements(Object target) {
+ final Object object = target;
+
+ return new Enumeration() {
+ private boolean seen = false;
+
+ public boolean hasMoreElements() {
+ return !seen;
+ }
+
+ public Object nextElement() {
+ Object result = null;
+
+ if (!seen) {
+ result = object;
+ seen = true;
+ }
+ return result;
+ }
+ };
+ }
}
Modified: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ObjectIndexedPropertyDescriptor.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ObjectIndexedPropertyDescriptor.java?rev=736963&r1=736962&r2=736963&view=diff
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ObjectIndexedPropertyDescriptor.java (original)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ObjectIndexedPropertyDescriptor.java Thu Jan 22 22:32:36 2009
@@ -30,8 +30,9 @@
//--------------------------------------------------------------------------
package org.apache.ibatis.ognl;
-import java.beans.*;
-import java.lang.reflect.*;
+import java.beans.IntrospectionException;
+import java.beans.PropertyDescriptor;
+import java.lang.reflect.Method;
/**
* <p>PropertyDescriptor subclass that describes an indexed set of read/write
@@ -39,85 +40,81 @@
* the "key" to be an arbitrary object rather than just an int. Consequently
* it does not have a "readMethod" or "writeMethod" because it only expects
* a pattern like:</p>
- *<pre>
+ * <pre>
* public void set<i>Property</i>(<i>KeyType</i>, <i>ValueType</i>);
* public <i>ValueType</i> get<i>Property</i>(<i>KeyType</i>);
- *</pre>
+ * </pre>
* <p>and does not require the methods that access it as an array. OGNL can
* get away with this without losing functionality because if the object
* does expose the properties they are most probably in a Map and that case
* is handled by the normal OGNL property accessors.
- *</p>
- *<p>For example, if an object were to have methods that accessed and "attributes"
+ * </p>
+ * <p>For example, if an object were to have methods that accessed and "attributes"
* property it would be natural to index them by String rather than by integer
* and expose the attributes as a map with a different property name:
- *<pre>
+ * <pre>
* public void setAttribute(String name, Object value);
* public Object getAttribute(String name);
* public Map getAttributes();
- *</pre>
- *<p>Note that the index get/set is called get/set <code>Attribute</code>
+ * </pre>
+ * <p>Note that the index get/set is called get/set <code>Attribute</code>
* whereas the collection getter is called <code>Attributes</code>. This
* case is handled unambiguously by the OGNL property accessors because the
* set/get<code>Attribute</code> methods are detected by this object and the
* "attributes" case is handled by the <code>MapPropertyAccessor</code>.
* Therefore OGNL expressions calling this code would be handled in the
* following way:
- *</p>
- *<table>
- * <tr><th>OGNL Expression</th>
- * <th>Handling</th>
- * </tr>
- * <tr>
- * <td><code>attribute["name"]</code></td>
- * <td>Handled by an index getter, like <code>getAttribute(String)</code>.</td>
- * </tr>
- * <tr>
- * <td><code>attribute["name"] = value</code></td>
- * <td>Handled by an index setter, like <code>setAttribute(String, Object)</code>.</td>
- * </tr>
- * <tr>
- * <td><code>attributes["name"]</code></td>
- * <td>Handled by <code>MapPropertyAccessor</code> via a <code>Map.get()</code>. This
- * will <b>not</b> go through the index get accessor.
- * </td>
- * </tr>
- * <tr>
- * <td><code>attributes["name"] = value</code></td>
- * <td>Handled by <code>MapPropertyAccessor</code> via a <code>Map.put()</code>. This
- * will <b>not</b> go through the index set accessor.
- * </td>
- * </tr>
+ * </p>
+ * <table>
+ * <tr><th>OGNL Expression</th>
+ * <th>Handling</th>
+ * </tr>
+ * <tr>
+ * <td><code>attribute["name"]</code></td>
+ * <td>Handled by an index getter, like <code>getAttribute(String)</code>.</td>
+ * </tr>
+ * <tr>
+ * <td><code>attribute["name"] = value</code></td>
+ * <td>Handled by an index setter, like <code>setAttribute(String, Object)</code>.</td>
+ * </tr>
+ * <tr>
+ * <td><code>attributes["name"]</code></td>
+ * <td>Handled by <code>MapPropertyAccessor</code> via a <code>Map.get()</code>. This
+ * will <b>not</b> go through the index get accessor.
+ * </td>
+ * </tr>
+ * <tr>
+ * <td><code>attributes["name"] = value</code></td>
+ * <td>Handled by <code>MapPropertyAccessor</code> via a <code>Map.put()</code>. This
+ * will <b>not</b> go through the index set accessor.
+ * </td>
+ * </tr>
* </table>
+ *
* @author Luke Blanshard (blanshlu@netscape.net)
* @author Drew Davidson (drew@ognl.org)
*/
-public class ObjectIndexedPropertyDescriptor extends PropertyDescriptor
-{
- private Method indexedReadMethod;
- private Method indexedWriteMethod;
- private Class propertyType;
-
- public ObjectIndexedPropertyDescriptor(String propertyName, Class propertyType, Method indexedReadMethod, Method indexedWriteMethod) throws IntrospectionException
- {
- super(propertyName, null, null);
- this.propertyType = propertyType;
- this.indexedReadMethod = indexedReadMethod;
- this.indexedWriteMethod = indexedWriteMethod;
- }
-
- public Method getIndexedReadMethod()
- {
- return indexedReadMethod;
- }
-
- public Method getIndexedWriteMethod()
- {
- return indexedWriteMethod;
- }
-
- public Class getPropertyType()
- {
- return propertyType;
- }
+public class ObjectIndexedPropertyDescriptor extends PropertyDescriptor {
+ private Method indexedReadMethod;
+ private Method indexedWriteMethod;
+ private Class propertyType;
+
+ public ObjectIndexedPropertyDescriptor(String propertyName, Class propertyType, Method indexedReadMethod, Method indexedWriteMethod) throws IntrospectionException {
+ super(propertyName, null, null);
+ this.propertyType = propertyType;
+ this.indexedReadMethod = indexedReadMethod;
+ this.indexedWriteMethod = indexedWriteMethod;
+ }
+
+ public Method getIndexedReadMethod() {
+ return indexedReadMethod;
+ }
+
+ public Method getIndexedWriteMethod() {
+ return indexedWriteMethod;
+ }
+
+ public Class getPropertyType() {
+ return propertyType;
+ }
}
Modified: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ObjectMethodAccessor.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ObjectMethodAccessor.java?rev=736963&r1=736962&r2=736963&view=diff
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ObjectMethodAccessor.java (original)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ObjectMethodAccessor.java Thu Jan 22 22:32:36 2009
@@ -30,34 +30,33 @@
//--------------------------------------------------------------------------
package org.apache.ibatis.ognl;
-import java.util.*;
+import java.util.List;
+import java.util.Map;
/**
* Implementation of PropertyAccessor that uses reflection on the target object's class to
* find a field or a pair of set/get methods with the given property name.
+ *
* @author Luke Blanshard (blanshlu@netscape.net)
* @author Drew Davidson (drew@ognl.org)
*/
-public class ObjectMethodAccessor implements MethodAccessor
-{
- /* MethodAccessor interface */
- public Object callStaticMethod( Map context, Class targetClass, String methodName, Object[] args ) throws MethodFailedException
- {
- List methods = OgnlRuntime.getMethods(targetClass, methodName, true);
+public class ObjectMethodAccessor implements MethodAccessor {
+ /* MethodAccessor interface */
+ public Object callStaticMethod(Map context, Class targetClass, String methodName, Object[] args) throws MethodFailedException {
+ List methods = OgnlRuntime.getMethods(targetClass, methodName, true);
- return OgnlRuntime.callAppropriateMethod( (OgnlContext)context, targetClass, null, methodName, null, methods, args );
- }
+ return OgnlRuntime.callAppropriateMethod((OgnlContext) context, targetClass, null, methodName, null, methods, args);
+ }
- public Object callMethod( Map context, Object target, String methodName, Object[] args ) throws MethodFailedException
- {
- Class targetClass = (target == null) ? null : target.getClass();
- Object source = target;
- List methods = OgnlRuntime.getMethods(targetClass, methodName, false);
+ public Object callMethod(Map context, Object target, String methodName, Object[] args) throws MethodFailedException {
+ Class targetClass = (target == null) ? null : target.getClass();
+ Object source = target;
+ List methods = OgnlRuntime.getMethods(targetClass, methodName, false);
- if ((methods == null) || (methods.size() == 0)) {
- methods = OgnlRuntime.getMethods(targetClass, methodName, true);
- source = targetClass;
- }
- return OgnlRuntime.callAppropriateMethod( (OgnlContext)context, target, target, methodName, null, methods, args );
+ if ((methods == null) || (methods.size() == 0)) {
+ methods = OgnlRuntime.getMethods(targetClass, methodName, true);
+ source = targetClass;
}
+ return OgnlRuntime.callAppropriateMethod((OgnlContext) context, target, target, methodName, null, methods, args);
+ }
}
Modified: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ObjectNullHandler.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ObjectNullHandler.java?rev=736963&r1=736962&r2=736963&view=diff
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ObjectNullHandler.java (original)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ObjectNullHandler.java Thu Jan 22 22:32:36 2009
@@ -30,24 +30,22 @@
//--------------------------------------------------------------------------
package org.apache.ibatis.ognl;
-import java.util.*;
+import java.util.Map;
/**
* Implementation of NullHandler that returns null in all cases,
* so that NullPointerException will be thrown by the caller.
+ *
* @author Luke Blanshard (blanshlu@netscape.net)
* @author Drew Davidson (drew@ognl.org)
*/
-public class ObjectNullHandler implements NullHandler
-{
- /* NullHandler interface */
- public Object nullMethodResult(Map context, Object target, String methodName, Object[] args)
- {
- return null;
- }
+public class ObjectNullHandler implements NullHandler {
+ /* NullHandler interface */
+ public Object nullMethodResult(Map context, Object target, String methodName, Object[] args) {
+ return null;
+ }
- public Object nullPropertyValue(Map context, Object target, Object property)
- {
- return null;
- }
+ public Object nullPropertyValue(Map context, Object target, Object property) {
+ return null;
+ }
}
Modified: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ObjectPropertyAccessor.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ObjectPropertyAccessor.java?rev=736963&r1=736962&r2=736963&view=diff
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ObjectPropertyAccessor.java (original)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/ObjectPropertyAccessor.java Thu Jan 22 22:32:36 2009
@@ -36,100 +36,92 @@
/**
* Implementation of PropertyAccessor that uses reflection on the target object's class to
* find a field or a pair of set/get methods with the given property name.
+ *
* @author Luke Blanshard (blanshlu@netscape.net)
* @author Drew Davidson (drew@ognl.org)
*/
-public class ObjectPropertyAccessor implements PropertyAccessor
-{
- /**
- Returns OgnlRuntime.NotFound if the property does not exist.
- */
- public Object getPossibleProperty( Map context, Object target, String name) throws OgnlException
- {
- Object result;
- OgnlContext ognlContext = (OgnlContext)context;
-
- try {
- if ((result = OgnlRuntime.getMethodValue(ognlContext, target, name, true)) == OgnlRuntime.NotFound) {
- result = OgnlRuntime.getFieldValue(ognlContext, target, name, true);
- }
- } catch (IntrospectionException ex) {
- throw new OgnlException(name, ex);
- } catch (OgnlException ex) {
- throw ex;
- } catch (Exception ex) {
- throw new OgnlException(name, ex);
- }
- return result;
- }
-
- /**
- Returns OgnlRuntime.NotFound if the property does not exist.
- */
- public Object setPossibleProperty( Map context, Object target, String name, Object value) throws OgnlException
- {
- Object result = null;
- OgnlContext ognlContext = (OgnlContext)context;
-
- try {
- if (!OgnlRuntime.setMethodValue(ognlContext, target, name, value, true)) {
- result = OgnlRuntime.setFieldValue(ognlContext, target, name, value) ? null : OgnlRuntime.NotFound;
- }
- } catch (IntrospectionException ex) {
- throw new OgnlException(name, ex);
- } catch (OgnlException ex) {
- throw ex;
- } catch (Exception ex) {
- throw new OgnlException(name, ex);
- }
- return result;
- }
-
- public boolean hasGetProperty( OgnlContext context, Object target, Object oname ) throws OgnlException
- {
- try {
- return OgnlRuntime.hasGetProperty( context, target, oname );
- } catch (IntrospectionException ex) {
- throw new OgnlException("checking if " + target + " has gettable property " + oname, ex);
- }
- }
-
- public boolean hasGetProperty( Map context, Object target, Object oname ) throws OgnlException
- {
- return hasGetProperty((OgnlContext)context, target, oname);
- }
-
- public boolean hasSetProperty( OgnlContext context, Object target, Object oname ) throws OgnlException
- {
- try {
- return OgnlRuntime.hasSetProperty( context, target, oname );
- } catch (IntrospectionException ex) {
- throw new OgnlException("checking if " + target + " has settable property " + oname, ex);
- }
- }
-
- public boolean hasSetProperty( Map context, Object target, Object oname ) throws OgnlException
- {
- return hasSetProperty((OgnlContext)context, target, oname);
- }
-
- public Object getProperty( Map context, Object target, Object oname ) throws OgnlException
- {
- Object result = null;
- String name = oname.toString();
-
- if ((result = getPossibleProperty(context, target, name)) == OgnlRuntime.NotFound) {
- throw new NoSuchPropertyException(target, name);
- }
- return result;
- }
-
- public void setProperty( Map context, Object target, Object oname, Object value ) throws OgnlException
- {
- String name = oname.toString();
-
- if (setPossibleProperty(context, target, name, value) == OgnlRuntime.NotFound) {
- throw new NoSuchPropertyException(target, name);
- }
+public class ObjectPropertyAccessor implements PropertyAccessor {
+ /**
+ * Returns OgnlRuntime.NotFound if the property does not exist.
+ */
+ public Object getPossibleProperty(Map context, Object target, String name) throws OgnlException {
+ Object result;
+ OgnlContext ognlContext = (OgnlContext) context;
+
+ try {
+ if ((result = OgnlRuntime.getMethodValue(ognlContext, target, name, true)) == OgnlRuntime.NotFound) {
+ result = OgnlRuntime.getFieldValue(ognlContext, target, name, true);
+ }
+ } catch (IntrospectionException ex) {
+ throw new OgnlException(name, ex);
+ } catch (OgnlException ex) {
+ throw ex;
+ } catch (Exception ex) {
+ throw new OgnlException(name, ex);
+ }
+ return result;
+ }
+
+ /**
+ * Returns OgnlRuntime.NotFound if the property does not exist.
+ */
+ public Object setPossibleProperty(Map context, Object target, String name, Object value) throws OgnlException {
+ Object result = null;
+ OgnlContext ognlContext = (OgnlContext) context;
+
+ try {
+ if (!OgnlRuntime.setMethodValue(ognlContext, target, name, value, true)) {
+ result = OgnlRuntime.setFieldValue(ognlContext, target, name, value) ? null : OgnlRuntime.NotFound;
+ }
+ } catch (IntrospectionException ex) {
+ throw new OgnlException(name, ex);
+ } catch (OgnlException ex) {
+ throw ex;
+ } catch (Exception ex) {
+ throw new OgnlException(name, ex);
+ }
+ return result;
+ }
+
+ public boolean hasGetProperty(OgnlContext context, Object target, Object oname) throws OgnlException {
+ try {
+ return OgnlRuntime.hasGetProperty(context, target, oname);
+ } catch (IntrospectionException ex) {
+ throw new OgnlException("checking if " + target + " has gettable property " + oname, ex);
+ }
+ }
+
+ public boolean hasGetProperty(Map context, Object target, Object oname) throws OgnlException {
+ return hasGetProperty((OgnlContext) context, target, oname);
+ }
+
+ public boolean hasSetProperty(OgnlContext context, Object target, Object oname) throws OgnlException {
+ try {
+ return OgnlRuntime.hasSetProperty(context, target, oname);
+ } catch (IntrospectionException ex) {
+ throw new OgnlException("checking if " + target + " has settable property " + oname, ex);
+ }
+ }
+
+ public boolean hasSetProperty(Map context, Object target, Object oname) throws OgnlException {
+ return hasSetProperty((OgnlContext) context, target, oname);
+ }
+
+ public Object getProperty(Map context, Object target, Object oname) throws OgnlException {
+ Object result = null;
+ String name = oname.toString();
+
+ if ((result = getPossibleProperty(context, target, name)) == OgnlRuntime.NotFound) {
+ throw new NoSuchPropertyException(target, name);
+ }
+ return result;
+ }
+
+ public void setProperty(Map context, Object target, Object oname, Object value) throws OgnlException {
+ String name = oname.toString();
+
+ if (setPossibleProperty(context, target, name, value) == OgnlRuntime.NotFound) {
+ throw new NoSuchPropertyException(target, name);
}
+ }
}
Modified: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/Ognl.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/Ognl.java?rev=736963&r1=736962&r2=736963&view=diff
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/Ognl.java (original)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/ognl/Ognl.java Thu Jan 22 22:32:36 2009
@@ -35,26 +35,26 @@
/**
* <P>This class provides static methods for parsing and interpreting OGNL expressions.</P>
- *
+ * <p/>
* <P>The simplest use of the Ognl class is to get the value of an expression from
* an object, without extra context or pre-parsing.</P>
- *
+ * <p/>
* <PRE>
* import ognl.Ognl;
* import ognl.OgnlException;
- *
- * try {
- * result = Ognl.getValue(expression, root);
- * } catch (OgnlException ex) {
- * // Report error or recover
- * }
+ * <p/>
+ * try {
+ * result = Ognl.getValue(expression, root);
+ * } catch (OgnlException ex) {
+ * // Report error or recover
+ * }
* </PRE>
- *
+ * <p/>
* <P>This will parse the expression given and evaluate it against the root object
* given, returning the result. If there is an error in the expression, such
* as the property is not found, the exception is encapsulated into an
* {@link org.apache.ibatis.ognl.OgnlException OgnlException}.</P>
- *
+ * <p/>
* <P>Other more sophisticated uses of Ognl can pre-parse expressions. This
* provides two advantages: in the case of user-supplied expressions it
* allows you to catch parse errors before evaluation and it allows you to
@@ -63,7 +63,7 @@
* to simplify use for programs that just wish to store the value for
* repeated use and do not care that it is an AST. If it does care
* it can always safely cast the value to an <CODE>AST</CODE> type.</P>
- *
+ * <p/>
* <P>The Ognl class also takes a <I>context map</I> as one of the parameters
* to the set and get methods. This allows you to put your own variables
* into the available namespace for OGNL expressions. The default context
@@ -73,512 +73,483 @@
* Here is an example that shows how to extract the <CODE>documentName</CODE>
* property out of the root object and append a string with the current user
* name in parens:</P>
- *
+ * <p/>
* <PRE>
- * private Map context = new HashMap();
- *
- * public void setUserName(String value)
- * {
- * context.put("userName", value);
- * }
- *
- * try {
- * // get value using our own custom context map
- * result = Ognl.getValue("documentName + \" (\" + ((#userName == null) ? \"<nobody>\" : #userName) + \")\"", context, root);
- * } catch (OgnlException ex) {
- * // Report error or recover
- * }
- *
+ * private Map context = new HashMap();
+ * <p/>
+ * public void setUserName(String value)
+ * {
+ * context.put("userName", value);
+ * }
+ * <p/>
+ * try {
+ * // get value using our own custom context map
+ * result = Ognl.getValue("documentName + \" (\" + ((#userName == null) ? \"<nobody>\" : #userName) + \")\"", context, root);
+ * } catch (OgnlException ex) {
+ * // Report error or recover
+ * }
+ * <p/>
* </PRE>
*
* @author Luke Blanshard (blanshlu@netscape.net)
* @author Drew Davidson (drew@ognl.org)
* @version 27 June 1999
*/
-public abstract class Ognl
-{
- /**
- * Parses the given OGNL expression and returns a tree representation of the
- * expression that can be used by <CODE>Ognl</CODE> static methods.
- *
- * @param expression the OGNL expression to be parsed
- * @return a tree representation of the expression
- * @throws ExpressionSyntaxException if the expression is malformed
- * @throws OgnlException if there is a pathological environmental problem
- */
- public static Object parseExpression( String expression ) throws OgnlException
- {
- try {
- OgnlParser parser = new OgnlParser( new StringReader(expression) );
- return parser.topLevelExpression();
- }
- catch (ParseException e) {
- throw new ExpressionSyntaxException( expression, e );
- }
- catch (TokenMgrError e) {
- throw new ExpressionSyntaxException( expression, e );
- }
- }
-
- /**
- * Creates and returns a new standard naming context for evaluating an OGNL
- * expression.
- *
- * @param root the root of the object graph
- * @return a new Map with the keys <CODE>root</CODE> and <CODE>context</CODE>
- * set appropriately
- */
- public static Map createDefaultContext( Object root )
- {
- return addDefaultContext( root, null, null, null, new OgnlContext() );
- }
-
- /**
- * Creates and returns a new standard naming context for evaluating an OGNL
- * expression.
- *
- * @param root the root of the object graph
- * @return a new OgnlContext with the keys <CODE>root</CODE> and <CODE>context</CODE>
- * set appropriately
- */
- public static Map createDefaultContext( Object root, ClassResolver classResolver )
- {
- return addDefaultContext( root, classResolver, null, null, new OgnlContext() );
- }
-
- /**
- * Creates and returns a new standard naming context for evaluating an OGNL
- * expression.
- *
- * @param root the root of the object graph
- * @return a new Map with the keys <CODE>root</CODE> and <CODE>context</CODE>
- * set appropriately
- */
- public static Map createDefaultContext( Object root, ClassResolver classResolver, TypeConverter converter )
- {
- return addDefaultContext( root, classResolver, converter, null, new OgnlContext() );
- }
-
- /**
- * Creates and returns a new standard naming context for evaluating an OGNL
- * expression.
- *
- * @param root the root of the object graph
- * @return a new Map with the keys <CODE>root</CODE> and <CODE>context</CODE>
- * set appropriately
- */
- public static Map createDefaultContext( Object root, ClassResolver classResolver, TypeConverter converter, MemberAccess memberAccess )
- {
- return addDefaultContext( root, classResolver, converter, memberAccess, new OgnlContext() );
- }
-
- /**
- * Appends the standard naming context for evaluating an OGNL expression
- * into the context given so that cached maps can be used as a context.
- *
- * @param root the root of the object graph
- * @param context the context to which OGNL context will be added.
- * @return Context Map with the keys <CODE>root</CODE> and <CODE>context</CODE>
- * set appropriately
- */
- public static Map addDefaultContext( Object root, Map context )
- {
- return addDefaultContext( root, null, null, null, context );
- }
-
- /**
- * Appends the standard naming context for evaluating an OGNL expression
- * into the context given so that cached maps can be used as a context.
- *
- * @param root the root of the object graph
- * @param context the context to which OGNL context will be added.
- * @return Context Map with the keys <CODE>root</CODE> and <CODE>context</CODE>
- * set appropriately
- */
- public static Map addDefaultContext( Object root, ClassResolver classResolver, Map context )
- {
- return addDefaultContext(root, classResolver, null, null, context);
- }
-
- /**
- * Appends the standard naming context for evaluating an OGNL expression
- * into the context given so that cached maps can be used as a context.
- *
- * @param root the root of the object graph
- * @param context the context to which OGNL context will be added.
- * @return Context Map with the keys <CODE>root</CODE> and <CODE>context</CODE>
- * set appropriately
- */
- public static Map addDefaultContext( Object root, ClassResolver classResolver, TypeConverter converter, Map context )
- {
- return addDefaultContext(root, classResolver, converter, null, context);
- }
-
- /**
- * Appends the standard naming context for evaluating an OGNL expression
- * into the context given so that cached maps can be used as a context.
- *
- * @param root the root of the object graph
- * @param context the context to which OGNL context will be added.
- * @return Context Map with the keys <CODE>root</CODE> and <CODE>context</CODE>
- * set appropriately
- */
- public static Map addDefaultContext( Object root, ClassResolver classResolver, TypeConverter converter, MemberAccess memberAccess, Map context )
- {
- OgnlContext result;
-
- if (!(context instanceof OgnlContext)) {
- result = new OgnlContext();
- result.setValues(context);
- } else {
- result = (OgnlContext)context;
- }
- if (classResolver != null) {
- result.setClassResolver(classResolver);
- }
- if (converter != null) {
- result.setTypeConverter(converter);
- }
- if (memberAccess != null) {
- result.setMemberAccess(memberAccess);
- }
- result.setRoot(root);
- return result;
- }
-
- public static void setClassResolver( Map context, ClassResolver classResolver)
- {
- context.put(OgnlContext.CLASS_RESOLVER_CONTEXT_KEY, classResolver);
- }
-
- public static ClassResolver getClassResolver( Map context )
- {
- return (ClassResolver)context.get(OgnlContext.CLASS_RESOLVER_CONTEXT_KEY);
- }
-
- public static void setTypeConverter( Map context, TypeConverter converter)
- {
- context.put(OgnlContext.TYPE_CONVERTER_CONTEXT_KEY, converter);
- }
-
- public static TypeConverter getTypeConverter( Map context )
- {
- return (TypeConverter)context.get(OgnlContext.TYPE_CONVERTER_CONTEXT_KEY);
- }
-
- public static void setMemberAccess(Map context, MemberAccess memberAccess)
- {
- context.put(OgnlContext.MEMBER_ACCESS_CONTEXT_KEY, memberAccess);
- }
-
- public static MemberAccess getMemberAccess(Map context)
- {
- return (MemberAccess)context.get(OgnlContext.MEMBER_ACCESS_CONTEXT_KEY);
- }
-
- public static void setRoot( Map context, Object root)
- {
- context.put(OgnlContext.ROOT_CONTEXT_KEY, root);
- }
-
- public static Object getRoot( Map context )
- {
- return context.get(OgnlContext.ROOT_CONTEXT_KEY);
- }
-
- public static Evaluation getLastEvaluation( Map context )
- {
- return (Evaluation)context.get(OgnlContext.LAST_EVALUATION_CONTEXT_KEY);
- }
-
- /**
- * Evaluates the given OGNL expression tree to extract a value from the given root
- * object. The default context is set for the given context and root via
- * <CODE>addDefaultContext()</CODE>.
- *
- * @param tree the OGNL expression tree to evaluate, as returned by parseExpression()
- * @param context the naming context for the evaluation
- * @param root the root object for the OGNL expression
- * @return the result of evaluating the expression
- * @throws MethodFailedException if the expression called a method which failed
- * @throws NoSuchPropertyException if the expression referred to a nonexistent property
- * @throws InappropriateExpressionException if the expression can't be used in this context
- * @throws OgnlException if there is a pathological environmental problem
- */
- public static Object getValue( Object tree, Map context, Object root ) throws OgnlException
- {
- return getValue( tree, context, root, null );
- }
-
- /**
- * Evaluates the given OGNL expression tree to extract a value from the given root
- * object. The default context is set for the given context and root via
- * <CODE>addDefaultContext()</CODE>.
- *
- * @param tree the OGNL expression tree to evaluate, as returned by parseExpression()
- * @param context the naming context for the evaluation
- * @param root the root object for the OGNL expression
- * @param resultType the converted type of the resultant object, using the context's type converter
- * @return the result of evaluating the expression
- * @throws MethodFailedException if the expression called a method which failed
- * @throws NoSuchPropertyException if the expression referred to a nonexistent property
- * @throws InappropriateExpressionException if the expression can't be used in this context
- * @throws OgnlException if there is a pathological environmental problem
- */
- public static Object getValue( Object tree, Map context, Object root, Class resultType ) throws OgnlException
- {
- Object result;
- OgnlContext ognlContext = (OgnlContext)addDefaultContext(root, context);
-
- result = ((Node)tree).getValue( ognlContext, root );
- if (resultType != null) {
- result = getTypeConverter( context ).convertValue( context, root, null, null, result, resultType);
- }
- return result;
- }
-
- /**
- * Evaluates the given OGNL expression to extract a value from the given root
- * object in a given context
- *
- * @see #parseExpression(String)
- * @see #getValue(Object,Object)
- * @param expression the OGNL expression to be parsed
- * @param context the naming context for the evaluation
- * @param root the root object for the OGNL expression
- * @return the result of evaluating the expression
- * @throws MethodFailedException if the expression called a method which failed
- * @throws NoSuchPropertyException if the expression referred to a nonexistent property
- * @throws InappropriateExpressionException if the expression can't be used in this context
- * @throws OgnlException if there is a pathological environmental problem
- */
- public static Object getValue( String expression, Map context, Object root ) throws OgnlException
- {
- return getValue( expression, context, root, null );
- }
-
- /**
- * Evaluates the given OGNL expression to extract a value from the given root
- * object in a given context
- *
- * @see #parseExpression(String)
- * @see #getValue(Object,Object)
- * @param expression the OGNL expression to be parsed
- * @param context the naming context for the evaluation
- * @param root the root object for the OGNL expression
- * @param resultType the converted type of the resultant object, using the context's type converter
- * @return the result of evaluating the expression
- * @throws MethodFailedException if the expression called a method which failed
- * @throws NoSuchPropertyException if the expression referred to a nonexistent property
- * @throws InappropriateExpressionException if the expression can't be used in this context
- * @throws OgnlException if there is a pathological environmental problem
- */
- public static Object getValue( String expression, Map context, Object root, Class resultType ) throws OgnlException
- {
- return getValue( parseExpression(expression), context, root, resultType );
- }
+public abstract class Ognl {
+ /**
+ * Parses the given OGNL expression and returns a tree representation of the
+ * expression that can be used by <CODE>Ognl</CODE> static methods.
+ *
+ * @param expression the OGNL expression to be parsed
+ * @return a tree representation of the expression
+ * @throws ExpressionSyntaxException if the expression is malformed
+ * @throws OgnlException if there is a pathological environmental problem
+ */
+ public static Object parseExpression(String expression) throws OgnlException {
+ try {
+ OgnlParser parser = new OgnlParser(new StringReader(expression));
+ return parser.topLevelExpression();
+ }
+ catch (ParseException e) {
+ throw new ExpressionSyntaxException(expression, e);
+ }
+ catch (TokenMgrError e) {
+ throw new ExpressionSyntaxException(expression, e);
+ }
+ }
+
+ /**
+ * Creates and returns a new standard naming context for evaluating an OGNL
+ * expression.
+ *
+ * @param root the root of the object graph
+ * @return a new Map with the keys <CODE>root</CODE> and <CODE>context</CODE>
+ * set appropriately
+ */
+ public static Map createDefaultContext(Object root) {
+ return addDefaultContext(root, null, null, null, new OgnlContext());
+ }
+
+ /**
+ * Creates and returns a new standard naming context for evaluating an OGNL
+ * expression.
+ *
+ * @param root the root of the object graph
+ * @return a new OgnlContext with the keys <CODE>root</CODE> and <CODE>context</CODE>
+ * set appropriately
+ */
+ public static Map createDefaultContext(Object root, ClassResolver classResolver) {
+ return addDefaultContext(root, classResolver, null, null, new OgnlContext());
+ }
+
+ /**
+ * Creates and returns a new standard naming context for evaluating an OGNL
+ * expression.
+ *
+ * @param root the root of the object graph
+ * @return a new Map with the keys <CODE>root</CODE> and <CODE>context</CODE>
+ * set appropriately
+ */
+ public static Map createDefaultContext(Object root, ClassResolver classResolver, TypeConverter converter) {
+ return addDefaultContext(root, classResolver, converter, null, new OgnlContext());
+ }
+
+ /**
+ * Creates and returns a new standard naming context for evaluating an OGNL
+ * expression.
+ *
+ * @param root the root of the object graph
+ * @return a new Map with the keys <CODE>root</CODE> and <CODE>context</CODE>
+ * set appropriately
+ */
+ public static Map createDefaultContext(Object root, ClassResolver classResolver, TypeConverter converter, MemberAccess memberAccess) {
+ return addDefaultContext(root, classResolver, converter, memberAccess, new OgnlContext());
+ }
+
+ /**
+ * Appends the standard naming context for evaluating an OGNL expression
+ * into the context given so that cached maps can be used as a context.
+ *
+ * @param root the root of the object graph
+ * @param context the context to which OGNL context will be added.
+ * @return Context Map with the keys <CODE>root</CODE> and <CODE>context</CODE>
+ * set appropriately
+ */
+ public static Map addDefaultContext(Object root, Map context) {
+ return addDefaultContext(root, null, null, null, context);
+ }
+
+ /**
+ * Appends the standard naming context for evaluating an OGNL expression
+ * into the context given so that cached maps can be used as a context.
+ *
+ * @param root the root of the object graph
+ * @param context the context to which OGNL context will be added.
+ * @return Context Map with the keys <CODE>root</CODE> and <CODE>context</CODE>
+ * set appropriately
+ */
+ public static Map addDefaultContext(Object root, ClassResolver classResolver, Map context) {
+ return addDefaultContext(root, classResolver, null, null, context);
+ }
+
+ /**
+ * Appends the standard naming context for evaluating an OGNL expression
+ * into the context given so that cached maps can be used as a context.
+ *
+ * @param root the root of the object graph
+ * @param context the context to which OGNL context will be added.
+ * @return Context Map with the keys <CODE>root</CODE> and <CODE>context</CODE>
+ * set appropriately
+ */
+ public static Map addDefaultContext(Object root, ClassResolver classResolver, TypeConverter converter, Map context) {
+ return addDefaultContext(root, classResolver, converter, null, context);
+ }
+
+ /**
+ * Appends the standard naming context for evaluating an OGNL expression
+ * into the context given so that cached maps can be used as a context.
+ *
+ * @param root the root of the object graph
+ * @param context the context to which OGNL context will be added.
+ * @return Context Map with the keys <CODE>root</CODE> and <CODE>context</CODE>
+ * set appropriately
+ */
+ public static Map addDefaultContext(Object root, ClassResolver classResolver, TypeConverter converter, MemberAccess memberAccess, Map context) {
+ OgnlContext result;
+
+ if (!(context instanceof OgnlContext)) {
+ result = new OgnlContext();
+ result.setValues(context);
+ } else {
+ result = (OgnlContext) context;
+ }
+ if (classResolver != null) {
+ result.setClassResolver(classResolver);
+ }
+ if (converter != null) {
+ result.setTypeConverter(converter);
+ }
+ if (memberAccess != null) {
+ result.setMemberAccess(memberAccess);
+ }
+ result.setRoot(root);
+ return result;
+ }
+
+ public static void setClassResolver(Map context, ClassResolver classResolver) {
+ context.put(OgnlContext.CLASS_RESOLVER_CONTEXT_KEY, classResolver);
+ }
+
+ public static ClassResolver getClassResolver(Map context) {
+ return (ClassResolver) context.get(OgnlContext.CLASS_RESOLVER_CONTEXT_KEY);
+ }
+
+ public static void setTypeConverter(Map context, TypeConverter converter) {
+ context.put(OgnlContext.TYPE_CONVERTER_CONTEXT_KEY, converter);
+ }
+
+ public static TypeConverter getTypeConverter(Map context) {
+ return (TypeConverter) context.get(OgnlContext.TYPE_CONVERTER_CONTEXT_KEY);
+ }
+
+ public static void setMemberAccess(Map context, MemberAccess memberAccess) {
+ context.put(OgnlContext.MEMBER_ACCESS_CONTEXT_KEY, memberAccess);
+ }
+
+ public static MemberAccess getMemberAccess(Map context) {
+ return (MemberAccess) context.get(OgnlContext.MEMBER_ACCESS_CONTEXT_KEY);
+ }
+
+ public static void setRoot(Map context, Object root) {
+ context.put(OgnlContext.ROOT_CONTEXT_KEY, root);
+ }
+
+ public static Object getRoot(Map context) {
+ return context.get(OgnlContext.ROOT_CONTEXT_KEY);
+ }
+
+ public static Evaluation getLastEvaluation(Map context) {
+ return (Evaluation) context.get(OgnlContext.LAST_EVALUATION_CONTEXT_KEY);
+ }
+
+ /**
+ * Evaluates the given OGNL expression tree to extract a value from the given root
+ * object. The default context is set for the given context and root via
+ * <CODE>addDefaultContext()</CODE>.
+ *
+ * @param tree the OGNL expression tree to evaluate, as returned by parseExpression()
+ * @param context the naming context for the evaluation
+ * @param root the root object for the OGNL expression
+ * @return the result of evaluating the expression
+ * @throws MethodFailedException if the expression called a method which failed
+ * @throws NoSuchPropertyException if the expression referred to a nonexistent property
+ * @throws InappropriateExpressionException
+ * if the expression can't be used in this context
+ * @throws OgnlException if there is a pathological environmental problem
+ */
+ public static Object getValue(Object tree, Map context, Object root) throws OgnlException {
+ return getValue(tree, context, root, null);
+ }
+
+ /**
+ * Evaluates the given OGNL expression tree to extract a value from the given root
+ * object. The default context is set for the given context and root via
+ * <CODE>addDefaultContext()</CODE>.
+ *
+ * @param tree the OGNL expression tree to evaluate, as returned by parseExpression()
+ * @param context the naming context for the evaluation
+ * @param root the root object for the OGNL expression
+ * @param resultType the converted type of the resultant object, using the context's type converter
+ * @return the result of evaluating the expression
+ * @throws MethodFailedException if the expression called a method which failed
+ * @throws NoSuchPropertyException if the expression referred to a nonexistent property
+ * @throws InappropriateExpressionException
+ * if the expression can't be used in this context
+ * @throws OgnlException if there is a pathological environmental problem
+ */
+ public static Object getValue(Object tree, Map context, Object root, Class resultType) throws OgnlException {
+ Object result;
+ OgnlContext ognlContext = (OgnlContext) addDefaultContext(root, context);
+
+ result = ((Node) tree).getValue(ognlContext, root);
+ if (resultType != null) {
+ result = getTypeConverter(context).convertValue(context, root, null, null, result, resultType);
+ }
+ return result;
+ }
+
+ /**
+ * Evaluates the given OGNL expression to extract a value from the given root
+ * object in a given context
+ *
+ * @param expression the OGNL expression to be parsed
+ * @param context the naming context for the evaluation
+ * @param root the root object for the OGNL expression
+ * @return the result of evaluating the expression
+ * @throws MethodFailedException if the expression called a method which failed
+ * @throws NoSuchPropertyException if the expression referred to a nonexistent property
+ * @throws InappropriateExpressionException
+ * if the expression can't be used in this context
+ * @throws OgnlException if there is a pathological environmental problem
+ * @see #parseExpression(String)
+ * @see #getValue(Object,Object)
+ */
+ public static Object getValue(String expression, Map context, Object root) throws OgnlException {
+ return getValue(expression, context, root, null);
+ }
+
+ /**
+ * Evaluates the given OGNL expression to extract a value from the given root
+ * object in a given context
+ *
+ * @param expression the OGNL expression to be parsed
+ * @param context the naming context for the evaluation
+ * @param root the root object for the OGNL expression
+ * @param resultType the converted type of the resultant object, using the context's type converter
+ * @return the result of evaluating the expression
+ * @throws MethodFailedException if the expression called a method which failed
+ * @throws NoSuchPropertyException if the expression referred to a nonexistent property
+ * @throws InappropriateExpressionException
+ * if the expression can't be used in this context
+ * @throws OgnlException if there is a pathological environmental problem
+ * @see #parseExpression(String)
+ * @see #getValue(Object,Object)
+ */
+ public static Object getValue(String expression, Map context, Object root, Class resultType) throws OgnlException {
+ return getValue(parseExpression(expression), context, root, resultType);
+ }
+
+ /**
+ * Evaluates the given OGNL expression tree to extract a value from the given root
+ * object.
+ *
+ * @param tree the OGNL expression tree to evaluate, as returned by parseExpression()
+ * @param root the root object for the OGNL expression
+ * @return the result of evaluating the expression
+ * @throws MethodFailedException if the expression called a method which failed
+ * @throws NoSuchPropertyException if the expression referred to a nonexistent property
+ * @throws InappropriateExpressionException
+ * if the expression can't be used in this context
+ * @throws OgnlException if there is a pathological environmental problem
+ */
+ public static Object getValue(Object tree, Object root) throws OgnlException {
+ return getValue(tree, root, null);
+ }
+
+ /**
+ * Evaluates the given OGNL expression tree to extract a value from the given root
+ * object.
+ *
+ * @param tree the OGNL expression tree to evaluate, as returned by parseExpression()
+ * @param root the root object for the OGNL expression
+ * @param resultType the converted type of the resultant object, using the context's type converter
+ * @return the result of evaluating the expression
+ * @throws MethodFailedException if the expression called a method which failed
+ * @throws NoSuchPropertyException if the expression referred to a nonexistent property
+ * @throws InappropriateExpressionException
+ * if the expression can't be used in this context
+ * @throws OgnlException if there is a pathological environmental problem
+ */
+ public static Object getValue(Object tree, Object root, Class resultType) throws OgnlException {
+ return getValue(tree, createDefaultContext(root), root, resultType);
+ }
+
+ /**
+ * Convenience method that combines calls to <code> parseExpression </code> and
+ * <code> getValue</code>.
+ *
+ * @param expression the OGNL expression to be parsed
+ * @param root the root object for the OGNL expression
+ * @return the result of evaluating the expression
+ * @throws ExpressionSyntaxException if the expression is malformed
+ * @throws MethodFailedException if the expression called a method which failed
+ * @throws NoSuchPropertyException if the expression referred to a nonexistent property
+ * @throws InappropriateExpressionException
+ * if the expression can't be used in this context
+ * @throws OgnlException if there is a pathological environmental problem
+ * @see #parseExpression(String)
+ * @see #getValue(Object,Object)
+ */
+ public static Object getValue(String expression, Object root) throws OgnlException {
+ return getValue(expression, root, null);
+ }
+
+ /**
+ * Convenience method that combines calls to <code> parseExpression </code> and
+ * <code> getValue</code>.
+ *
+ * @param expression the OGNL expression to be parsed
+ * @param root the root object for the OGNL expression
+ * @param resultType the converted type of the resultant object, using the context's type converter
+ * @return the result of evaluating the expression
+ * @throws ExpressionSyntaxException if the expression is malformed
+ * @throws MethodFailedException if the expression called a method which failed
+ * @throws NoSuchPropertyException if the expression referred to a nonexistent property
+ * @throws InappropriateExpressionException
+ * if the expression can't be used in this context
+ * @throws OgnlException if there is a pathological environmental problem
+ * @see #parseExpression(String)
+ * @see #getValue(Object,Object)
+ */
+ public static Object getValue(String expression, Object root, Class resultType) throws OgnlException {
+ return getValue(parseExpression(expression), root, resultType);
+ }
+
+ /**
+ * Evaluates the given OGNL expression tree to insert a value into the object graph
+ * rooted at the given root object. The default context is set for the given
+ * context and root via <CODE>addDefaultContext()</CODE>.
+ *
+ * @param tree the OGNL expression tree to evaluate, as returned by parseExpression()
+ * @param context the naming context for the evaluation
+ * @param root the root object for the OGNL expression
+ * @param value the value to insert into the object graph
+ * @throws MethodFailedException if the expression called a method which failed
+ * @throws NoSuchPropertyException if the expression referred to a nonexistent property
+ * @throws InappropriateExpressionException
+ * if the expression can't be used in this context
+ * @throws OgnlException if there is a pathological environmental problem
+ */
+ public static void setValue(Object tree, Map context, Object root, Object value) throws OgnlException {
+ OgnlContext ognlContext = (OgnlContext) addDefaultContext(root, context);
+ Node n = (Node) tree;
+
+ n.setValue(ognlContext, root, value);
+ }
+
+ /**
+ * Evaluates the given OGNL expression to insert a value into the object graph
+ * rooted at the given root object given the context.
+ *
+ * @param expression the OGNL expression to be parsed
+ * @param root the root object for the OGNL expression
+ * @param context the naming context for the evaluation
+ * @param value the value to insert into the object graph
+ * @throws MethodFailedException if the expression called a method which failed
+ * @throws NoSuchPropertyException if the expression referred to a nonexistent property
+ * @throws InappropriateExpressionException
+ * if the expression can't be used in this context
+ * @throws OgnlException if there is a pathological environmental problem
+ */
+ public static void setValue(String expression, Map context, Object root, Object value) throws OgnlException {
+ setValue(parseExpression(expression), context, root, value);
+ }
+
+ /**
+ * Evaluates the given OGNL expression tree to insert a value into the object graph
+ * rooted at the given root object.
+ *
+ * @param tree the OGNL expression tree to evaluate, as returned by parseExpression()
+ * @param root the root object for the OGNL expression
+ * @param value the value to insert into the object graph
+ * @throws MethodFailedException if the expression called a method which failed
+ * @throws NoSuchPropertyException if the expression referred to a nonexistent property
+ * @throws InappropriateExpressionException
+ * if the expression can't be used in this context
+ * @throws OgnlException if there is a pathological environmental problem
+ */
+ public static void setValue(Object tree, Object root, Object value) throws OgnlException {
+ setValue(tree, createDefaultContext(root), root, value);
+ }
+
+ /**
+ * Convenience method that combines calls to <code> parseExpression </code> and
+ * <code> setValue</code>.
+ *
+ * @param expression the OGNL expression to be parsed
+ * @param root the root object for the OGNL expression
+ * @param value the value to insert into the object graph
+ * @throws ExpressionSyntaxException if the expression is malformed
+ * @throws MethodFailedException if the expression called a method which failed
+ * @throws NoSuchPropertyException if the expression referred to a nonexistent property
+ * @throws InappropriateExpressionException
+ * if the expression can't be used in this context
+ * @throws OgnlException if there is a pathological environmental problem
+ * @see #parseExpression(String)
+ * @see #setValue(Object,Object,Object)
+ */
+ public static void setValue(String expression, Object root, Object value) throws OgnlException {
+ setValue(parseExpression(expression), root, value);
+ }
+
+ public static boolean isConstant(Object tree, Map context) throws OgnlException {
+ return ((SimpleNode) tree).isConstant((OgnlContext) addDefaultContext(null, context));
+ }
+
+ public static boolean isConstant(String expression, Map context) throws OgnlException {
+ return isConstant(parseExpression(expression), context);
+ }
+
+ public static boolean isConstant(Object tree) throws OgnlException {
+ return isConstant(tree, createDefaultContext(null));
+ }
+
+ public static boolean isConstant(String expression) throws OgnlException {
+ return isConstant(parseExpression(expression), createDefaultContext(null));
+ }
+
+ public static boolean isSimpleProperty(Object tree, Map context) throws OgnlException {
+ return ((SimpleNode) tree).isSimpleProperty((OgnlContext) addDefaultContext(null, context));
+ }
+
+ public static boolean isSimpleProperty(String expression, Map context) throws OgnlException {
+ return isSimpleProperty(parseExpression(expression), context);
+ }
+
+ public static boolean isSimpleProperty(Object tree) throws OgnlException {
+ return isSimpleProperty(tree, createDefaultContext(null));
+ }
+
+ public static boolean isSimpleProperty(String expression) throws OgnlException {
+ return isSimpleProperty(parseExpression(expression), createDefaultContext(null));
+ }
+
+ public static boolean isSimpleNavigationChain(Object tree, Map context) throws OgnlException {
+ return ((SimpleNode) tree).isSimpleNavigationChain((OgnlContext) addDefaultContext(null, context));
+ }
- /**
- * Evaluates the given OGNL expression tree to extract a value from the given root
- * object.
- *
- * @param tree the OGNL expression tree to evaluate, as returned by parseExpression()
- * @param root the root object for the OGNL expression
- * @return the result of evaluating the expression
- * @throws MethodFailedException if the expression called a method which failed
- * @throws NoSuchPropertyException if the expression referred to a nonexistent property
- * @throws InappropriateExpressionException if the expression can't be used in this context
- * @throws OgnlException if there is a pathological environmental problem
- */
- public static Object getValue( Object tree, Object root ) throws OgnlException
- {
- return getValue( tree, root, null );
- }
-
- /**
- * Evaluates the given OGNL expression tree to extract a value from the given root
- * object.
- *
- * @param tree the OGNL expression tree to evaluate, as returned by parseExpression()
- * @param root the root object for the OGNL expression
- * @param resultType the converted type of the resultant object, using the context's type converter
- * @return the result of evaluating the expression
- * @throws MethodFailedException if the expression called a method which failed
- * @throws NoSuchPropertyException if the expression referred to a nonexistent property
- * @throws InappropriateExpressionException if the expression can't be used in this context
- * @throws OgnlException if there is a pathological environmental problem
- */
- public static Object getValue( Object tree, Object root, Class resultType ) throws OgnlException
- {
- return getValue( tree, createDefaultContext(root), root, resultType );
- }
-
- /**
- * Convenience method that combines calls to <code> parseExpression </code> and
- * <code> getValue</code>.
- *
- * @see #parseExpression(String)
- * @see #getValue(Object,Object)
- * @param expression the OGNL expression to be parsed
- * @param root the root object for the OGNL expression
- * @return the result of evaluating the expression
- * @throws ExpressionSyntaxException if the expression is malformed
- * @throws MethodFailedException if the expression called a method which failed
- * @throws NoSuchPropertyException if the expression referred to a nonexistent property
- * @throws InappropriateExpressionException if the expression can't be used in this context
- * @throws OgnlException if there is a pathological environmental problem
- */
- public static Object getValue( String expression, Object root ) throws OgnlException
- {
- return getValue( expression, root, null );
- }
-
- /**
- * Convenience method that combines calls to <code> parseExpression </code> and
- * <code> getValue</code>.
- *
- * @see #parseExpression(String)
- * @see #getValue(Object,Object)
- * @param expression the OGNL expression to be parsed
- * @param root the root object for the OGNL expression
- * @param resultType the converted type of the resultant object, using the context's type converter
- * @return the result of evaluating the expression
- * @throws ExpressionSyntaxException if the expression is malformed
- * @throws MethodFailedException if the expression called a method which failed
- * @throws NoSuchPropertyException if the expression referred to a nonexistent property
- * @throws InappropriateExpressionException if the expression can't be used in this context
- * @throws OgnlException if there is a pathological environmental problem
- */
- public static Object getValue( String expression, Object root, Class resultType ) throws OgnlException
- {
- return getValue( parseExpression(expression), root, resultType );
- }
-
- /**
- * Evaluates the given OGNL expression tree to insert a value into the object graph
- * rooted at the given root object. The default context is set for the given
- * context and root via <CODE>addDefaultContext()</CODE>.
- *
- * @param tree the OGNL expression tree to evaluate, as returned by parseExpression()
- * @param context the naming context for the evaluation
- * @param root the root object for the OGNL expression
- * @param value the value to insert into the object graph
- * @throws MethodFailedException if the expression called a method which failed
- * @throws NoSuchPropertyException if the expression referred to a nonexistent property
- * @throws InappropriateExpressionException if the expression can't be used in this context
- * @throws OgnlException if there is a pathological environmental problem
- */
- public static void setValue( Object tree, Map context, Object root, Object value ) throws OgnlException
- {
- OgnlContext ognlContext = (OgnlContext)addDefaultContext(root, context);
- Node n = (Node) tree;
-
- n.setValue( ognlContext, root, value );
- }
-
- /**
- * Evaluates the given OGNL expression to insert a value into the object graph
- * rooted at the given root object given the context.
- *
- * @param expression the OGNL expression to be parsed
- * @param root the root object for the OGNL expression
- * @param context the naming context for the evaluation
- * @param value the value to insert into the object graph
- * @throws MethodFailedException if the expression called a method which failed
- * @throws NoSuchPropertyException if the expression referred to a nonexistent property
- * @throws InappropriateExpressionException if the expression can't be used in this context
- * @throws OgnlException if there is a pathological environmental problem
- */
- public static void setValue( String expression, Map context, Object root, Object value ) throws OgnlException
- {
- setValue( parseExpression(expression), context, root, value );
- }
-
- /**
- * Evaluates the given OGNL expression tree to insert a value into the object graph
- * rooted at the given root object.
- *
- * @param tree the OGNL expression tree to evaluate, as returned by parseExpression()
- * @param root the root object for the OGNL expression
- * @param value the value to insert into the object graph
- * @throws MethodFailedException if the expression called a method which failed
- * @throws NoSuchPropertyException if the expression referred to a nonexistent property
- * @throws InappropriateExpressionException if the expression can't be used in this context
- * @throws OgnlException if there is a pathological environmental problem
- */
- public static void setValue( Object tree, Object root, Object value ) throws OgnlException
- {
- setValue( tree, createDefaultContext(root), root, value );
- }
-
- /**
- * Convenience method that combines calls to <code> parseExpression </code> and
- * <code> setValue</code>.
- *
- * @see #parseExpression(String)
- * @see #setValue(Object,Object,Object)
- * @param expression the OGNL expression to be parsed
- * @param root the root object for the OGNL expression
- * @param value the value to insert into the object graph
- * @throws ExpressionSyntaxException if the expression is malformed
- * @throws MethodFailedException if the expression called a method which failed
- * @throws NoSuchPropertyException if the expression referred to a nonexistent property
- * @throws InappropriateExpressionException if the expression can't be used in this context
- * @throws OgnlException if there is a pathological environmental problem
- */
- public static void setValue( String expression, Object root, Object value ) throws OgnlException
- {
- setValue( parseExpression(expression), root, value );
- }
-
- public static boolean isConstant( Object tree, Map context ) throws OgnlException
- {
- return ((SimpleNode)tree).isConstant( (OgnlContext)addDefaultContext( null, context ) );
- }
-
- public static boolean isConstant( String expression, Map context ) throws OgnlException
- {
- return isConstant(parseExpression(expression), context);
- }
-
- public static boolean isConstant( Object tree ) throws OgnlException
- {
- return isConstant(tree, createDefaultContext(null));
- }
-
- public static boolean isConstant( String expression ) throws OgnlException
- {
- return isConstant(parseExpression(expression), createDefaultContext(null));
- }
-
- public static boolean isSimpleProperty( Object tree, Map context ) throws OgnlException
- {
- return ((SimpleNode)tree).isSimpleProperty( (OgnlContext)addDefaultContext( null, context ) );
- }
-
- public static boolean isSimpleProperty( String expression, Map context ) throws OgnlException
- {
- return isSimpleProperty(parseExpression(expression), context);
- }
-
- public static boolean isSimpleProperty( Object tree ) throws OgnlException
- {
- return isSimpleProperty(tree, createDefaultContext(null));
- }
-
- public static boolean isSimpleProperty( String expression ) throws OgnlException
- {
- return isSimpleProperty(parseExpression(expression), createDefaultContext(null));
- }
-
- public static boolean isSimpleNavigationChain( Object tree, Map context ) throws OgnlException
- {
- return ((SimpleNode)tree).isSimpleNavigationChain( (OgnlContext)addDefaultContext( null, context ) );
- }
-
- public static boolean isSimpleNavigationChain( String expression, Map context ) throws OgnlException
- {
- return isSimpleNavigationChain(parseExpression(expression), context);
+ public static boolean isSimpleNavigationChain(String expression, Map context) throws OgnlException {
+ return isSimpleNavigationChain(parseExpression(expression), context);
}
public static boolean isSimpleNavigationChain( Object tree ) throws OgnlException
@@ -591,7 +562,9 @@
return isSimpleNavigationChain(parseExpression(expression), createDefaultContext(null));
}
- /** You can't make one of these. */
+ /**
+ * You can't make one of these.
+ */
private Ognl()
{
}