Q - the child class that extends this abstract classR - the type the child class' execute()-function returnspublic abstract class AbstractQuery<Q extends AbstractQuery,R> extends Object
| Modifier and Type | Field and Description |
|---|---|
protected String |
userAgent
User agent by which this library or its consumer is recognized.
|
| Modifier | Constructor and Description |
|---|---|
protected |
AbstractQuery(IXmlConverter xmlConverter,
String baseUrl,
String userAgent)
Constructor, setting the returnType.
|
| Modifier and Type | Method and Description |
|---|---|
protected String |
buildURL()
Generates a String URL based on the supplied values.
|
protected static void |
closeInputStreamQuietly(InputStream stream)
Closes the given InputStream.
|
R |
execute()
Executes this query, returning any result.
|
<T> T |
execute(Class<T> type)
Executes this query, returning any result.
|
protected <T> T |
makeRequest(String urlStr,
Class<T> type)
Makes a GET request to the NationStates API.
|
protected <T> T |
translateResponse(InputStream response,
Class<T> type)
Translates the stream response to the object this Query wishes to return
via its execute() function.
|
protected void |
validateQueryParameters()
Validates the query parameters before executing the query.
|
protected final String userAgent
protected AbstractQuery(IXmlConverter xmlConverter, String baseUrl, String userAgent)
xmlConverter - The converter for translating XML from the API to
objects.baseUrl - Base URL to NationStates.userAgent - User agent by which this library or its consumer is
recognized.protected void validateQueryParameters()
protected String buildURL()
public final R execute()
public <T> T execute(Class<T> type)
T - the type to returntype - the type to returnprotected final <T> T makeRequest(String urlStr, Class<T> type)
T - type to parse tourlStr - the url to make the request totype - type to parse toprotected <T> T translateResponse(InputStream response, Class<T> type)
T - type to parse toresponse - the response to translatetype - type to parse toprotected static final void closeInputStreamQuietly(InputStream stream)
stream - the InputStream to closeCopyright © 2017. All rights reserved.