Class WorldBankReader

java.lang.Object
org.episteme.core.io.AbstractResourceReader<Country>
org.episteme.social.politics.loaders.WorldBankReader
All Implemented Interfaces:
ResourceIO<Country>, ResourceReader<Country>

public class WorldBankReader extends AbstractResourceReader<Country>
Reader for World Bank Data.
See Also:
  • Constructor Details

    • WorldBankReader

      public WorldBankReader()
    • WorldBankReader

      public WorldBankReader(HttpClient httpClient)
  • Method Details

    • getInstance

      public static WorldBankReader getInstance()
    • getGlobalGDP

      public double getGlobalGDP()
    • getCategory

      public String getCategory()
      Description copied from interface: ResourceIO
      Returns the category for grouping. MUST be implemented with I18N support.
      Returns:
      the category name
    • getDescription

      public String getDescription()
      Description copied from interface: ResourceIO
      Returns a short description of this resource handler. MUST be implemented with I18N support.
      Returns:
      the description
    • getLongDescription

      public String getLongDescription()
      Description copied from interface: ResourceIO
      Returns a long description of this resource handler. MUST be implemented with I18N support.
      Returns:
      the long description
    • getResourcePath

      public String getResourcePath()
      Description copied from interface: ResourceIO
      Returns the base path where this resource is located.
    • getResourceType

      public Class<Country> getResourceType()
      Description copied from interface: ResourceIO
      Returns the type of resource.
    • getSupportedVersions

      public String[] getSupportedVersions()
      Description copied from interface: ResourceIO
      Returns the supported versions of the format this reader/writer handles.

      Each implementation MUST override this method to declare which versions of the underlying format are supported. The returned array should contain version strings in the format's standard notation (e.g., "3.0", "2.1", "Level 3 Version 2").

      Examples:

      • MathML: {"3.0", "2.0"}
      • SBML: {"Level 3 Version 2", "Level 3 Version 1", "Level 2 Version 5"}
      • PhyloXML: {"1.10", "1.00"}

      Returns:
      array of supported version strings, never null (empty array if version-agnostic)
    • loadFromSource

      protected Country loadFromSource(String id) throws Exception
      Specified by:
      loadFromSource in class AbstractResourceReader<Country>
      Throws:
      Exception
    • loadAllFromSource

      protected List<Country> loadAllFromSource() throws Exception
      Overrides:
      loadAllFromSource in class AbstractResourceReader<Country>
      Throws:
      Exception
    • getMiniCatalog

      protected MiniCatalog<Country> getMiniCatalog()
      Overrides:
      getMiniCatalog in class AbstractResourceReader<Country>
    • fetchIndicatorData

      public CompletableFuture<Map<String,Double>> fetchIndicatorData(String countryCode, String indicator)
      Fetches indicator data for a country from World Bank API. Common indicators: - NY.GDP.MKTP.CD: GDP (current US$) - SP.POP.TOTL: Population, total - SP.DYN.LE00.IN: Life expectancy at birth - EN.ATM.CO2E.PC: CO2 emissions (metric tons per capita)
      Parameters:
      countryCode - ISO 3-letter country code (e.g., "USA", "FRA")
      indicator - World Bank indicator code
      Returns:
      Map of year -> value
    • fetchIndicators

      public Map<String, Map<String,Double>> fetchIndicators(List<String> countryCodes, List<String> indicators)
      Fetches multiple indicators for multiple countries in parallel.
      Parameters:
      countryCodes - List of ISO3 country codes
      indicators - List of World Bank indicator codes (e.g., SP.POP.TOTL)
      Returns:
      Map of Country Code -> (Indicator Code -> Value)
    • clearCache

      public void clearCache()
      Clears the cached regions, forcing a reload on next access.
      Overrides:
      clearCache in class AbstractResourceReader<Country>
    • getName

      public String getName()
      Description copied from interface: ResourceIO
      Returns the display name of this resource handler. MUST be implemented with I18N support.
      Returns:
      the display name