Top Description Inners Fields Constructors Methods
org.springframework.format.number.money

public Class Jsr354NumberFormatAnnotationFormatterFactory

extends EmbeddedValueResolutionSupport
implements AnnotationFormatterFactory<NumberFormat>
Class Inheritance
All Implemented Interfaces
org.springframework.format.AnnotationFormatterFactory
Imports
java.text.ParseException, java.util.Collections, .Currency, .Locale, .Set, javax.money.CurrencyUnit, .Monetary, .MonetaryAmount, org.springframework.context.support.EmbeddedValueResolutionSupport, org.springframework.format.AnnotationFormatterFactory, .Formatter, .Parser, .Printer, org.springframework.format.annotation.NumberFormat, .NumberFormat.Style, org.springframework.format.number.CurrencyStyleFormatter, .NumberStyleFormatter, .PercentStyleFormatter, org.springframework.util.StringUtils

Formats javax.money.MonetaryAmount fields annotated with Spring's common NumberFormat annotation.
Author
Juergen Hoeller
Since
4.2
See Also
NumberFormat

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
private static class

Field Summary

Modifier and TypeField and Description
private static final String

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private Formatter<MonetaryAmount>
public Set<Class<?>>
getFieldTypes()

Implements org.springframework.format.AnnotationFormatterFactory.getFieldTypes.

The types of fields that may be annotated with the <A> annotation.

public Parser<MonetaryAmount>
getParser(NumberFormat
the annotation instance
annotation
,
Class<?>
the type of field that was annotated
fieldType
)

Implements org.springframework.format.AnnotationFormatterFactory.getParser.

Get the Parser to parse a submitted value for a field of fieldType annotated with annotation.

public Printer<MonetaryAmount>
getPrinter(NumberFormat
the annotation instance
annotation
,
Class<?>
the type of field that was annotated
fieldType
)

Implements org.springframework.format.AnnotationFormatterFactory.getPrinter.

Get the Printer to print the value of a field of fieldType annotated with annotation.

Inherited from org.springframework.context.support.EmbeddedValueResolutionSupport:
resolveEmbeddedValuesetEmbeddedValueResolver

Field Detail

CURRENCY_CODE_PATTERNback to summary
private static final String CURRENCY_CODE_PATTERN

Constructor Detail

Jsr354NumberFormatAnnotationFormatterFactoryback to summary
public Jsr354NumberFormatAnnotationFormatterFactory()

Method Detail

configureFormatterFromback to summary
private Formatter<MonetaryAmount> configureFormatterFrom(NumberFormat annotation)
getFieldTypesback to summary
public Set<Class<?>> getFieldTypes()

Implements org.springframework.format.AnnotationFormatterFactory.getFieldTypes.

Doc from org.springframework.format.AnnotationFormatterFactory.getFieldTypes.

The types of fields that may be annotated with the <A> annotation.

Annotations
@Override
getParserback to summary
public Parser<MonetaryAmount> getParser(NumberFormat annotation, Class<?> fieldType)

Implements org.springframework.format.AnnotationFormatterFactory.getParser.

Doc from org.springframework.format.AnnotationFormatterFactory.getParser.

Get the Parser to parse a submitted value for a field of fieldType annotated with annotation.

If the object the parser returns is not assignable to fieldType, a coercion to fieldType will be attempted before the field is set.

Parameters
annotation:NumberFormat

the annotation instance

fieldType:Class<?>

the type of field that was annotated

Returns:Parser<MonetaryAmount>

the parser

Annotations
@Override
getPrinterback to summary
public Printer<MonetaryAmount> getPrinter(NumberFormat annotation, Class<?> fieldType)

Implements org.springframework.format.AnnotationFormatterFactory.getPrinter.

Doc from org.springframework.format.AnnotationFormatterFactory.getPrinter.

Get the Printer to print the value of a field of fieldType annotated with annotation.

If the type T the printer accepts is not assignable to fieldType, a coercion from fieldType to T will be attempted before the Printer is invoked.

