Search in sources :

Example 1 with RateIMFResult

use of org.javamoney.moneta.convert.internal.imf.IMFRateReadingHandler.RateIMFResult in project jsr354-ri by JavaMoney.

the class IMFHistoricRateProvider method loadFromRemote.

private void loadFromRemote(Map<IMFHistoricalType, InputStream> resources) {
    try {
        for (IMFHistoricalType type : resources.keySet()) {
            RateIMFResult result = handler.read(resources.get(type));
            combine(result.getSdrToCurrency(), this.sdrToCurrency);
            combine(result.getCurrencyToSdr(), this.currencyToSdr);
        }
    } catch (Exception e) {
        LOG.log(Level.SEVERE, "Error", e);
    }
}
Also used : RateIMFResult(org.javamoney.moneta.convert.internal.imf.IMFRateReadingHandler.RateIMFResult) IOException(java.io.IOException)

Example 2 with RateIMFResult

use of org.javamoney.moneta.convert.internal.imf.IMFRateReadingHandler.RateIMFResult in project jsr354-ri by JavaMoney.

the class IMFAbstractRateProvider method newDataLoaded.

@Override
public void newDataLoaded(String resourceId, InputStream is) {
    try {
        int oldSize = this.sdrToCurrency.size();
        RateIMFResult result = handler.read(is);
        this.sdrToCurrency = result.getSdrToCurrency();
        this.currencyToSdr = result.getCurrencyToSdr();
        int newSize = this.sdrToCurrency.size();
        loadState = "Loaded " + resourceId + " exchange rates for days:" + (newSize - oldSize);
        LOG.info(loadState);
        loadLock.countDown();
    } catch (Exception e) {
        loadState = "Last Error during data load: " + e.getMessage();
        throw new IllegalArgumentException("Failed to load IMF data provided.", e);
    }
}
Also used : RateIMFResult(org.javamoney.moneta.convert.internal.imf.IMFRateReadingHandler.RateIMFResult) MonetaryException(javax.money.MonetaryException)

Aggregations

RateIMFResult (org.javamoney.moneta.convert.internal.imf.IMFRateReadingHandler.RateIMFResult)2 IOException (java.io.IOException)1 MonetaryException (javax.money.MonetaryException)1