public abstract class AbstractClient
extends Object
An abstract API client.
| Modifier and Type | Class and Description |
|---|---|
static class |
AbstractClient.LibraryVersion
A version of a software library.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addUserAgent(AbstractClient.LibraryVersion userAgent)
Add a software library to the list of user agents.
|
String |
getApplicationID() |
int |
getConnectTimeout()
Get the connection timeout.
|
String |
getHeader(String name)
Get an HTTP header.
|
int |
getHostDownDelay()
Get the timeout for retrying connection to a down host.
|
String[] |
getReadHosts() |
int |
getReadTimeout()
Get the default read timeout.
|
int |
getSearchTimeout()
Get the read timeout for search requests.
|
AbstractClient.LibraryVersion[] |
getUserAgents()
Retrieve the list of declared user agents.
|
String[] |
getWriteHosts() |
boolean |
hasUserAgent(AbstractClient.LibraryVersion userAgent)
Test whether a user agent is declared.
|
void |
removeUserAgent(AbstractClient.LibraryVersion userAgent)
Remove a software library from the list of user agents.
|
void |
setConnectTimeout(int connectTimeout)
Set the connection timeout.
|
void |
setHeader(String name,
String value)
Set an HTTP header that will be sent with every request.
|
void |
setHostDownDelay(int hostDownDelay)
Set the timeout for retrying connection to a down host.
|
void |
setHosts(String... hosts)
Set read and write hosts to the same value (convenience method).
|
void |
setReadHosts(String... hosts) |
void |
setReadTimeout(int readTimeout)
Set the default read timeout.
|
void |
setSearchTimeout(int searchTimeout)
Set the read timeout for search requests.
|
void |
setWriteHosts(String... hosts) |
public String getApplicationID()
public void setHeader(@NonNull
String name,
@Nullable
String value)
Set an HTTP header that will be sent with every request.
name - Header name.value - Value for the header. If null, the header will be removed.public String getHeader(@NonNull
String name)
Get an HTTP header.
name - Header name.public String[] getReadHosts()
public void setReadHosts(@NonNull
String... hosts)
public String[] getWriteHosts()
public void setWriteHosts(@NonNull
String... hosts)
public void setHosts(@NonNull
String... hosts)
Set read and write hosts to the same value (convenience method).
hosts - New hosts. Must not be empty.public int getConnectTimeout()
Get the connection timeout.
public void setConnectTimeout(int connectTimeout)
Set the connection timeout.
connectTimeout - The new connection timeout (ms).public int getReadTimeout()
Get the default read timeout.
public void setReadTimeout(int readTimeout)
Set the default read timeout.
readTimeout - The default read timeout (ms).public int getSearchTimeout()
Get the read timeout for search requests.
public void setSearchTimeout(int searchTimeout)
Set the read timeout for search requests.
searchTimeout - The read timeout for search requests (ms).public int getHostDownDelay()
Get the timeout for retrying connection to a down host.
public void setHostDownDelay(int hostDownDelay)
Set the timeout for retrying connection to a down host.
hostDownDelay - The delay before connecting again to a down host (ms).public void addUserAgent(@NonNull
AbstractClient.LibraryVersion userAgent)
Add a software library to the list of user agents.
userAgent - The library to add.public void removeUserAgent(@NonNull
AbstractClient.LibraryVersion userAgent)
Remove a software library from the list of user agents.
userAgent - The library to remove.@NonNull public AbstractClient.LibraryVersion[] getUserAgents()
Retrieve the list of declared user agents.
public boolean hasUserAgent(@NonNull
AbstractClient.LibraryVersion userAgent)
Test whether a user agent is declared.
userAgent - The user agent to look for.