public abstract class AbstractClient extends Object
Abstract class which specifies how clients should operate.
| Modifier | Constructor and Description |
|---|---|
protected |
AbstractClient()
Default constructor.
|
protected |
AbstractClient(Locale locale)
Overloaded constructor.
|
| Modifier and Type | Method and 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 the
Locale for this client instance. |
Locale |
getLocalizationLocale()
Returns the
Locale 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 current
Locale 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 the
Locale for this client instance. |
void |
setLocalizationLocale(Locale loc)
Changes the
Locale used for the localization. |
protected AbstractClient()
Default constructor.
protected AbstractClient(Locale locale)
Overloaded constructor.
locale - the Locale for this clientpublic CommunicationProtocol getCommunicationProtocol()
Returns the communication protocol for this client instance.
CommunicationProtocol for this client instancepublic void setCommunicationProtocol(CommunicationProtocol communicationProtocol)
Sets the communication protocol for this client instance.
communicationProtocol - the
CommunicationProtocol for this client instancepublic 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 Locale getLocalizationLocale()
Returns the Locale used for the localization.
Locale for the localizationpublic 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.
loc - the Locale for the localizationprotected URLEndpoint getRootUrl()
Determines the URL for the API based on the current Locale and
communication protocol.
protected String doGetRequest(String url)
Performs a GET request to the specified URL.
url - the URL which will be sent a GET requestprotected String doPostRequest(String url, String query)
Performs a POST request to the specified URL.
url - the URL which will be sent a POST requestquery - the query which the API will processprotected List<ResponseModel> getResponseModels(String table)
Retrieves the response models for a given table.
table - the tableResponseModelprotected List<ResponseModel> getResponseModels(String table, Map<String,Collection<?>> mappings)
Retrieves the response models for a given table which match the input constraints.
table - the tablemappings - the mappingsResponseModelpublic abstract URLEndpoint getUrl()
Returns the URL endpoint which this client represents.
Copyright © 2019. All rights reserved.