This class is mutable and intended for use by a single thread. A new instance should be created for each use. The formatters produced by the builder are immutable and thread-safe.
| Modifier and Type | Class and Description |
|---|---|
| private static enum | MoneyFormatterBuilder.
Handles the singleton outputs. |
| private static enum | MoneyFormatterBuilder.
Handles the singleton outputs. |
| Modifier and Type | Field and Description |
|---|---|
| private final List | parsers
The parsers. |
| private final List | printers
The printers. |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public MoneyFormatterBuilder | Returns: this for chaining, never nullthe formatter to append, not null formatter)Appends the printers and parsers from the specified formatter to this builder. |
| public MoneyFormatterBuilder | Returns: this for chaining, never nullthe printer to append, null makes the formatter unable to print printer, MoneyParser the parser to append, null makes the formatter unable to parse parser)Appends the specified printer and parser to this builder. |
| public MoneyFormatterBuilder | Returns: this, for chaining, never nullAppends the amount to the builder using a standard format. |
| public MoneyFormatterBuilder | Returns: this, for chaining, never nullthe style to use, not null style)Appends the amount to the builder using the specified amount style. |
| public MoneyFormatterBuilder | Returns: this, for chaining, never nullAppends the amount to the builder using a grouped localized format. |
| public MoneyFormatterBuilder | Returns: this, for chaining, never nullAppends the currency code to the builder. |
| public MoneyFormatterBuilder | Returns: this, for chaining, never nullAppends the currency code to the builder. |
| public MoneyFormatterBuilder | Returns: this, for chaining, never nullAppends the currency code to the builder. |
| public MoneyFormatterBuilder | Returns: this, for chaining, never nullAppends the localized currency symbol to the builder. |
| private MoneyFormatterBuilder | Returns: this for chaining, never nullthe printer to append, null makes the formatter unable to print printer, MoneyParser the parser to append, null makes the formatter unable to parse parser)Appends the specified printer and parser to this builder. |
| public MoneyFormatterBuilder | Returns: this, for chaining, never nullthe literal to append, null or empty ignored literal)Appends a literal to the builder. |
| public MoneyFormatterBuilder | Returns: this for chaining, never nullthe formatter to use when the amount is positive or zero whenPositiveOrZero, MoneyFormatter the formatter to use when the amount is negative whenNegative)Appends the specified formatters, one used when the amount is positive, and one when the amount is negative. |
| public MoneyFormatterBuilder | Returns: this for chaining, never nullthe formatter to use when the amount is positive whenPositive, MoneyFormatter the formatter to use when the amount is zero whenZero, MoneyFormatter the formatter to use when the amount is negative whenNegative)Appends the specified formatters, one used when the amount is positive, one when the amount is zero and one when the amount is negative. |
| public MoneyFormatter | Returns: the formatter built from this builder, never nullBuilds the formatter from the builder using the default locale. |
| public MoneyFormatter | Returns: the formatter built from this builder, never nullthe initial locale for the formatter, not null locale)Builds the formatter from the builder setting the locale. |
| parsers | back to summary |
|---|---|
| private final List<MoneyParser> parsers The parsers. | |
| printers | back to summary |
|---|---|
| private final List<MoneyPrinter> printers The printers. | |
| MoneyFormatterBuilder | back to summary |
|---|---|
| public MoneyFormatterBuilder() Constructor, creating a new empty builder. | |
| append | back to summary |
|---|---|
| public MoneyFormatterBuilder append(MoneyFormatter formatter) Appends the printers and parsers from the specified formatter to this builder. If the specified formatter cannot print, then the the output of this builder will be unable to print. If the specified formatter cannot parse, then the output of this builder will be unable to parse.
| |
| append | back to summary |
|---|---|
| public MoneyFormatterBuilder append(MoneyPrinter printer, MoneyParser parser) Appends the specified printer and parser to this builder. If null is specified then the formatter will be unable to print/parse.
| |
| appendAmount | back to summary |
|---|---|
| public MoneyFormatterBuilder appendAmount() Appends the amount to the builder using a standard format.
The format used is
| |
| appendAmount | back to summary |
|---|---|
| public MoneyFormatterBuilder appendAmount(MoneyAmountStyle style) Appends the amount to the builder using the specified amount style. The amount is the value itself, such as '12.34'.
The amount style allows the formatting of the number to be controlled in detail.
This includes the characters for positive, negative, decimal, grouping and whether
to output the absolute or signed amount.
See
| |
| appendAmountLocalized | back to summary |
|---|---|
| public MoneyFormatterBuilder appendAmountLocalized() Appends the amount to the builder using a grouped localized format.
The format used is
| |
| appendCurrencyCode | back to summary |
|---|---|
| public MoneyFormatterBuilder appendCurrencyCode() Appends the currency code to the builder. The currency code is the three letter ISO code, such as 'GBP'.
| |
| appendCurrencyNumeric3Code | back to summary |
|---|---|
| public MoneyFormatterBuilder appendCurrencyNumeric3Code() Appends the currency code to the builder. The numeric code is the ISO numeric code, such as '826' and is zero padded to three digits.
| |
| appendCurrencyNumericCode | back to summary |
|---|---|
| public MoneyFormatterBuilder appendCurrencyNumericCode() Appends the currency code to the builder. The numeric code is the ISO numeric code, such as '826'.
| |
| appendCurrencySymbolLocalized | back to summary |
|---|---|
| public MoneyFormatterBuilder appendCurrencySymbolLocalized() Appends the localized currency symbol to the builder. The localized currency symbol is the symbol as chosen by the locale of the formatter. Symbols cannot be parsed.
| |
| appendInternal | back to summary |
|---|---|
| private MoneyFormatterBuilder appendInternal(MoneyPrinter printer, MoneyParser parser) Appends the specified printer and parser to this builder. Either the printer or parser must be non-null.
| |
| appendLiteral | back to summary |
|---|---|
| public MoneyFormatterBuilder appendLiteral(CharSequence literal) Appends a literal to the builder. The localized currency symbol is the symbol as chosen by the locale of the formatter.
| |
| appendSigned | back to summary |
|---|---|
| public MoneyFormatterBuilder appendSigned(MoneyFormatter whenPositiveOrZero, MoneyFormatter whenNegative) Appends the specified formatters, one used when the amount is positive, and one when the amount is negative. When printing, the amount is queried and the appropriate formatter is used. When parsing, each formatter is tried, with the longest successful match, or the first match if multiple are successful. If the negative parser is matched, the amount returned will be negative no matter what amount is parsed.
A typical use case for this would be to produce a format like
'
In order to use this method, it may be necessary to output an unsigned amount.
This can be achieved using
| |
| appendSigned | back to summary |
|---|---|
| public MoneyFormatterBuilder appendSigned(MoneyFormatter whenPositive, MoneyFormatter whenZero, MoneyFormatter whenNegative) Appends the specified formatters, one used when the amount is positive, one when the amount is zero and one when the amount is negative. When printing, the amount is queried and the appropriate formatter is used. When parsing, each formatter is tried, with the longest successful match, or the first match if multiple are successful. If the zero parser is matched, the amount returned will be zero no matter what amount is parsed. If the negative parser is matched, the amount returned will be negative no matter what amount is parsed.
A typical use case for this would be to produce a format like
'
In order to use this method, it may be necessary to output an unsigned amount.
This can be achieved using
| |
| toFormatter | back to summary |
|---|---|
| public MoneyFormatter toFormatter() Builds the formatter from the builder using the default locale.
Once the builder is in the correct state it must be converted to a
This method uses the default locale within the returned formatter.
It can be changed by calling
| |
| toFormatter | back to summary |
|---|---|
| public MoneyFormatter toFormatter(Locale locale) Builds the formatter from the builder setting the locale.
Once the builder is in the correct state it must be converted to a
This method uses the specified locale within the returned formatter.
It can be changed by calling
| |
| Modifier and Type | Field and Description |
|---|---|
| public static final MoneyFormatterBuilder. |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public void | print(MoneyPrintContext
the context being used, not null context, Appendable the appendable to add to, not null appendable, BigMoney the money to print, not null money)Implements org. Prints part of a monetary value to the output appendable. |
| public String | toString()
Overrides java. Returns the name of this enum constant, as contained in the declaration. |
| public static MoneyFormatterBuilder. | |
| public static MoneyFormatterBuilder. |
| LOCALIZED_SYMBOL | back to summary |
|---|---|
| public static final MoneyFormatterBuilder. | |
| SingletonPrinters | back to summary |
|---|---|
| private SingletonPrinters() | |
| back to summary | |
|---|---|
| public void print(MoneyPrintContext context, Appendable appendable, BigMoney money) throws IOException Implements org. Doc from org. Prints part of a monetary value to the output appendable.
The implementation determines what to append, which may be some or all
of the data held in the The context is not a thread-safe object and a new instance will be created for each print. The context must not be stored in an instance variable or shared with any other threads.
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Returns the name of this enum constant, as contained in the declaration. This method may be overridden, though it typically isn't necessary or desirable. An enum class should override this method when a more "programmer-friendly" string form exists. | |
| valueOf | back to summary |
|---|---|
| public static MoneyFormatterBuilder. | |
| values | back to summary |
|---|---|
| public static MoneyFormatterBuilder. | |
| Modifier and Type | Field and Description |
|---|---|
| public static final MoneyFormatterBuilder. | |
| public static final MoneyFormatterBuilder. | |
| public static final MoneyFormatterBuilder. | |
| private final String |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public String | toString()
Overrides java. Returns the name of this enum constant, as contained in the declaration. |
| public static MoneyFormatterBuilder. | |
| public static MoneyFormatterBuilder. |
| CODE | back to summary |
|---|---|
| public static final MoneyFormatterBuilder. | |
| NUMERIC_3_CODE | back to summary |
|---|---|
| public static final MoneyFormatterBuilder. | |
| NUMERIC_CODE | back to summary |
|---|---|
| public static final MoneyFormatterBuilder. | |
| toString | back to summary |
|---|---|
| private final String toString | |
| Singletons | back to summary |
|---|---|
| private Singletons(String toString) | |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Returns the name of this enum constant, as contained in the declaration. This method may be overridden, though it typically isn't necessary or desirable. An enum class should override this method when a more "programmer-friendly" string form exists. | |
| valueOf | back to summary |
|---|---|
| public static MoneyFormatterBuilder. | |
| values | back to summary |
|---|---|
| public static MoneyFormatterBuilder. | |