Class AbstractClient
- java.lang.Object
-
- com.github.dannil.scbjavaclient.client.AbstractClient
-
- Direct Known Subclasses:
AbstractContainerClient,AgricultureCerealCropsClient,AgricultureHoldingsClient,AgricultureLandUseClient,AgricultureLivestockClient,BusinessActivitiesAccomodationStatisticsMonthClient,BusinessActivitiesAccomodationStatisticsYearClient,BusinessActivitiesBalanceStatisticsClient,BusinessActivitiesDatabaseClient,BusinessActivitiesIndustrialCapacityUtilizationEconomicIndicatorsClient,BusinessActivitiesIndustrialCapacityUtilizationIndustrialCapacityUtilizationClient,BusinessActivitiesIndustrialInventoriesEconomicIndicatorsClient,BusinessActivitiesIndustrialInventoriesInventoriesClient,BusinessActivitiesInvestmentSurveyEconomicIndicatorsClient,BusinessActivitiesNonFinancialCorporationsClient,BusinessActivitiesNonProfitOrganizationsPrimaryStatisticsClient,BusinessActivitiesNonProfitOrganizationsSatelliteAccountsClient,BusinessActivitiesOrdersAndTurnoverOldTablesSNI2002Client,BusinessActivitiesOrdersAndTurnoverOldTablesSNI2007Client,BusinessActivitiesOrdersAndTurnoverOrdersAndTurnoverClient,BusinessActivitiesProductionIndexClient,BusinessActivitiesProductionValueIndexProductionValueIndexClient,EducationAndResearchActivityAfterTrainingClient,EducationAndResearchCommunityInnovationSurveyActivityClient,EducationAndResearchCommunityInnovationSurveyCooperationClient,EducationAndResearchFolkHighSchoolStatisticsClient,EnergyAnnualStatisticsClient,EnergyMonthlyStatisticsClient,EnvironmentAirPollutantsClient,EnvironmentGreenhouseGasClient,EnvironmentLandAndWaterAreaClient,EnvironmentLandUseBuildingsClient,EnvironmentLandUseInfrastructureForTransportClient,EnvironmentLandUsePlanningClient,EnvironmentLandUseUsageClient,EnvironmentLocalitiesAreasAndPopulationPopulationClient,EnvironmentPackagingAndPackagingWasteClient,EnvironmentProtectedNatureNatureTypesClient,EnvironmentProtectedNatureNumberAndAreaClient,EnvironmentProtectedNaturePopulationAndAccessibilityClient,EnvironmentSEEAAirEmissionsAccountsClient,EnvironmentSEEAEnergyAccountsClient,EnvironmentSEEAGoodsAndServicesSectorClient,EnvironmentSEEAMaterialFlowAccountsClient,EnvironmentSEEATaxesClient,EnvironmentShorelineLandUseLandUseClient,EnvironmentShorelineLandUseOldTablesClient,EnvironmentSmallerLocalitiesClient,EnvironmentWasteClient,FinancialMarketsBalanceOfPaymentsDirectInvestmentsClient,FinancialMarketsBalanceOfPaymentsEconomicIndicatorsClient,FinancialMarketsBalanceOfPaymentsInternationalInvestmentPositionClient,FinancialMarketsBalanceOfPaymentsPaymentsClient,FinancialMarketsBalanceOfPaymentsPortfolioInvestmentClient,FinancialMarketsEnterprisesClient,FinancialMarketsInstitutionsClient,FinancialMarketsInvestmentFundsClient,FinancialMarketsSecuritiesClient,FinancialMarketsShareholdersRestOfTheWorldClient,FinancialMarketsShareholdersSwedishMarketplaceClient,FinancialMarketsStatisticsClaimsAndLiabilitiesClient,FinancialMarketsStatisticsDepositAndLendingClient,FinancialMarketsStatisticsEconomicIndicatorsClient,FinancialMarketsStatisticsKeyFiguresClient,FinancialMarketsStatisticsStatisticsClient,GoodsAndServicesFoodSalesClient,GoodsAndServicesForeignTradeGoodsCNClient,GoodsAndServicesForeignTradeGoodsEconomicIndicatorsClient,GoodsAndServicesForeignTradeGoodsSITCClient,GoodsAndServicesForeignTradeGoodsSPINClient,GoodsAndServicesForeignTradeGoodsTotalClient,GoodsAndServicesTurnoverServiceSectorOldTablesSNI2002Client,GoodsAndServicesTurnoverServiceSectorOldTablesSNI2007Client,GoodsAndServicesTurnoverServiceSectorTurnoverClient,LabourMarketCostIndexClient,LabourMarketGrossPayAggregateWagesClient,LabourMarketShortTermEmploymentPopulationClient,LabourMarketShortTermEmploymentSickLeaveClient,LivingConditionsFamiliesAdoptionsClient,LivingConditionsFamiliesHousingClient,LivingConditionsFamiliesLegalGuardiansClient,LivingConditionsFamiliesSiblingsClient,LivingConditionsSurveysEmploymentClient,LivingConditionsSurveysHealthClient,PopulationNameNewbornClient,PopulationNameRegisteredPersonsClient,PopulationProjectionsLatestAssumptionsClient,PopulationProjectionsLatestProjectionsClient,PopulationStatisticsAdopteesClient,PopulationStatisticsAmountClient,PopulationStatisticsAsylumSeekersClient,PopulationStatisticsAverageAgeClient,PopulationStatisticsBackgroundClient,PopulationStatisticsCitizenshipClient,PopulationStatisticsDeathsClient,PopulationStatisticsDensityClient,PopulationStatisticsForeignBornPersonsClient,PopulationStatisticsForeignCitizensClient,PopulationStatisticsHouseholdClient,PopulationStatisticsLiveBirthsClient,PopulationStatisticsMeanPopulationClient,PopulationStatisticsMigrationClient,PopulationStatisticsPartnershipClient,PopulationStatisticsVitalEventsClient,PricesAndConsumptionBPIClient,PricesAndConsumptionCCIFPIExcludingWageClient,PricesAndConsumptionCCIFPIIncludingWageClient,PricesAndConsumptionCPICPIFCTClient,PricesAndConsumptionCPIEconomicIndicatorsClient,PricesAndConsumptionCPIHICPClient,PricesAndConsumptionCPIKPIFClient,PricesAndConsumptionCPIPriceBasicAmountClient,PricesAndConsumptionPPIEconomicIndicatorsClient,PricesAndConsumptionPPISPIN2002MonthClient,PricesAndConsumptionPPISPIN2002YearClient,PricesAndConsumptionPPISPIN2007MonthlyAndQuarterlyClient,PricesAndConsumptionPPISPIN2007YearClient,PricesAndConsumptionPPISPIN2015MonthlyAndQuarterlyClient,PricesAndConsumptionPurchasingPowerParitiesClient,PublicFinancesAnnualAccountsBalanceSheetCountyClient,PublicFinancesAnnualAccountsBalanceSheetMunicipalityClient,PublicFinancesAnnualAccountsStatementAccountsCountyClient,PublicFinancesAnnualAccountsStatementAccountsMunicipalityClient,PublicFinancesAssetsAndLiabilitiesClient,PublicFinancesGovernmentDebtClient,PublicFinancesLocalTaxesClient,PublicFinancesPubliclyOwnedEnterprisesClient,PublicFinancesTaxAssessmentClient,TransportRegisteredVehiclesEconomicIndicatorsClient,TransportRegisteredVehiclesVehiclesClient
public abstract class AbstractClient extends Object
Abstract class which specifies how clients should operate.
- Since:
- 0.0.2
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractClient()Default constructor.protectedAbstractClient(Locale locale)Overloaded constructor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected StringdoGetRequest(String url)Performs a GET request to the specified URL.protected StringdoPostRequest(String url, String query)Performs a POST request to the specified URL.CommunicationProtocolgetCommunicationProtocol()Returns the communication protocol for this client instance.LocalegetLocale()Retrieves theLocalefor this client instance.LocalegetLocalizationLocale()Returns theLocaleused for the localization.protected List<ResponseModel>getResponseModels(String table)Retrieves the response models for a given table.protected List<ResponseModel>getResponseModels(String table, Map<String,Collection<?>> mappings)Retrieves the response models for a given table which match the input constraints.protected URLEndpointgetRootUrl()Determines the URL for the API based on the currentLocaleand communication protocol.abstract URLEndpointgetUrl()Returns the URL endpoint which this client represents.voidsetCommunicationProtocol(CommunicationProtocol communicationProtocol)Sets the communication protocol for this client instance.voidsetLocale(Locale locale)Sets theLocalefor this client instance.voidsetLocalizationLocale(Locale loc)Changes theLocaleused for the localization.
-
-
-
Constructor Detail
-
AbstractClient
protected AbstractClient()
Default constructor.
-
AbstractClient
protected AbstractClient(Locale locale)
Overloaded constructor.
- Parameters:
locale- theLocalefor this client
-
-
Method Detail
-
getCommunicationProtocol
public CommunicationProtocol getCommunicationProtocol()
Returns the communication protocol for this client instance.
- Returns:
- the
CommunicationProtocolfor this client instance
-
setCommunicationProtocol
public void setCommunicationProtocol(CommunicationProtocol communicationProtocol)
Sets the communication protocol for this client instance.
- Parameters:
communicationProtocol- theCommunicationProtocolfor this client instance
-
getLocale
public Locale getLocale()
Retrieves the
Localefor this client instance.- Returns:
- the
Localefor this client instance
-
setLocale
public void setLocale(Locale locale)
Sets the
Localefor this client instance. Note that doing this after a call tosetLocalizationLocale(Locale)overwrites the localization language with the input of this method.- Parameters:
locale- theLocalefor this client
-
getLocalizationLocale
public Locale getLocalizationLocale()
Returns the
Localeused for the localization.- Returns:
- locale the
Localefor the localization
-
setLocalizationLocale
public void setLocalizationLocale(Locale loc)
Changes the
Localeused for the localization. Useful if the client needs to be in a different language than the error messages.- Parameters:
loc- theLocalefor the localization
-
getRootUrl
protected URLEndpoint getRootUrl()
Determines the URL for the API based on the current
Localeand communication protocol.- Returns:
- the URL representing the entry point for the API
-
doGetRequest
protected String doGetRequest(String url)
Performs a GET request to the specified URL.
- Parameters:
url- the URL which will be sent a GET request- Returns:
- a string representation of the API's response
-
doPostRequest
protected String doPostRequest(String url, String query)
Performs a POST request to the specified URL.
- Parameters:
url- the URL which will be sent a POST requestquery- the query which the API will process- Returns:
- a string representation of the API's response
-
getResponseModels
protected List<ResponseModel> getResponseModels(String table)
Retrieves the response models for a given table.
- Parameters:
table- the table- Returns:
- a list of
ResponseModel
-
getResponseModels
protected List<ResponseModel> getResponseModels(String table, Map<String,Collection<?>> mappings)
Retrieves the response models for a given table which match the input constraints.
- Parameters:
table- the tablemappings- the mappings- Returns:
- a list of
ResponseModel
-
getUrl
public abstract URLEndpoint getUrl()
Returns the URL endpoint which this client represents.
- Returns:
- the URL endpoint for this client
-
-