Top Description Fields Constructors Methods
org.javamoney.moneta.convert.ecb

pack-priv Class ECBRateReadingHandler

extends DefaultHandler
Class Inheritance
Imports
java.math.BigDecimal, java.time.LocalDate, java.util.Map, .Objects, .Optional, java.util.concurrent.ConcurrentHashMap, javax.money.CurrencyUnit, .Monetary, javax.money.convert.ConversionContextBuilder, .ExchangeRate, .ProviderContext, .RateType, org.javamoney.moneta.convert.ExchangeRateBuilder, org.javamoney.moneta.spi.DefaultNumberValue, org.xml.sax.Attributes, .SAXException, org.xml.sax.helpers.DefaultHandler

SAX Event Handler that reads the quotes.

Format:

<gesmes:Envelope xmlns:gesmes="http://www.gesmes.org/xml/2002-08-01" xmlns="http://www.ecb.int/vocabulary/2002-08-01/eurofxref"> <gesmes:subject>Reference rates</gesmes:subject> <gesmes:Sender> <gesmes:name>European Central Bank</gesmes:name> </gesmes:Sender> <Cube> <Cube time="2013-02-21">...</Cube> <Cube time="2013-02-20">...</Cube> <Cube time="2013-02-19"> <Cube currency="USD" rate="1.3349"/> <Cube currency="JPY" rate="124.81"/> <Cube currency="BGN" rate="1.9558"/> <Cube currency="CZK" rate="25.434"/> <Cube currency="DKK" rate="7.4599"/> <Cube currency="GBP" rate="0.8631"/> <Cube currency="HUF" rate="290.79"/> <Cube currency="LTL" rate="3.4528"/> ...
<gesmes:Envelope
xmlns:gesmes="http://www.gesmes.org/xml/2002-08-01"
xmlns="http://www.ecb.int/vocabulary/2002-08-01/eurofxref">
<gesmes:subject>Reference rates</gesmes:subject> <gesmes:Sender>
<gesmes:name>European Central Bank</gesmes:name> </gesmes:Sender> <Cube>
<Cube time="2013-02-21">...</Cube> <Cube time="2013-02-20">...</Cube>
<Cube time="2013-02-19"> <Cube currency="USD" rate="1.3349"/> <Cube
currency="JPY" rate="124.81"/> <Cube currency="BGN" rate="1.9558"/> <Cube
currency="CZK" rate="25.434"/> <Cube currency="DKK" rate="7.4599"/> <Cube
currency="GBP" rate="0.8631"/> <Cube currency="HUF" rate="290.79"/> <Cube
currency="LTL" rate="3.4528"/> ...
Authors
Anatole Tresch, Werner Keil, otaviojava

Field Summary

Modifier and TypeField and Description
private final ProviderContext
private final Map<LocalDate, Map<String, ExchangeRate>>
private LocalDate
localDate

Current timestamp for the given section.

Constructor Summary

AccessConstructor and Description
pack-priv
ECBRateReadingHandler(Map<LocalDate, Map<String, ExchangeRate>>
the rates, not null.
historicRates
,
ProviderContext
the context, not null.
context
)

Creates a new handler.

Method Summary

Modifier and TypeMethod and Description
pack-priv void
addRate(CurrencyUnit
the term (target) currency, mapped from EUR.
term
,
LocalDate localDate, Number
The rate.
rate
)

Method to add a currency exchange rate.

public void
startElement(String uri, String localName, String qName, Attributes attributes)

Overrides org.xml.sax.helpers.DefaultHandler.startElement.

Implements org.xml.sax.ContentHandler.startElement.

Receive notification of the start of an element.

Inherited from org.xml.sax.helpers.DefaultHandler:
charactersendDocumentendElementendPrefixMappingerrorfatalErrorignorableWhitespacenotationDeclprocessingInstructionresolveEntitysetDocumentLocatorskippedEntitystartDocumentstartPrefixMappingunparsedEntityDeclwarning

Field Detail

contextback to summary
private final ProviderContext context
historicRatesback to summary
private final Map<LocalDate, Map<String, ExchangeRate>> historicRates
localDateback to summary
private LocalDate localDate

Current timestamp for the given section.

Constructor Detail

ECBRateReadingHandlerback to summary
pack-priv ECBRateReadingHandler(Map<LocalDate, Map<String, ExchangeRate>> historicRates, ProviderContext context)

Creates a new handler.

Parameters
historicRates:Map<LocalDate, Map<String, ExchangeRate>>

the rates, not null.

context:ProviderContext

the context, not null.

Method Detail

addRateback to summary
pack-priv void addRate(CurrencyUnit term, LocalDate localDate, Number rate)

Method to add a currency exchange rate.

Parameters
term:CurrencyUnit

the term (target) currency, mapped from EUR.

rate:Number

The rate.

startElementback to summary
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException

Overrides org.xml.sax.helpers.DefaultHandler.startElement.

Implements org.xml.sax.ContentHandler.startElement.

Doc from org.xml.sax.helpers.DefaultHandler.startElement.

Receive notification of the start of an element.

By default, do nothing. Application writers may override this method in a subclass to take specific actions at the start of each element (such as allocating a new tree node or writing output to a file).

Annotations
@Override
Exceptions
SAXException:
Any SAX exception, possibly wrapping another exception.