1 /*
2 * Copyright 2009-2013 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;
17
18 import java.util.List;
19
20 /**
21 * Provider for available currencies.
22 */
23 public abstract class CurrencyUnitDataProvider {
24
25 /**
26 * Registers all the currencies known by this provider.
27 *
28 * @throws Exception if an error occurs
29 */
30 protected abstract void registerCurrencies() throws Exception;
31
32 /**
33 * Registers a currency allowing it to be used.
34 * <p>
35 * This method is called by {@link #registerCurrencies()} to perform the
36 * actual creation of a currency.
37 *
38 * @param currencyCode the currency code, not null
39 * @param numericCurrencyCode the numeric currency code, -1 if none
40 * @param decimalPlaces the number of decimal places that the currency
41 * normally has, from 0 to 3, or -1 for a pseudo-currency
42 * @param countryCodes the country codes to register the currency under, not null
43 */
44 protected final void registerCurrency(String currencyCode, int numericCurrencyCode, int decimalPlaces, List<String> countryCodes) {
45 CurrencyUnit.registerCurrency(currencyCode, numericCurrencyCode, decimalPlaces, countryCodes, true);
46 }
47
48 }