diff --git a/org.springframework.context/src/main/java/org/springframework/ui/format/AnnotationFormatterFactory.java b/org.springframework.context/src/main/java/org/springframework/ui/format/AnnotationFormatterFactory.java index 4ffcd9655f..eccdeed4e9 100644 --- a/org.springframework.context/src/main/java/org/springframework/ui/format/AnnotationFormatterFactory.java +++ b/org.springframework.context/src/main/java/org/springframework/ui/format/AnnotationFormatterFactory.java @@ -1,7 +1,36 @@ +/* + * 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; import java.lang.annotation.Annotation; +/** + * A factory that creates Formatters to format property values on properties annotated with a particular format {@link Annotation}. + * For example, a CurrencyAnnotationFormatterFactory might create a {@link Formatter} that formats a BigDecimal value set on a property annotated with @CurrencyFormat. + * @author Keith Donald + * @param The type of Annotation this factory uses to create Formatter instances + * @param The type of Object Formatters created by this factory format + */ public interface AnnotationFormatterFactory { + + /** + * Get the Formatter that will format the value of the property annotated with the provided annotation. + * The annotation instance can contain properties that may be used to configure the Formatter that is returned. + * @param annotation the annotation instance + * @return the Formatter to use to format values of properties annotated with the annotation. + */ Formatter getFormatter(A annotation); } diff --git a/org.springframework.context/src/main/java/org/springframework/ui/format/Formatter.java b/org.springframework.context/src/main/java/org/springframework/ui/format/Formatter.java index 1f3b01e9d9..012c31e2f6 100644 --- a/org.springframework.context/src/main/java/org/springframework/ui/format/Formatter.java +++ b/org.springframework.context/src/main/java/org/springframework/ui/format/Formatter.java @@ -35,7 +35,6 @@ public interface Formatter { /** * Parse an object from its formatted representation. - * TODO - remove dependency on java.text by replacing ParseException? * @param formatted a formatted representation * @param locale the user's locale * @return the parsed object diff --git a/org.springframework.context/src/main/java/org/springframework/ui/format/number/CurrencyAnnotationFormatterFactory.java b/org.springframework.context/src/main/java/org/springframework/ui/format/number/CurrencyAnnotationFormatterFactory.java index 972cfe8c80..f28f8b6142 100644 --- a/org.springframework.context/src/main/java/org/springframework/ui/format/number/CurrencyAnnotationFormatterFactory.java +++ b/org.springframework.context/src/main/java/org/springframework/ui/format/number/CurrencyAnnotationFormatterFactory.java @@ -1,3 +1,18 @@ +/* + * 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.math.BigDecimal; @@ -5,6 +20,10 @@ import java.math.BigDecimal; import org.springframework.ui.format.AnnotationFormatterFactory; import org.springframework.ui.format.Formatter; +/** + * Returns a CurrencyFormatter for properties annotated with the {@link CurrencyFormat} annotation. + * @author Keith Donald + */ public class CurrencyAnnotationFormatterFactory implements AnnotationFormatterFactory { public Formatter getFormatter(CurrencyFormat annotation) { return new CurrencyFormatter(); diff --git a/org.springframework.context/src/main/java/org/springframework/ui/format/number/CurrencyFormat.java b/org.springframework.context/src/main/java/org/springframework/ui/format/number/CurrencyFormat.java index b2bb9fb76b..2d22910b79 100644 --- a/org.springframework.context/src/main/java/org/springframework/ui/format/number/CurrencyFormat.java +++ b/org.springframework.context/src/main/java/org/springframework/ui/format/number/CurrencyFormat.java @@ -1,3 +1,18 @@ +/* + * 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; @@ -7,7 +22,7 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; /** - * A annotation to apply to a BigDecimal property to have property values formatted as currency using a {@link CurrencyFormatter}. + * A annotation to apply to a BigDecimal property to have its value formatted as currency amount using a {@link CurrencyFormatter}. * @author Keith Donald */ @Target( { ElementType.METHOD, ElementType.FIELD })