← joda-money / src/main/java/org/joda/money/format/MoneyPrinter.java
| 1 | /* |
| 2 | * Copyright 2009-present, Stephen Colebourne |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | package org.joda.money.format; |
| 17 | |
| 18 | import java.io.IOException; |
| 19 | |
| 20 | import org.joda.money.BigMoney; |
| 21 | |
| 22 | /** |
| 23 | * Prints part of a monetary value to the output appendable. |
| 24 | * <p> |
| 25 | * The printer may print any part, or the whole, of the input {@link BigMoney}. |
| 26 | * Typically, a complete print is constructed from a number of smaller printers |
| 27 | * that have been combined using {@link MoneyFormatterBuilder}. |
| 28 | * <p> |
| 29 | * This interface must be implemented with care to ensure other classes operate correctly. |
| 30 | * All instantiable implementations must be thread-safe, and should generally |
| 31 | * be final and immutable. |
| 32 | */ |
| 33 | public interface MoneyPrinter { |
| 34 | |
| 35 | /** |
| 36 | * Prints part of a monetary value to the output appendable. |
| 37 | * <p> |
| 38 | * The implementation determines what to append, which may be some or all |
| 39 | * of the data held in the {@code BigMoney}. |
| 40 | * <p> |
| 41 | * The context is not a thread-safe object and a new instance will be created |
| 42 | * for each print. The context must not be stored in an instance variable |
| 43 | * or shared with any other threads. |
| 44 | * |
| 45 | * @param context the context being used, not null |
| 46 | * @param appendable the appendable to add to, not null |
| 47 | * @param money the money to print, not null |
| 48 | * @throws MoneyFormatException if there is a problem while printing |
| 49 | * @throws IOException if an IO exception occurs |
| 50 | */ |
| 51 | public abstract void print(MoneyPrintContext context, Appendable appendable, BigMoney money) throws IOException; |
| 52 | |
| 53 | } |
| 54 |