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 protected
AbstractClient()
Default constructor.protected
AbstractClient(Locale locale)
Overloaded constructor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected String
doGetRequest(String url)
Performs a GET request to the specified URL.protected String
doPostRequest(String url, String query)
Performs a POST request to the specified URL.CommunicationProtocol
getCommunicationProtocol()
Returns the communication protocol for this client instance.Locale
getLocale()
Retrieves theLocale
for this client instance.Locale
getLocalizationLocale()
Returns theLocale
used 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 URLEndpoint
getRootUrl()
Determines the URL for the API based on the currentLocale
and communication protocol.abstract URLEndpoint
getUrl()
Returns the URL endpoint which this client represents.void
setCommunicationProtocol(CommunicationProtocol communicationProtocol)
Sets the communication protocol for this client instance.void
setLocale(Locale locale)
Sets theLocale
for this client instance.void
setLocalizationLocale(Locale loc)
Changes theLocale
used for the localization.
-
-
-
Constructor Detail
-
AbstractClient
protected AbstractClient()
Default constructor.
-
AbstractClient
protected AbstractClient(Locale locale)
Overloaded constructor.
- Parameters:
locale
- theLocale
for this client
-
-
Method Detail
-
getCommunicationProtocol
public CommunicationProtocol getCommunicationProtocol()
Returns the communication protocol for this client instance.
- Returns:
- the
CommunicationProtocol
for this client instance
-
setCommunicationProtocol
public void setCommunicationProtocol(CommunicationProtocol communicationProtocol)
Sets the communication protocol for this client instance.
- Parameters:
communicationProtocol
- theCommunicationProtocol
for this client instance
-
getLocale
public Locale getLocale()
Retrieves the
Locale
for this client instance.- Returns:
- the
Locale
for this client instance
-
setLocale
public void setLocale(Locale locale)
Sets the
Locale
for this client instance. Note that doing this after a call tosetLocalizationLocale(Locale)
overwrites the localization language with the input of this method.- Parameters:
locale
- theLocale
for this client
-
getLocalizationLocale
public Locale getLocalizationLocale()
Returns the
Locale
used for the localization.- Returns:
- locale the
Locale
for the localization
-
setLocalizationLocale
public void setLocalizationLocale(Locale loc)
Changes the
Locale
used for the localization. Useful if the client needs to be in a different language than the error messages.- Parameters:
loc
- theLocale
for the localization
-
getRootUrl
protected URLEndpoint getRootUrl()
Determines the URL for the API based on the current
Locale
and 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
-
-