Q - the child class that extends this abstract classR - the type the child class' execute()-function returnspublic abstract class APIQuery<Q extends APIQuery,R> extends AbstractQuery<Q,R>
| Modifier and Type | Field and Description |
|---|---|
protected IRateLimiter |
generalRateLimiter
The general rate limiter for all API calls.
|
protected String |
resourceValue
The resource value, e.g.
|
userAgent| Modifier | Constructor and Description |
|---|---|
protected |
APIQuery(IXmlConverter xmlConverter,
IRateLimiter generalRateLimiter,
IRateLimiter scrapingRateLimiter,
String baseUrl,
String userAgent,
int apiVersion,
String resourceValue)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
protected String |
buildURL()
Generates a String URL based on the supplied values.
|
<T> T |
execute(Class<T> type)
Executes this query, returning any result.
|
protected IRateLimiter |
getRateLimiter()
Returns the rate limiter to use in the makeRequest()-function.
|
protected abstract String |
resourceString()
Gives the resource string of this Query, e.g.
|
Q |
slowMode()
Makes the Query execute in slow mode, reducing the rate limit from 6
requests per 4 seconds to only 1 request per second.
|
protected void |
validateQueryParameters()
Validates the query parameters before executing the query.
|
closeInputStreamQuietly, execute, makeRequest, translateResponseprotected final IRateLimiter generalRateLimiter
protected final String resourceValue
protected APIQuery(IXmlConverter xmlConverter, IRateLimiter generalRateLimiter, IRateLimiter scrapingRateLimiter, String baseUrl, String userAgent, int apiVersion, String resourceValue)
xmlConverter - The converter for translating XML from the API to
objects.resourceValue - The resource value (e.g. 'nation', 'region'...)generalRateLimiter - The default rate limiterbaseUrl - The URL to the API to consumeuserAgent - The User Agent to communicate withapiVersion - The version of the API to expect to consumescrapingRateLimiter - Rate limiter used when 'scraping'public Q slowMode()
protected IRateLimiter getRateLimiter()
public <T> T execute(Class<T> type)
AbstractQueryexecute in class AbstractQuery<Q extends APIQuery,R>T - the type to returntype - the type to returnprotected void validateQueryParameters()
AbstractQueryvalidateQueryParameters in class AbstractQuery<Q extends APIQuery,R>protected String buildURL()
AbstractQuerybuildURL in class AbstractQuery<Q extends APIQuery,R>protected abstract String resourceString()
Copyright © 2017. All rights reserved.