Browse Source

javado polish

conversation
Keith Donald 16 years ago
parent
commit
b8b84f4f39
  1. 29
      org.springframework.context/src/main/java/org/springframework/ui/format/AnnotationFormatterFactory.java
  2. 1
      org.springframework.context/src/main/java/org/springframework/ui/format/Formatter.java
  3. 19
      org.springframework.context/src/main/java/org/springframework/ui/format/number/CurrencyAnnotationFormatterFactory.java
  4. 17
      org.springframework.context/src/main/java/org/springframework/ui/format/number/CurrencyFormat.java

29
org.springframework.context/src/main/java/org/springframework/ui/format/AnnotationFormatterFactory.java

@ -1,7 +1,36 @@ @@ -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 <code>CurrencyAnnotationFormatterFactory</code> might create a {@link Formatter} that formats a <code>BigDecimal</code> value set on a property annotated with <code>@CurrencyFormat</code>.
* @author Keith Donald
* @param <A> The type of Annotation this factory uses to create Formatter instances
* @param <T> The type of Object Formatters created by this factory format
*/
public interface AnnotationFormatterFactory<A extends Annotation, T> {
/**
* 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<T> getFormatter(A annotation);
}

1
org.springframework.context/src/main/java/org/springframework/ui/format/Formatter.java

@ -35,7 +35,6 @@ public interface Formatter<T> { @@ -35,7 +35,6 @@ public interface Formatter<T> {
/**
* 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

19
org.springframework.context/src/main/java/org/springframework/ui/format/number/CurrencyAnnotationFormatterFactory.java

@ -1,3 +1,18 @@ @@ -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; @@ -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<CurrencyFormat, BigDecimal> {
public Formatter<BigDecimal> getFormatter(CurrencyFormat annotation) {
return new CurrencyFormatter();

17
org.springframework.context/src/main/java/org/springframework/ui/format/number/CurrencyFormat.java

@ -1,3 +1,18 @@ @@ -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; @@ -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 })

Loading…
Cancel
Save