Instances of MoneyFormatter can be created by
MoneyFormatterBuilder.
This class is immutable and thread-safe.
| Modifier and Type | Field and Description |
|---|---|
| private final Locale | locale
The locale to use. |
| private final MultiPrinterParser | printerParser
The printer/parser. |
| private static final long | serialVersionUID
Serialization version. |
| Access | Constructor and Description |
|---|---|
| pack-priv | MoneyFormatter(Locale
the locale to use, not null locale, MoneyPrinter[] the printers, not null printers, MoneyParser[] the parsers, not null parsers)Constructor, creating a new formatter. |
| private | MoneyFormatter(Locale
the locale to use, not null locale, MultiPrinterParser the printer/parser, not null printerParser)Constructor, creating a new formatter. |
| Modifier and Type | Method and Description |
|---|---|
| pack-priv static void | checkNotNull(Object
the object to check, null throws exception object, String the message to use in the exception, not null message)Validates that the object specified is not null |
| public Locale | |
| pack-priv MultiPrinterParser | |
| public boolean | |
| public boolean | |
| public MoneyParseContext | Returns: the parsed monetary value, null only if the parse results in an errorthe text to parse, not null text, int the start index to parse from startIndex)Parses the text extracting monetary information. |
| public BigMoney | Returns: the parsed monetary value, never nullthe text to parse, not null text)Fully parses the text into a |
| public Money | Returns: the parsed monetary value, never nullthe text to parse, not null text)Fully parses the text into a |
| public String | Returns: the string printed using the settings of this formatterthe money to print, not null moneyProvider)Prints a monetary value to a |
| public void | print(Appendable
the appendable to add to, not null appendable, BigMoneyProvider the money to print, not null moneyProvider)Prints a monetary value to an |
| public void | printIO(Appendable
the appendable to add to, not null appendable, BigMoneyProvider the money to print, not null moneyProvider)Prints a monetary value to an |
| public String | Returns: a string summarising the formatter, never nullOverrides java. Gets a string summary of the formatter. |
| public MoneyFormatter | Returns: the new instance, never nullthe locale, not null locale)Returns a copy of this instance with the specified locale. |
| locale | back to summary |
|---|---|
| private final Locale locale The locale to use. | |
| printerParser | back to summary |
|---|---|
| private final MultiPrinterParser printerParser The printer/parser. | |
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID Serialization version. | |
| MoneyFormatter | back to summary |
|---|---|
| pack-priv MoneyFormatter(Locale locale, MoneyPrinter[] printers, MoneyParser[] parsers) Constructor, creating a new formatter.
| |
| MoneyFormatter | back to summary |
|---|---|
| private MoneyFormatter(Locale locale, MultiPrinterParser printerParser) Constructor, creating a new formatter.
| |
| checkNotNull | back to summary |
|---|---|
| pack-priv static void checkNotNull(Object object, String message) Validates that the object specified is not null
| |
| getLocale | back to summary |
|---|---|
| public Locale getLocale() Gets the locale to use.
| |
| getPrinterParser | back to summary |
|---|---|
| pack-priv MultiPrinterParser getPrinterParser() Gets the printer/parser.
| |
| isParser | back to summary |
|---|---|
| public boolean isParser() Checks whether this formatter can parse. If the formatter cannot parse, an UnsupportedOperationException will be thrown from the parse methods.
| |
| isPrinter | back to summary |
|---|---|
| public boolean isPrinter() Checks whether this formatter can print. If the formatter cannot print, an UnsupportedOperationException will be thrown from the print methods.
| |
| parse | back to summary |
|---|---|
| public MoneyParseContext parse(CharSequence text, int startIndex) Parses the text extracting monetary information. This method parses the input providing low-level access to the parsing state. The resulting context contains the parsed text, indicator of error, position following the parse and the parsed currency and amount. Together, these provide enough information for higher level APIs to use.
| |
| parseBigMoney | back to summary |
|---|---|
| public BigMoney parseBigMoney(CharSequence text) Fully parses the text into a The parse must complete normally and parse the entire text (currency and amount). If the parse completes without reading the entire length of the text, an exception is thrown. If any other problem occurs during parsing, an exception is thrown.
| |
| parseMoney | back to summary |
|---|---|
| public Money parseMoney(CharSequence text) Fully parses the text into a The parse must complete normally and parse the entire text (currency and amount). If the parse completes without reading the entire length of the text, an exception is thrown. If any other problem occurs during parsing, an exception is thrown.
| |
| back to summary | |
|---|---|
| public String print(BigMoneyProvider moneyProvider) Prints a monetary value to a
| |
| back to summary | |
|---|---|
| public void print(Appendable appendable, BigMoneyProvider moneyProvider) Prints a monetary value to an
Example implementations of
| |
| printIO | back to summary |
|---|---|
| public void printIO(Appendable appendable, BigMoneyProvider moneyProvider) throws IOException Prints a monetary value to an
Example implementations of
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Gets a string summary of the formatter. | |
| withLocale | back to summary |
|---|---|
| public MoneyFormatter withLocale(Locale locale) Returns a copy of this instance with the specified locale. Changing the locale may change the style of output depending on how the formatter has been configured.
| |