Parameters
annotation:NumberFormat

the annotation instance

fieldType:Class<?>

the type of field that was annotated

Returns:Printer<MonetaryAmount>

the printer

Annotations
@Override
org.springframework.format.number.money back to summary

private Class Jsr354NumberFormatAnnotationFormatterFactory.NumberDecoratingFormatter

extends Object
implements Formatter<MonetaryAmount>
Class Inheritance
  • java.lang.Object
  • org.springframework.format.number.money.Jsr354NumberFormatAnnotationFormatterFactory.NumberDecoratingFormatter
All Implemented Interfaces
org.springframework.format.Formatter, org.springframework.format.Parser, org.springframework.format.Printer

Field Summary

Modifier and TypeField and Description
private final Formatter<Number>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public MonetaryAmount
parse(String
the text string
text
,
Locale
the current user locale
locale
)

Implements org.springframework.format.Parser.parse.

Parse a text String to produce a T.

public String
print(MonetaryAmount
the instance to print
object
,
Locale
the current user locale
locale
)

Implements org.springframework.format.Printer.print.

Print the object of type T for display.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

numberFormatterback to summary
private final Formatter<Number> numberFormatter

Constructor Detail

NumberDecoratingFormatterback to summary
public NumberDecoratingFormatter(Formatter<Number> numberFormatter)

Method Detail

parseback to summary
public MonetaryAmount parse(String text, Locale locale) throws ParseException

Implements org.springframework.format.Parser.parse.

Doc from org.springframework.format.Parser.parse.

Parse a text String to produce a T.

Parameters
text:String

the text string

locale:Locale

the current user locale

Returns:MonetaryAmount

an instance of T

Annotations
@Override
Exceptions
ParseException:
when a parse exception occurs in a java.text parsing library
printback to summary
public String print(MonetaryAmount object, Locale locale)

Implements org.springframework.format.Printer.print.

Doc from org.springframework.format.Printer.print.

Print the object of type T for display.

Parameters
object:MonetaryAmount

the instance to print

locale:Locale

the current user locale

Returns:String

the printed text string

Annotations
@Override
org.springframework.format.number.money back to summary

private Class Jsr354NumberFormatAnnotationFormatterFactory.PatternDecoratingFormatter

extends Object
implements Formatter<MonetaryAmount>
Class Inheritance
  • java.lang.Object
  • org.springframework.format.number.money.Jsr354NumberFormatAnnotationFormatterFactory.PatternDecoratingFormatter
All Implemented Interfaces
org.springframework.format.Formatter, org.springframework.format.Parser, org.springframework.format.Printer

Field Summary

Modifier and TypeField and Description
private final String

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private Currency
public MonetaryAmount
parse(String
the text string
text
,
Locale
the current user locale
locale
)

Implements org.springframework.format.Parser.parse.

Parse a text String to produce a T.

public String
print(MonetaryAmount
the instance to print
object
,
Locale
the current user locale
locale
)

Implements org.springframework.format.Printer.print.

Print the object of type T for display.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

patternback to summary
private final String pattern

Constructor Detail

PatternDecoratingFormatterback to summary
public PatternDecoratingFormatter(String pattern)

Method Detail

determineCurrencyback to summary
private Currency determineCurrency(String text, Locale locale)
parseback to summary
public MonetaryAmount parse(String text, Locale locale) throws ParseException

Implements org.springframework.format.Parser.parse.

Doc from org.springframework.format.Parser.parse.

Parse a text String to produce a T.

Parameters
text:String

the text string

locale:Locale

the current user locale

Returns:MonetaryAmount

an instance of T

Annotations
@Override
Exceptions
ParseException:
when a parse exception occurs in a java.text parsing library
printback to summary
public String print(MonetaryAmount object, Locale locale)

Implements org.springframework.format.Printer.print.

Doc from org.springframework.format.Printer.print.

Print the object of type T for display.

Parameters
object:MonetaryAmount

the instance to print

locale:Locale

the current user locale

Returns:String

the printed text string

Annotations
@Override