[seam-commits] Seam SVN: r10988 - modules/trunk/el/src/main/java/org/jboss/seam/el.

seam-commits at lists.jboss.org seam-commits at lists.jboss.org
Tue May 26 11:25:15 EDT 2009


Author: dan.j.allen
Date: 2009-05-26 11:25:15 -0400 (Tue, 26 May 2009)
New Revision: 10988

Modified:
   modules/trunk/el/src/main/java/org/jboss/seam/el/Expressions.java
Log:
add some convenience methods

Modified: modules/trunk/el/src/main/java/org/jboss/seam/el/Expressions.java
===================================================================
--- modules/trunk/el/src/main/java/org/jboss/seam/el/Expressions.java	2009-05-26 15:24:28 UTC (rev 10987)
+++ modules/trunk/el/src/main/java/org/jboss/seam/el/Expressions.java	2009-05-26 15:25:15 UTC (rev 10988)
@@ -79,6 +79,58 @@
    }
    
    /**
+    * Get the value of a unified ValueExpression, coercing it to the expected type.
+    * 
+    * @param expression a unified ValueExpression
+    * @param type the expected value type
+    * 
+    * @return the value of the unified ValueExpression
+    */
+   @SuppressWarnings("unchecked")
+   public <T> T getValue(javax.el.ValueExpression expression, Class<T> type)
+   {
+      return (T) expression.getValue(getELContext());
+   }
+   
+   /**
+    * Inspect the unified ValueExpression and return the value's expected type.
+    * 
+    * @param expression a unified ValueExpression
+    * 
+    * @return the value's expected type
+    */
+   public Class<?> getType(javax.el.ValueExpression expression)
+   {
+      return expression.getType(getELContext());
+   }
+
+   /**
+    * Assign the specified value to the unified ValueExpression.
+    * 
+    * @param expression a unified ValueExpression
+    * @param value the value to assign to the ValueExpression
+    */
+   public void setValue(javax.el.ValueExpression expression, Object value)
+   {
+      expression.setValue(getELContext(), value);
+   }
+   
+   /**
+    * Invoke the unified MethodExpression, coercing the result to the expected return type.
+    * 
+    * @param expression a unified MethodExpression
+    * @param returnType the expected return type
+    * @param args method arguments
+    * 
+    * @return the return value of the underlying method represented by the unified MethodExpression
+    */
+   @SuppressWarnings("unchecked")
+   public <T> T invoke(javax.el.MethodExpression expression, Class<T> returnType, Object... args)
+   {
+      return (T) expression.invoke(getELContext(), args);
+   }
+   
+   /**
     * Create a value expression.
     * 
     * @param expression a JBoss EL value expression
@@ -117,6 +169,7 @@
             return getExpressionFactory().createValueExpression( getELContext(), expression, type );
          }
          
+         @SuppressWarnings("unchecked")
          public T getValue()
          {
             return (T) toUnifiedValueExpression().getValue( getELContext() );
@@ -132,6 +185,7 @@
             return expression;
          }
          
+         @SuppressWarnings("unchecked")
          public Class<T> getType()
          {
             // QUESTION shouldn't we use the type provided in the constructor?




More information about the seam-commits mailing list