Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
爱吃血肠
spring-framework
提交
3d4158ea
S
spring-framework
项目概览
爱吃血肠
/
spring-framework
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
spring-framework
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
3d4158ea
编写于
8月 16, 2008
作者:
A
Andy Clement
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
implements new interface methods. sorting out javadoc
上级
98c82fe9
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
35 addition
and
44 deletion
+35
-44
org.springframework.expression/src/main/java/org/springframework/expression/spel/SpelExpression.java
...a/org/springframework/expression/spel/SpelExpression.java
+35
-44
未找到文件。
org.springframework.expression/src/main/java/org/springframework/expression/spel/SpelExpression.java
浏览文件 @
3d4158ea
...
...
@@ -18,12 +18,10 @@ package org.springframework.expression.spel;
import
org.springframework.expression.EvaluationContext
;
import
org.springframework.expression.EvaluationException
;
import
org.springframework.expression.Expression
;
import
org.springframework.expression.common.ExpressionUtils
;
import
org.springframework.expression.spel.ast.SpelNode
;
import
org.springframework.expression.spel.standard.StandardEvaluationContext
;
// TODO 3 Do we need more getValue() options - for example with just a root object or with a set of variables?
// (these things are currently captured in the Context)
/**
* A SpelExpressions represents a parsed (valid) expression that is ready to be evaluated in a specified context. An
* expression can be evaluated standalone or in a specified context. During expression evaluation the context may be
...
...
@@ -55,44 +53,22 @@ public class SpelExpression implements Expression {
}
/**
* Evaluate the expression in a default context that knows nothing (and therefore cannot resolve references to
* properties/etc). Only useful for trivial expressions like '3+4'.
*
* @return the value of the expression
* @throws SpelException if there is a problem with evaluation of the expression
* {@inheritDoc}
*/
public
Object
getValue
()
throws
EvaluationException
{
EvaluationContext
eContext
=
new
StandardEvaluationContext
();
return
ast
.
getValue
(
new
ExpressionState
(
eContext
));
}
// public Class<?> getValueType() throws ELException {
// return ast.getValueType(new ExpressionState());
// }
/**
* Evaluate the expression in a specified context which can resolve references to properties, methods, types, etc.
* The {@link StandardEvaluationContext} can be sub classed and overridden where necessary, rather than implementing
* the entire EvaluationContext interface.
*
* @param context the context in which to evaluate the expression
* @return the value of the expression
* @throws SpelException if there is a problem with evaluation of the expression.
* {@inheritDoc}
*/
public
Object
getValue
(
EvaluationContext
context
)
throws
EvaluationException
{
return
ast
.
getValue
(
new
ExpressionState
(
context
));
}
/**
* Evaluate the expression in a specified context which can resolve references to properties, methods, types, etc -
* the type of the evaluation result is expected to be of a particular class and an exception will be thrown if it
* is not and cannot be converted to that type. The {@link StandardEvaluationContext} can be sub classed and
* overridden where necessary, rather than implementing the entire EvaluationContext interface.
*
* @param context the context in which to evaluate the expression
* @param expectedResultType the class the caller would like the result to be
* @return the value of the expression
* @throws SpelException if there is a problem with evaluation of the expression.
* {@inheritDoc}
*/
public
Object
getValue
(
EvaluationContext
context
,
Class
<?>
expectedResultType
)
throws
EvaluationException
{
Object
result
=
ast
.
getValue
(
new
ExpressionState
(
context
));
...
...
@@ -109,23 +85,14 @@ public class SpelExpression implements Expression {
}
/**
* Evaluate an expression and set the result to the specified value. This only makes sense when working with the
* expression against a context.
*
* @param context the context in which to evaluate the expression
* @param value the new value
* @throws SpelException if there is a problem with evaluation of the expression.
* {@inheritDoc}
*/
public
void
setValue
(
EvaluationContext
context
,
Object
value
)
throws
EvaluationException
{
ast
.
setValue
(
new
ExpressionState
(
context
),
value
);
}
/**
* Determine if an expression evaluates to an value that can be set with a value (for example, a property).
*
* @param context the context in which to evaluate the expression
* @return true if the expression supports setValue()
* @throws SpelException if there is a problem with evaluation of the expression.
* {@inheritDoc}
*/
public
boolean
isWritable
(
EvaluationContext
context
)
throws
EvaluationException
{
return
ast
.
isWritable
(
new
ExpressionState
(
context
));
...
...
@@ -148,15 +115,39 @@ public class SpelExpression implements Expression {
public
String
toStringAST
()
{
return
ast
.
toStringAST
();
}
/**
* {@inheritDoc}
*/
public
Class
getValueType
(
EvaluationContext
context
)
throws
EvaluationException
{
// TODO Auto-generated method stub
throw
new
UnsupportedOperationException
(
"Auto-generated method stub"
);
// TODO is this a legal implementation? The null return value could be very unhelpful. See other getValueType()
// also.
Object
value
=
getValue
(
context
);
if
(
value
==
null
)
{
return
null
;
}
else
{
return
value
.
getClass
();
}
}
/**
* {@inheritDoc}
*/
public
Class
getValueType
()
throws
EvaluationException
{
Object
value
=
getValue
();
if
(
value
==
null
)
{
return
null
;
}
else
{
return
value
.
getClass
();
}
}
/**
* {@inheritDoc}
*/
public
Object
getValue
(
Class
<?>
expectedResultType
)
throws
EvaluationException
{
// TODO Auto-generated method stub
throw
new
UnsupportedOperationException
(
"Auto-generated method stub"
);
Object
result
=
getValue
();
return
ExpressionUtils
.
convert
(
null
,
result
,
expectedResultType
);
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录