This commit is contained in:
Keith Donald
2008-04-05 00:49:51 +00:00
parent ef056227c1
commit 72124f845c
4 changed files with 40 additions and 22 deletions

View File

@@ -23,6 +23,8 @@ import java.util.Map;
import ognl.Ognl;
import ognl.OgnlException;
import org.springframework.beans.BeanWrapperImpl;
import org.springframework.beans.BeansException;
import org.springframework.binding.expression.EvaluationAttempt;
import org.springframework.binding.expression.EvaluationException;
import org.springframework.binding.expression.Expression;
@@ -105,13 +107,8 @@ class OgnlExpression implements Expression {
public Class getValueType(Object context) {
try {
if (Ognl.isSimpleProperty(expression)) {
// TODO
throw new UnsupportedOperationException("Not yet implemented - in progress");
} else {
return null;
}
} catch (OgnlException e) {
return new BeanWrapperImpl(context).getPropertyDescriptor(expressionString).getPropertyType();
} catch (BeansException e) {
throw new EvaluationException(new EvaluationAttempt(this, context), e);
}
}

View File

@@ -123,7 +123,9 @@ public class OgnlExpressionParserTests extends TestCase {
// maps
parser.parseExpression("#{ 'foo' : 'foo value', 'bar' : 'bar value' }", null);
parser.parseExpression("${#{ 'foo' : 'foo value', 'bar' : 'bar value' }}", new FluentParserContext().template());
parser
.parseExpression("${#{ 'foo' : 'foo value', 'bar' : 'bar value' }}", new FluentParserContext()
.template());
parser.parseExpression("#@java.util.LinkedHashMap@{ 'foo' : 'foo value', 'bar' : 'bar value' }", null);
parser.parseExpression("${#@java.util.LinkedHashMap@{ 'foo' : 'foo value', 'bar' : 'bar value' }}",
new FluentParserContext().template());
@@ -135,22 +137,28 @@ public class OgnlExpressionParserTests extends TestCase {
}
public void testVariables() {
Expression exp = parser.parseExpression("#var", new FluentParserContext().variable(new ExpressionVariable("var",
"flag")));
Expression exp = parser.parseExpression("#var", new FluentParserContext().variable(new ExpressionVariable(
"var", "flag")));
assertEquals(false, ((Boolean) exp.getValue(bean)).booleanValue());
}
public void testVariablesWithCoersion() {
Expression exp = parser.parseExpression("#var", new FluentParserContext().variable(new ExpressionVariable("var",
"number", new FluentParserContext().expectResult(Long.class))));
Expression exp = parser.parseExpression("#var", new FluentParserContext().variable(new ExpressionVariable(
"var", "number", new FluentParserContext().expectResult(Long.class))));
assertEquals(new Long(0), exp.getValue(bean));
}
public void testNestedVariablesWithTemplates() {
Expression exp = parser.parseExpression("#var", new FluentParserContext()
.variable(new ExpressionVariable("var", "${flag}${#var}", new FluentParserContext().template().variable(
Expression exp = parser.parseExpression("#var", new FluentParserContext().variable(new ExpressionVariable(
"var", "${flag}${#var}", new FluentParserContext().template().variable(
new ExpressionVariable("var", "number")))));
assertEquals("false0", exp.getValue(bean));
}
public void testGetValueType() {
String exp = "flag";
Expression e = parser.parseExpression(exp, null);
assertEquals(boolean.class, e.getValueType(bean));
}
}

View File

@@ -26,6 +26,7 @@
<dependency org="javax.persistence" name="persistence-api" rev="1.0.0" conf="compile->default"/>
<dependency org="org.aopalliance" name="aopalliance" rev="1.0" conf="compile->default"/>
<dependency org="org.apache" name="commons-codec" rev="1.3" conf="compile, compile->default" />
<dependency org="org.antlr" name="antlr" rev="2.7.6" conf="compile, compile->default" />
<dependency org="org.apache.commons" name="commons-collections" rev="3.2" conf="compile->default" />
<dependency org="org.apache.logging" name="log4j" rev="1.2.15" conf="compile->default"/>
<dependency org="org.apache.taglibs" name="standard" rev="1.1.2" conf="compile->default"/>
@@ -33,20 +34,23 @@
<dependency org="org.hibernate" name="hibernate-annotations" rev="3.3.0.ga" conf="compile->default"/>
<dependency org="org.hibernate" name="hibernate-commons-annotations" rev="3.3.0.ga" conf="compile->default"/>
<dependency org="org.hibernate" name="hibernate-entitymanager" rev="3.3.1.ga" conf="compile->default"/>
<dependency org="org.hsqldb" name="hsqldb" rev="1.8.0.9" conf="compile->default"/>
<dependency org="org.jboss" name="jboss-common-core" rev="2.0.4.GA" conf="compile->default"/>
<dependency org="org.jboss" name="javassist" rev="3.3.ga" conf="compile->default"/>
<dependency org="org.jboss.seam" name="jboss-el" rev="2.0.0.GA" conf="compile->default"/>
<dependency org="org.hsqldb" name="hsqldb" rev="1.8.0.9" conf="compile->default"/>
<dependency org="org.springframework" name="spring-aop" rev="2.5.2" conf="compile->default"/>
<dependency org="org.springframework" name="spring-orm" rev="2.5.2" conf="compile->default"/>
<dependency org="org.springframework" name="spring-jdbc" rev="2.5.2" conf="compile->default"/>
<dependency org="org.springframework" name="spring-tx" rev="2.5.2" conf="compile->default"/>
<dependency org="org.springframework" name="spring-orm" rev="2.5.2" conf="compile->default"/>
<dependency org="org.springframework" name="spring-tx" rev="2.5.2" conf="compile->default"/>
<dependency org="org.springframework.security" name="spring-security-core" rev="2.0.0.m2" conf="compile->default"/>
<dependency org="org.springframework.webflow" name="spring-faces" rev="latest.integration" conf="compile->jsf12"/>
<dependency org="org.springframework.webflow" name="spring-js" rev="latest.integration" conf="compile->compile"/>
<dependency org="org.springframework.webflow" name="spring-webflow" rev="latest.integration" conf="compile->compile"/>
<dependency org="org.springframework.webflow" name="spring-js" rev="latest.integration" conf="compile->compile"/>
<dependency org="net.sf.cglib" name="cglib_nodep" rev="2.1.3" conf="compile->default"/>
<!-- concurrent Required by "jboss archive browsing" which is used by hibernate-entity manager but not noted in their docs -->
<dependency org="edu.oswego.cs" name="concurrent" rev="1.3.4" conf="compile->default"/>
<!-- build-time only dependencies -->
<dependency org="javax.servlet" name="servlet-api" rev="2.4" conf="provided->default"/>
<dependency org="javax.el" name="el-api" rev="1.0" conf="provided->default"/>

View File

@@ -25,26 +25,35 @@
<dependency org="javax.persistence" name="persistence-api" rev="1.0.0" conf="compile->default"/>
<dependency org="org.aopalliance" name="aopalliance" rev="1.0" conf="compile->default"/>
<dependency org="org.apache" name="commons-codec" rev="1.3" conf="compile->default"/>
<dependency org="org.apache.commons" name="commons-beanutils" rev="1.7.0" conf="compile->default" />
<dependency org="org.apache.commons" name="commons-collections" rev="3.2" conf="compile->default" />
<dependency org="org.apache.commons" name="commons-digester" rev="1.8.0" conf="compile->default" />
<dependency org="org.apache.logging" name="log4j" rev="1.2.15" conf="runtime->default"/>
<dependency org="org.apache.taglibs" name="standard" rev="1.1.2" conf="compile->default"/>
<dependency org="org.apache.tiles" name="tiles-api" rev="2.0.5" conf="compile->default"/>
<dependency org="org.apache.tiles" name="tiles-core" rev="2.0.5" conf="compile->default"/>
<dependency org="org.apache.tiles" name="tiles-jsp" rev="2.0.5" conf="compile->default"/>
<dependency org="org.antlr" name="antlr" rev="2.7.6" conf="compile, compile->default" />
<dependency org="org.hibernate" name="hibernate" rev="3.2.5.ga" conf="compile->default"/>
<dependency org="org.hibernate" name="hibernate-entitymanager" rev="3.3.1.ga" conf="compile->default"/>
<dependency org="org.hibernate" name="hibernate-annotations" rev="3.3.0.ga" conf="compile->default"/>
<dependency org="org.hibernate" name="hibernate-commons-annotations" rev="3.3.0.ga" conf="compile->default"/>
<dependency org="org.hsqldb" name="hsqldb" rev="1.8.0.9" conf="compile->default"/>
<dependency org="org.jboss" name="jboss-common-core" rev="2.0.4.GA" conf="compile->default"/>
<dependency org="org.jboss" name="javassist" rev="3.3.ga" conf="compile->default"/>
<dependency org="org.ognl" name="ognl" rev="2.6.9" conf="compile->default"/>
<dependency org="org.springframework" name="spring-aop" rev="2.5.2" conf="compile->default"/>
<dependency org="org.springframework" name="spring-orm" rev="2.5.2" conf="compile->default"/>
<dependency org="org.springframework" name="spring-jdbc" rev="2.5.2" conf="compile->default"/>
<dependency org="org.springframework" name="spring-orm" rev="2.5.2" conf="compile->default"/>
<dependency org="org.springframework" name="spring-tx" rev="2.5.2" conf="compile->default"/>
<dependency org="org.springframework.security" name="spring-security-core" rev="2.0.0.m2"/>
<dependency org="org.springframework.security" name="spring-security-taglibs" rev="2.0.0.m2"/>
<dependency org="org.springframework.webflow" name="spring-faces" rev="latest.integration" conf="compile->compile"/>
<dependency org="org.springframework.webflow" name="spring-webflow" rev="latest.integration" conf="compile->compile"/>
<dependency org="org.springframework.webflow" name="spring-js" rev="latest.integration" conf="compile->compile"/>
<dependency org="org.springframework.webflow" name="spring-js" rev="latest.integration" conf="compile->compile"/>
<dependency org="org.springframework.webflow" name="spring-webflow" rev="latest.integration" conf="compile->compile"/>
<dependency org="net.sf.cglib" name="cglib_nodep" rev="2.1.3" conf="compile->default"/>
<!-- concurrent Required by "jboss archive browsing" which is used by hibernate-entity manager but not noted in their docs -->
<dependency org="edu.oswego.cs" name="concurrent" rev="1.3.4" conf="compile->default"/>
<!-- build-time only dependencies -->
<dependency org="javax.servlet" name="servlet-api" rev="2.4" conf="provided->default"/>