T
- the target type.public static final class MonetaryAmountFormat.Builder extends Object
MonetaryFormat
instances programmatically using a fluent API. The
formatting hereby is modeled by a concatenation of FormatToken
instances. The same FormatToken
instances also are responsible
for implementing the opposite, parsing, of an item from an input
character sequence. Each FormatToken
gets access to the current
parsing location, and the original and current character input sequence,
modeled by the ParseContext
. Finall if parsing of a part failed,
a FormatToken
throws an ItemParseException
describing the
problem.
This class is not thread-safe and therefore should not be shared among different threads.
Constructor and Description |
---|
MonetaryAmountFormat.Builder(Locale locale)
Creates a new Builder.
|
Modifier and Type | Method and Description |
---|---|
MonetaryAmountFormat.Builder |
appendAmount()
Add the amount to the given format.
|
MonetaryAmountFormat.Builder |
appendAmount(AmountStyle style)
Add a
FormatToken to the token list. |
MonetaryAmountFormat.Builder |
appendCurrency()
Adds a currency to the format printing using the currency code.
|
MonetaryAmountFormat.Builder |
appendCurrency(MonetaryAmountFormat.CurrencyStyle style)
Adds a currency unit to the format using the given
MonetaryAmountFormat.CurrencyStyle . |
MonetaryAmountFormat.Builder |
appendLiteral(String literal)
Add a
FormatToken to the token list. |
MonetaryAmountFormat |
build()
This method creates an
MonetaryFormat based on this instance,
hereby using the given a ItemFactory to extract the item to
be returned from the ParseContext 's results. |
String |
toString() |
MonetaryAmountFormat.Builder |
withDefaultCurrency(javax.money.CurrencyUnit currency) |
MonetaryAmountFormat.Builder |
withNumberGroupChars(char... groupChars) |
MonetaryAmountFormat.Builder |
withNumberGroupSizes(int... groupSizes) |
public MonetaryAmountFormat.Builder(Locale locale)
targetType
- the target class.public MonetaryAmountFormat.Builder withDefaultCurrency(javax.money.CurrencyUnit currency)
public MonetaryAmountFormat.Builder appendAmount(AmountStyle style)
FormatToken
to the token list.token
- the token to add.public MonetaryAmountFormat.Builder appendAmount()
locale
is used, and the number is rounded with the
currencies, default rounding as returned by
MonetaryRoundings.getRounding()
.token
- the token to add.public MonetaryAmountFormat.Builder appendCurrency(MonetaryAmountFormat.CurrencyStyle style)
MonetaryAmountFormat.CurrencyStyle
.style
- the style to be used, not null
.public MonetaryAmountFormat.Builder appendCurrency()
public MonetaryAmountFormat.Builder appendLiteral(String literal)
FormatToken
to the token list.literal
- the literal to add, not null
.public MonetaryAmountFormat build()
MonetaryFormat
based on this instance,
hereby using the given a ItemFactory
to extract the item to
be returned from the ParseContext
's results.MonetaryFormat
instance, never null.public MonetaryAmountFormat.Builder withNumberGroupSizes(int... groupSizes)
public MonetaryAmountFormat.Builder withNumberGroupChars(char... groupChars)
Copyright © 2012–2013 JSR 354 - Expert Group. All rights reserved.