public abstract class AbstractClient extends Object
Abstract class which specifies how clients should operate.
| Modifier and Type | Field and Description |
|---|---|
protected Locale |
locale |
protected Localization |
localization |
| Modifier | Constructor and Description |
|---|---|
protected |
AbstractClient()
Default constructor.
|
protected |
AbstractClient(Locale locale)
Overloaded constructor.
|
| Modifier and Type | Method and Description |
|---|---|
protected String |
get(String table)
Performs a GET request to the specified table.
|
protected String |
getBaseUrl()
Determines the base URL for the API based on the current
Locale. |
Locale |
getLocale()
Retrieves the
Locale for this client instance. |
List<String> |
getRegions(String table)
Returns the list of the available regions for a given table.
|
String |
getUrl()
Returns the URL endpoint which this client represents.
|
List<String> |
getYears(String table)
Returns the list of the available years for a given table.
|
protected String |
post(String table,
String query)
Performs a POST request to the specified table.
|
void |
setLocale(Locale locale)
Sets the
Locale for this client instance. |
void |
setLocalizationLocale(Locale locale)
Changes the
Locale used for the localization. |
protected Locale locale
protected Localization localization
protected AbstractClient()
Default constructor.
protected AbstractClient(Locale locale)
Overloaded constructor.
locale - the Locale for this clientpublic Locale getLocale()
Retrieves the Locale for this client instance.
Locale for this client instancepublic void setLocale(Locale locale)
Sets the Locale for this client instance. Note that doing this
after a call to setLocalizationLocale(Locale) overwrites the localization
language with the input of this method.
locale - the Locale for this clientpublic void setLocalizationLocale(Locale locale)
Changes the Locale used for the localization. Useful if the client
needs to be in a different language than the error messages.
locale - the Locale for the localizationprotected String getBaseUrl()
Determines the base URL for the API based on the current
Locale.
protected String get(String table)
Performs a GET request to the specified table.
table - the table which will be sent a GET requestprotected String post(String table, String query)
Performs a POST request to the specified table.
table - the table which will be sent a POST requestquery - the query which the API will processpublic List<String> getRegions(String table)
Returns the list of the available regions for a given table.
table - the table to retrieve the regions frompublic List<String> getYears(String table)
Returns the list of the available years for a given table.
table - the table to retrieve the years frompublic String getUrl()
Returns the URL endpoint which this client represents.
Copyright © 2016. All rights reserved.