Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
爱吃血肠
spring-framework
提交
707d2ed7
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,发现更多精彩内容 >>
提交
707d2ed7
编写于
4月 09, 2009
作者:
A
Andy Clement
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Changed signature of convertValue() to keep the Sun compiler happy
上级
362629d0
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
55 addition
and
25 deletion
+55
-25
org.springframework.expression/src/main/java/org/springframework/expression/TypeConverter.java
...in/java/org/springframework/expression/TypeConverter.java
+1
-1
org.springframework.expression/src/main/java/org/springframework/expression/spel/ExpressionState.java
.../org/springframework/expression/spel/ExpressionState.java
+2
-2
org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/ConstructorReference.java
...ngframework/expression/spel/ast/ConstructorReference.java
+1
-1
org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/Indexer.java
...java/org/springframework/expression/spel/ast/Indexer.java
+11
-11
org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/OperatorAnd.java
.../org/springframework/expression/spel/ast/OperatorAnd.java
+2
-2
org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/OperatorNot.java
.../org/springframework/expression/spel/ast/OperatorNot.java
+1
-1
org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/OperatorOr.java
...a/org/springframework/expression/spel/ast/OperatorOr.java
+3
-3
org.springframework.expression/src/main/java/org/springframework/expression/spel/support/StandardTypeConverter.java
...mework/expression/spel/support/StandardTypeConverter.java
+2
-2
org.springframework.expression/src/test/java/org/springframework/expression/spel/ExpressionTestsUsingCoreConversionService.java
...ssion/spel/ExpressionTestsUsingCoreConversionService.java
+2
-2
org.springframework.expression/src/test/java/org/springframework/expression/spel/SpringEL300Tests.java
...org/springframework/expression/spel/SpringEL300Tests.java
+30
-0
未找到文件。
org.springframework.expression/src/main/java/org/springframework/expression/TypeConverter.java
浏览文件 @
707d2ed7
...
...
@@ -48,7 +48,7 @@ public interface TypeConverter {
* @return the converted value
* @throws EvaluationException if conversion is not possible
*/
<
T
>
T
convertValue
(
Object
value
,
TypeDescriptor
typeDescriptor
)
throws
EvaluationException
;
Object
convertValue
(
Object
value
,
TypeDescriptor
typeDescriptor
)
throws
EvaluationException
;
/**
* Return true if the type converter can convert the specified type to the desired target type.
...
...
org.springframework.expression/src/main/java/org/springframework/expression/spel/ExpressionState.java
浏览文件 @
707d2ed7
...
...
@@ -100,11 +100,11 @@ public class ExpressionState {
return
this
.
relatedContext
.
getTypeLocator
().
findType
(
type
);
}
public
<
T
>
T
convertValue
(
Object
value
,
TypeDescriptor
targetTypeDescriptor
)
throws
EvaluationException
{
public
Object
convertValue
(
Object
value
,
TypeDescriptor
targetTypeDescriptor
)
throws
EvaluationException
{
return
this
.
relatedContext
.
getTypeConverter
().
convertValue
(
value
,
targetTypeDescriptor
);
}
public
<
T
>
T
convertValue
(
TypedValue
value
,
TypeDescriptor
targetTypeDescriptor
)
throws
EvaluationException
{
public
Object
convertValue
(
TypedValue
value
,
TypeDescriptor
targetTypeDescriptor
)
throws
EvaluationException
{
return
this
.
relatedContext
.
getTypeConverter
().
convertValue
(
value
.
getValue
(),
targetTypeDescriptor
);
}
...
...
org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/ConstructorReference.java
浏览文件 @
707d2ed7
...
...
@@ -76,7 +76,7 @@ public class ConstructorReference extends SpelNodeImpl {
TypedValue
childValue
=
getChild
(
i
+
1
).
getValueInternal
(
state
);
Object
value
=
childValue
.
getValue
();
arguments
[
i
]
=
value
;
argumentTypes
[
i
]
=
value
==
null
?
Object
.
class
:
value
.
getClass
(
);
argumentTypes
[
i
]
=
(
value
==
null
?
Object
.
class
:
value
.
getClass
()
);
}
ConstructorExecutor
executorToUse
=
this
.
cachedExecutor
;
...
...
org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/Indexer.java
浏览文件 @
707d2ed7
...
...
@@ -58,7 +58,7 @@ public class Indexer extends SpelNodeImpl {
return
new
TypedValue
(
o
,
TypeDescriptor
.
valueOf
(
targetObjectTypeDescriptor
.
getMapValueType
()));
}
int
idx
=
state
.
convertValue
(
index
,
INTEGER_TYPE_DESCRIPTOR
);
int
idx
=
(
Integer
)
state
.
convertValue
(
index
,
INTEGER_TYPE_DESCRIPTOR
);
if
(
targetObject
==
null
)
{
throw
new
SpelException
(
SpelMessages
.
CANNOT_INDEX_INTO_NULL_VALUE
);
...
...
@@ -115,10 +115,10 @@ public class Indexer extends SpelNodeImpl {
}
if
(
targetObjectTypeDescriptor
.
isArray
())
{
int
idx
=
state
.
convertValue
(
index
,
INTEGER_TYPE_DESCRIPTOR
);
int
idx
=
(
Integer
)
state
.
convertValue
(
index
,
INTEGER_TYPE_DESCRIPTOR
);
setArrayElement
(
state
,
contextObject
.
getValue
(),
idx
,
newValue
,
targetObjectTypeDescriptor
.
getElementType
());
}
else
if
(
targetObjectTypeDescriptor
.
isCollection
())
{
int
idx
=
state
.
convertValue
(
index
,
INTEGER_TYPE_DESCRIPTOR
);
int
idx
=
(
Integer
)
state
.
convertValue
(
index
,
INTEGER_TYPE_DESCRIPTOR
);
Collection
c
=
(
Collection
)
targetObject
;
if
(
idx
>=
c
.
size
())
{
throw
new
SpelException
(
SpelMessages
.
COLLECTION_INDEX_OUT_OF_BOUNDS
,
c
.
size
(),
idx
);
...
...
@@ -153,35 +153,35 @@ public class Indexer extends SpelNodeImpl {
if
(
arrayComponentType
==
Integer
.
TYPE
)
{
int
[]
array
=
(
int
[])
ctx
;
checkAccess
(
array
.
length
,
idx
);
array
[
idx
]
=
state
.
convertValue
(
newValue
,
INTEGER_TYPE_DESCRIPTOR
);
array
[
idx
]
=
(
Integer
)
state
.
convertValue
(
newValue
,
INTEGER_TYPE_DESCRIPTOR
);
}
else
if
(
arrayComponentType
==
Boolean
.
TYPE
)
{
boolean
[]
array
=
(
boolean
[])
ctx
;
checkAccess
(
array
.
length
,
idx
);
array
[
idx
]
=
state
.
convertValue
(
newValue
,
BOOLEAN_TYPE_DESCRIPTOR
);
array
[
idx
]
=
(
Boolean
)
state
.
convertValue
(
newValue
,
BOOLEAN_TYPE_DESCRIPTOR
);
}
else
if
(
arrayComponentType
==
Character
.
TYPE
)
{
char
[]
array
=
(
char
[])
ctx
;
checkAccess
(
array
.
length
,
idx
);
array
[
idx
]
=
state
.
convertValue
(
newValue
,
CHARACTER_TYPE_DESCRIPTOR
);
array
[
idx
]
=
(
Character
)
state
.
convertValue
(
newValue
,
CHARACTER_TYPE_DESCRIPTOR
);
}
else
if
(
arrayComponentType
==
Long
.
TYPE
)
{
long
[]
array
=
(
long
[])
ctx
;
checkAccess
(
array
.
length
,
idx
);
array
[
idx
]
=
state
.
convertValue
(
newValue
,
LONG_TYPE_DESCRIPTOR
);
array
[
idx
]
=
(
Long
)
state
.
convertValue
(
newValue
,
LONG_TYPE_DESCRIPTOR
);
}
else
if
(
arrayComponentType
==
Short
.
TYPE
)
{
short
[]
array
=
(
short
[])
ctx
;
checkAccess
(
array
.
length
,
idx
);
array
[
idx
]
=
state
.
convertValue
(
newValue
,
SHORT_TYPE_DESCRIPTOR
);
array
[
idx
]
=
(
Short
)
state
.
convertValue
(
newValue
,
SHORT_TYPE_DESCRIPTOR
);
}
else
if
(
arrayComponentType
==
Double
.
TYPE
)
{
double
[]
array
=
(
double
[])
ctx
;
checkAccess
(
array
.
length
,
idx
);
array
[
idx
]
=
state
.
convertValue
(
newValue
,
DOUBLE_TYPE_DESCRIPTOR
);
array
[
idx
]
=
(
Double
)
state
.
convertValue
(
newValue
,
DOUBLE_TYPE_DESCRIPTOR
);
}
else
if
(
arrayComponentType
==
Float
.
TYPE
)
{
float
[]
array
=
(
float
[])
ctx
;
checkAccess
(
array
.
length
,
idx
);
array
[
idx
]
=
state
.
convertValue
(
newValue
,
FLOAT_TYPE_DESCRIPTOR
);
array
[
idx
]
=
(
Float
)
state
.
convertValue
(
newValue
,
FLOAT_TYPE_DESCRIPTOR
);
}
else
if
(
arrayComponentType
==
Byte
.
TYPE
)
{
byte
[]
array
=
(
byte
[])
ctx
;
checkAccess
(
array
.
length
,
idx
);
array
[
idx
]
=
state
.
convertValue
(
newValue
,
BYTE_TYPE_DESCRIPTOR
);
array
[
idx
]
=
(
Byte
)
state
.
convertValue
(
newValue
,
BYTE_TYPE_DESCRIPTOR
);
}
else
{
Object
[]
array
=
(
Object
[])
ctx
;
checkAccess
(
array
.
length
,
idx
);
...
...
org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/OperatorAnd.java
浏览文件 @
707d2ed7
...
...
@@ -46,7 +46,7 @@ public class OperatorAnd extends Operator {
boolean
rightValue
;
try
{
leftValue
=
state
.
convertValue
(
getLeftOperand
().
getValueInternal
(
state
),
BOOLEAN_TYPE_DESCRIPTOR
);
leftValue
=
(
Boolean
)
state
.
convertValue
(
getLeftOperand
().
getValueInternal
(
state
),
BOOLEAN_TYPE_DESCRIPTOR
);
}
catch
(
SpelException
ee
)
{
ee
.
setPosition
(
getLeftOperand
().
getCharPositionInLine
());
...
...
@@ -58,7 +58,7 @@ public class OperatorAnd extends Operator {
}
try
{
rightValue
=
state
.
convertValue
(
getRightOperand
().
getValueInternal
(
state
),
BOOLEAN_TYPE_DESCRIPTOR
);
rightValue
=
(
Boolean
)
state
.
convertValue
(
getRightOperand
().
getValueInternal
(
state
),
BOOLEAN_TYPE_DESCRIPTOR
);
}
catch
(
SpelException
ee
)
{
ee
.
setPosition
(
getRightOperand
().
getCharPositionInLine
());
...
...
org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/OperatorNot.java
浏览文件 @
707d2ed7
...
...
@@ -37,7 +37,7 @@ public class OperatorNot extends SpelNodeImpl { // Not is a unary operator so do
@Override
public
BooleanTypedValue
getValueInternal
(
ExpressionState
state
)
throws
EvaluationException
{
try
{
boolean
value
=
state
.
convertValue
(
getChild
(
0
).
getValueInternal
(
state
),
BOOLEAN_TYPE_DESCRIPTOR
);
boolean
value
=
(
Boolean
)
state
.
convertValue
(
getChild
(
0
).
getValueInternal
(
state
),
BOOLEAN_TYPE_DESCRIPTOR
);
return
BooleanTypedValue
.
forValue
(!
value
);
}
catch
(
SpelException
see
)
{
...
...
org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/OperatorOr.java
浏览文件 @
707d2ed7
...
...
@@ -43,8 +43,8 @@ public class OperatorOr extends Operator {
public
BooleanTypedValue
getValueInternal
(
ExpressionState
state
)
throws
EvaluationException
{
boolean
leftValue
;
boolean
rightValue
;
try
{
leftValue
=
state
.
convertValue
(
getLeftOperand
().
getValueInternal
(
state
),
BOOLEAN_TYPE_DESCRIPTOR
);
try
{
leftValue
=
(
Boolean
)
state
.
convertValue
(
getLeftOperand
().
getValueInternal
(
state
),
BOOLEAN_TYPE_DESCRIPTOR
);
}
catch
(
SpelException
see
)
{
see
.
setPosition
(
getLeftOperand
().
getCharPositionInLine
());
...
...
@@ -56,7 +56,7 @@ public class OperatorOr extends Operator {
}
try
{
rightValue
=
state
.
convertValue
(
getRightOperand
().
getValueInternal
(
state
),
BOOLEAN_TYPE_DESCRIPTOR
);
rightValue
=
(
Boolean
)
state
.
convertValue
(
getRightOperand
().
getValueInternal
(
state
),
BOOLEAN_TYPE_DESCRIPTOR
);
}
catch
(
SpelException
see
)
{
see
.
setPosition
(
getRightOperand
().
getCharPositionInLine
());
...
...
org.springframework.expression/src/main/java/org/springframework/expression/spel/support/StandardTypeConverter.java
浏览文件 @
707d2ed7
...
...
@@ -86,7 +86,7 @@ public class StandardTypeConverter implements TypeConverter {
}
@SuppressWarnings
(
"unchecked"
)
public
<
T
>
T
convertValue
(
Object
value
,
TypeDescriptor
typeDescriptor
)
throws
EvaluationException
{
public
Object
convertValue
(
Object
value
,
TypeDescriptor
typeDescriptor
)
throws
EvaluationException
{
// For activation when conversion service available - this replaces the rest of the method (probably...)
// try {
// return (T)conversionService.executeConversion(value, typeDescriptor);
...
...
@@ -95,7 +95,7 @@ public class StandardTypeConverter implements TypeConverter {
// } catch (ConversionException ce) {
// throw new SpelException(ce, SpelMessages.TYPE_CONVERSION_ERROR, value.getClass(), typeDescriptor.asString());
// }
return
(
T
)
convertValue
(
value
,
typeDescriptor
.
getType
());
return
convertValue
(
value
,
typeDescriptor
.
getType
());
}
public
boolean
canConvert
(
Class
<?>
sourceType
,
Class
<?>
targetType
)
{
...
...
org.springframework.expression/src/test/java/org/springframework/expression/spel/ExpressionTestsUsingCoreConversionService.java
浏览文件 @
707d2ed7
...
...
@@ -111,9 +111,9 @@ public class ExpressionTestsUsingCoreConversionService extends ExpressionTestCas
}
@SuppressWarnings
(
"unchecked"
)
public
<
T
>
T
convertValue
(
Object
value
,
TypeDescriptor
typeDescriptor
)
public
Object
convertValue
(
Object
value
,
TypeDescriptor
typeDescriptor
)
throws
EvaluationException
{
return
(
T
)
super
.
executeConversion
(
value
,
typeDescriptor
);
return
super
.
executeConversion
(
value
,
typeDescriptor
);
}
}
...
...
org.springframework.expression/src/test/java/org/springframework/expression/spel/SpringEL300Tests.java
0 → 100644
浏览文件 @
707d2ed7
/*
* Copyright 2002-2009 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.springframework.expression.spel
;
/**
* Tests based on Jiras up to the release of Spring 3.0.0
*
* @author Andy Clement
*/
public
class
SpringEL300Tests
extends
ExpressionTestCase
{
public
void
testNPE_5661
()
{
evaluate
(
"joinThreeStrings('a',null,'c')"
,
"anullc"
,
String
.
class
);
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录