001 /*
002 * Copyright 2009-2013 Stephen Colebourne
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016 package org.joda.money;
017
018 import java.util.List;
019
020 /**
021 * Provider for available currencies.
022 */
023 public abstract class CurrencyUnitDataProvider {
024
025 /**
026 * Registers all the currencies known by this provider.
027 *
028 * @throws Exception if an error occurs
029 */
030 protected abstract void registerCurrencies() throws Exception;
031
032 /**
033 * Registers a currency allowing it to be used.
034 * <p>
035 * This method is called by {@link #registerCurrencies()} to perform the
036 * actual creation of a currency.
037 *
038 * @param currencyCode the currency code, not null
039 * @param numericCurrencyCode the numeric currency code, -1 if none
040 * @param decimalPlaces the number of decimal places that the currency
041 * normally has, from 0 to 3, or -1 for a pseudo-currency
042 * @param countryCodes the country codes to register the currency under, not null
043 */
044 protected final void registerCurrency(String currencyCode, int numericCurrencyCode, int decimalPlaces, List<String> countryCodes) {
045 CurrencyUnit.registerCurrency(currencyCode, numericCurrencyCode, decimalPlaces, countryCodes, true);
046 }
047
048 }