Class MultiPrinterParser
- All Implemented Interfaces:
Serializable
,MoneyParser
,MoneyPrinter
This class is immutable and thread-safe.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final MoneyParser[]
The parsers.private final MoneyPrinter[]
The printers.private static final long
Serialization version. -
Constructor Summary
ConstructorsConstructorDescriptionMultiPrinterParser
(MoneyPrinter[] printers, MoneyParser[] parsers) Constructor. -
Method Summary
Modifier and TypeMethodDescription(package private) void
appendTo
(MoneyFormatterBuilder builder) (package private) boolean
isParser()
(package private) boolean
void
parse
(MoneyParseContext context) Parses monetary information using a textual representation.void
print
(MoneyPrintContext context, Appendable appendable, BigMoney money) Prints part of a monetary value to the output appendable.toString()
-
Field Details
-
serialVersionUID
private static final long serialVersionUIDSerialization version.- See Also:
-
printers
The printers. -
parsers
The parsers.
-
-
Constructor Details
-
MultiPrinterParser
MultiPrinterParser(MoneyPrinter[] printers, MoneyParser[] parsers) Constructor.- Parameters:
printers
- the printers, not null
-
-
Method Details
-
isPrinter
boolean isPrinter() -
isParser
boolean isParser() -
appendTo
-
print
public void print(MoneyPrintContext context, Appendable appendable, BigMoney money) throws IOException Description copied from interface:MoneyPrinter
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
BigMoney
.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.
- Specified by:
print
in interfaceMoneyPrinter
- Parameters:
context
- the context being used, not nullappendable
- the appendable to add to, not nullmoney
- the money to print, not null- Throws:
IOException
- if an IO exception occurs
-
parse
Description copied from interface:MoneyParser
Parses monetary information using a textual representation.The text and parse index are stored in the context. The parsed data and updated index is also stored in the context.
Implementations should avoid throwing exceptions and use the error index in the context instead to record the problem. The context can be assumed to not be in error on entry to this method.
The context is not a thread-safe object and a new instance will be created for each parse. The context must not be stored in an instance variable or shared with any other threads.
- Specified by:
parse
in interfaceMoneyParser
- Parameters:
context
- the context to use and parse into, not null
-
toString
-