Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
爱吃血肠
spring-framework
提交
2bd664f7
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,发现更多精彩内容 >>
提交
2bd664f7
编写于
8月 19, 2009
作者:
K
Keith Donald
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
removed framework specific annotation in favor of user-defined for now
上级
704cc79c
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
19 addition
and
42 deletion
+19
-42
org.springframework.context/src/main/java/org/springframework/ui/format/FormatterRegistry.java
...java/org/springframework/ui/format/FormatterRegistry.java
+4
-4
org.springframework.context/src/main/java/org/springframework/ui/format/number/CurrencyFormat.java
.../org/springframework/ui/format/number/CurrencyFormat.java
+0
-34
org.springframework.context/src/test/java/org/springframework/ui/format/GenericFormatterRegistryTests.java
...ingframework/ui/format/GenericFormatterRegistryTests.java
+15
-4
未找到文件。
org.springframework.context/src/main/java/org/springframework/ui/format/FormatterRegistry.java
浏览文件 @
2bd664f7
...
...
@@ -38,8 +38,8 @@ public interface FormatterRegistry {
* Adds a Formatter to this registry indexed by type.
* Use this add method when type differs from <T>.
* Calling getFormatter(type) returns a decorator that wraps the targetFormatter.
* On format, the decorator first coerses the instance of t
T
ype to <T>, then delegates to <code>targetFormatter</code> to format the value.
* On parse, the decorator first delegates to the formatter to parse a <T>, then coerses the parsed value to
objectT
ype.
* On format, the decorator first coerses the instance of type to <T>, then delegates to <code>targetFormatter</code> to format the value.
* On parse, the decorator first delegates to the formatter to parse a <T>, then coerses the parsed value to
t
ype.
* @param type the object type
* @param targetFormatter the target formatter
* @param <T> the type of object the target formatter formats
...
...
@@ -47,14 +47,14 @@ public interface FormatterRegistry {
<
T
>
void
add
(
Class
<?>
type
,
Formatter
<
T
>
targetFormatter
);
/**
* Adds a AnnotationFormatterFactory that
will format values of
properties annotated with a specific annotation.
* Adds a AnnotationFormatterFactory that
returns the Formatter for
properties annotated with a specific annotation.
* @param factory the annotation formatter factory
*/
<
A
extends
Annotation
,
T
>
void
add
(
AnnotationFormatterFactory
<
A
,
T
>
factory
);
/**
* Get the Formatter for the type descriptor.
* @return the Formatter, or <code>null</code> if none is registered
* @return the Formatter, or <code>null</code> if no
suitable o
ne is registered
*/
@SuppressWarnings
(
"unchecked"
)
Formatter
getFormatter
(
TypeDescriptor
type
);
...
...
org.springframework.context/src/main/java/org/springframework/ui/format/number/CurrencyFormat.java
已删除
100644 → 0
浏览文件 @
704cc79c
/*
* Copyright 2004-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.ui.format.number
;
import
java.lang.annotation.Documented
;
import
java.lang.annotation.ElementType
;
import
java.lang.annotation.Retention
;
import
java.lang.annotation.RetentionPolicy
;
import
java.lang.annotation.Target
;
/**
* A annotation to apply to a BigDecimal property to have its value formatted as currency amount using a {@link CurrencyFormatter}.
* @author Keith Donald
* @since 3.0
*/
@Target
(
{
ElementType
.
METHOD
,
ElementType
.
FIELD
})
@Retention
(
RetentionPolicy
.
RUNTIME
)
@Documented
public
@interface
CurrencyFormat
{
}
org.springframework.context/src/test/java/org/springframework/ui/format/GenericFormatterRegistryTests.java
浏览文件 @
2bd664f7
...
...
@@ -3,6 +3,11 @@ package org.springframework.ui.format;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertNull
;
import
java.lang.annotation.Documented
;
import
java.lang.annotation.ElementType
;
import
java.lang.annotation.Retention
;
import
java.lang.annotation.RetentionPolicy
;
import
java.lang.annotation.Target
;
import
java.math.BigDecimal
;
import
java.math.BigInteger
;
import
java.text.ParseException
;
...
...
@@ -12,7 +17,6 @@ import org.junit.Before;
import
org.junit.Test
;
import
org.springframework.core.convert.TypeDescriptor
;
import
org.springframework.core.style.ToStringCreator
;
import
org.springframework.ui.format.number.CurrencyFormat
;
import
org.springframework.ui.format.number.CurrencyFormatter
;
import
org.springframework.ui.format.number.IntegerFormatter
;
...
...
@@ -73,7 +77,7 @@ public class GenericFormatterRegistryTests {
registry
.
add
(
Integer
.
class
,
new
AddressFormatter
());
}
@Currency
Format
@Currency
public
BigDecimal
currencyField
;
private
static
TypeDescriptor
typeDescriptor
(
Class
<?>
clazz
)
{
...
...
@@ -81,11 +85,11 @@ public class GenericFormatterRegistryTests {
}
public
static
class
CurrencyAnnotationFormatterFactory
implements
AnnotationFormatterFactory
<
Currency
Format
,
BigDecimal
>
{
AnnotationFormatterFactory
<
Currency
,
BigDecimal
>
{
private
CurrencyFormatter
currencyFormatter
=
new
CurrencyFormatter
();
public
Formatter
<
BigDecimal
>
getFormatter
(
Currency
Format
annotation
)
{
public
Formatter
<
BigDecimal
>
getFormatter
(
Currency
annotation
)
{
return
currencyFormatter
;
}
}
...
...
@@ -161,5 +165,12 @@ public class GenericFormatterRegistryTests {
}
}
@Target
(
{
ElementType
.
METHOD
,
ElementType
.
FIELD
})
@Retention
(
RetentionPolicy
.
RUNTIME
)
@Documented
public
@interface
Currency
{
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录