public abstract class AbstractRequester extends Object
Class which contains the logic for sending URL requests to a specified address.
Modifier | Constructor and Description |
---|---|
protected |
AbstractRequester()
Default constructor.
|
protected |
AbstractRequester(Charset charset)
Overloaded constructor.
|
Modifier and Type | Method and Description |
---|---|
Charset |
getCharset()
Getter for charset.
|
protected URLConnection |
getConnection(String url)
Retrieves the
URLConnection that represents the specified URL. |
abstract HttpResponse |
getResponse(String url)
Retrieves the response from the specified URL.
|
protected HttpResponse |
getResponse(URLConnection connection)
Retrieves the response from the specified
URLConnection . |
void |
setCharset(Charset charset)
Setter for charset.
|
protected AbstractRequester()
Default constructor. Specifies the charset to be used for requests as UTF-8.
protected AbstractRequester(Charset charset)
Overloaded constructor. Loads the request properties and other data needed for the requesters.
charset
- the charset to use when doing a requestprotected URLConnection getConnection(String url) throws IOException
Retrieves the URLConnection
that represents the specified URL. This
method sets the request properties for the URLConnection
being
retrieved.
url
- the URLURLConnection
IOException
- if an exception occurred when creating the URLConnection
protected HttpResponse getResponse(URLConnection connection) throws IOException
Retrieves the response from the specified URLConnection
.
connection
- the URLConnection
Response
IOException
- if an exception occurred while retrieving the Response
public abstract HttpResponse getResponse(String url)
Retrieves the response from the specified URL.
url
- the URL to callResponse
public final Charset getCharset()
Getter for charset.
public final void setCharset(Charset charset)
Setter for charset.
charset
- the charsetCopyright © 2018. All rights reserved.