Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
爱吃血肠
spring-framework
提交
51bac37d
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,体验更适合开发者的 AI 搜索 >>
提交
51bac37d
编写于
8月 09, 2012
作者:
S
Sam Brannen
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #116 from aclement/SPR-9620
* SPR-9620: Support nested double quotes in SpEL expressions
上级
0d963a69
75944cc8
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
32 addition
and
4 deletion
+32
-4
spring-expression/src/main/java/org/springframework/expression/spel/SpelMessage.java
...java/org/springframework/expression/spel/SpelMessage.java
+2
-1
spring-expression/src/main/java/org/springframework/expression/spel/ast/StringLiteral.java
...rg/springframework/expression/spel/ast/StringLiteral.java
+2
-2
spring-expression/src/main/java/org/springframework/expression/spel/standard/Tokenizer.java
...g/springframework/expression/spel/standard/Tokenizer.java
+8
-1
spring-expression/src/test/java/org/springframework/expression/spel/standard/SpelParserTests.java
...ngframework/expression/spel/standard/SpelParserTests.java
+19
-0
src/dist/changelog.txt
src/dist/changelog.txt
+1
-0
未找到文件。
spring-expression/src/main/java/org/springframework/expression/spel/SpelMessage.java
浏览文件 @
51bac37d
/*
* Copyright 2002-20
09
the original author or authors.
* Copyright 2002-20
12
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.
...
...
@@ -104,6 +104,7 @@ public enum SpelMessage {
MISSING_ARRAY_DIMENSION
(
Kind
.
ERROR
,
1063
,
"A required array dimension has not been specified"
),
//
INITIALIZER_LENGTH_INCORRECT
(
Kind
.
ERROR
,
1064
,
"array initializer size does not match array dimensions"
),
//
UNEXPECTED_ESCAPE_CHAR
(
Kind
.
ERROR
,
1065
,
"unexpected escape character."
);
;
private
Kind
kind
;
...
...
spring-expression/src/main/java/org/springframework/expression/spel/ast/StringLiteral.java
浏览文件 @
51bac37d
/*
* Copyright 2002-20
09
the original author or authors.
* Copyright 2002-20
12
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.
...
...
@@ -31,7 +31,7 @@ public class StringLiteral extends Literal {
super
(
payload
,
pos
);
// TODO should these have been skipped being created by the parser rules? or not?
value
=
value
.
substring
(
1
,
value
.
length
()
-
1
);
this
.
value
=
new
TypedValue
(
value
.
replaceAll
(
"''"
,
"'"
));
this
.
value
=
new
TypedValue
(
value
.
replaceAll
(
"''"
,
"'"
)
.
replaceAll
(
"\"\""
,
"\""
)
);
}
@Override
...
...
spring-expression/src/main/java/org/springframework/expression/spel/standard/Tokenizer.java
浏览文件 @
51bac37d
...
...
@@ -199,6 +199,8 @@ class Tokenizer {
// hit sentinel at end of value
pos
++;
// will take us to the end
break
;
case
'\\'
:
throw
new
InternalParseException
(
new
SpelParseException
(
expressionString
,
pos
,
SpelMessage
.
UNEXPECTED_ESCAPE_CHAR
));
default
:
throw
new
IllegalStateException
(
"Cannot handle ("
+
Integer
.
valueOf
(
ch
)+
") '"
+
ch
+
"'"
);
}
...
...
@@ -241,7 +243,12 @@ class Tokenizer {
pos
++;
char
ch
=
toProcess
[
pos
];
if
(
ch
==
'"'
)
{
terminated
=
true
;
// may not be the end if the char after is also a "
if
(
toProcess
[
pos
+
1
]==
'"'
)
{
pos
++;
// skip over that too, and continue
}
else
{
terminated
=
true
;
}
}
if
(
ch
==
0
)
{
throw
new
InternalParseException
(
new
SpelParseException
(
expressionString
,
start
,
SpelMessage
.
NON_TERMINATING_DOUBLE_QUOTED_STRING
));
...
...
spring-expression/src/test/java/org/springframework/expression/spel/standard/SpelParserTests.java
浏览文件 @
51bac37d
...
...
@@ -261,6 +261,25 @@ public class SpelParserTests {
assertEquals
(
"ho"
,
expr
.
getValue
());
}
@Test
public
void
testStringLiterals_DoubleQuotes_spr9620
()
throws
Exception
{
SpelExpression
expr
=
new
SpelExpressionParser
().
parseRaw
(
"\"double quote: \"\".\""
);
assertEquals
(
"double quote: \"."
,
expr
.
getValue
());
expr
=
new
SpelExpressionParser
().
parseRaw
(
"\"hello \"\" world\""
);
assertEquals
(
"hello \" world"
,
expr
.
getValue
());
}
@Test
public
void
testStringLiterals_DoubleQuotes_spr9620_2
()
throws
Exception
{
try
{
new
SpelExpressionParser
().
parseRaw
(
"\"double quote: \\\"\\\".\""
);
fail
(
"Should have failed"
);
}
catch
(
SpelParseException
spe
)
{
assertEquals
(
17
,
spe
.
getPosition
());
assertEquals
(
SpelMessage
.
UNEXPECTED_ESCAPE_CHAR
,
spe
.
getMessageCode
());
}
}
@Test
public
void
positionalInformation
()
throws
EvaluationException
,
ParseException
{
SpelExpression
expr
=
new
SpelExpressionParser
().
parseRaw
(
"true and true or false"
);
...
...
src/dist/changelog.txt
浏览文件 @
51bac37d
...
...
@@ -10,6 +10,7 @@ Changes in version 3.2 M2 (2012-08-xx)
* now inferring return type of generic factory methods (SPR-9493)
* SpEL now supports method invocations on integers (SPR-9612)
* SpEL now supports symbolic boolean operators for OR and AND (SPR-9614)
* SpEL now supports nested double quotes in expressions (SPR-9620)
* introduced support for case-insensitive null literals in SpEL expressions (SPR-9613)
* now using BufferedInputStream in SimpleMetaDataReader to double performance (SPR-9528)
* introduced "repeatCount" property in Quartz SimpleTriggerFactoryBean (SPR-9521)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录