public class FlattrConnection extends Object implements Connection
Connection.| Constructor and Description |
|---|
FlattrConnection(RequestType type)
Creates a new
FlattrConnection for the given RequestType. |
| Modifier and Type | Method and Description |
|---|---|
protected String |
base64(String str)
Base64 encodes a string.
|
Connection |
call(String call)
Call to be placed against the URL.
|
protected HttpURLConnection |
createConnection(URL url)
Creates a
HttpURLConnection to the given url. |
Connection |
data(FlattrObject data)
Data to be transported to the call.
|
Connection |
form(String name,
String value)
Form parameter to be sent.
|
protected Charset |
getCharset(String contentType)
Gets the
Charset from the content-type header. |
Connection |
key(ConsumerKey key)
Consumer key to be used.
|
Connection |
parameter(String name,
String value)
A parameter to be used for a placeholder in the call string.
|
Connection |
parameterArray(String name,
String[] value)
An array of parameters to be used for a placeholder in the call string.
|
Connection |
query(String name,
String value)
Query parameter to be used in the URL.
|
Connection |
rateLimit(RateLimit limit)
RateLimit object to keep updated. |
Collection<FlattrObject> |
result()
Invokes the call and returns a Collection of
FlattrObject as response. |
FlattrObject |
singleResult()
Invokes the call and returns a single
FlattrObject as response. |
Connection |
token(AccessToken token)
Access token to be used for calls that require authentication.
|
Connection |
url(String url)
Base URL to connect to.
|
public FlattrConnection(RequestType type)
FlattrConnection for the given RequestType.type - RequestType to be usedpublic Connection url(String url)
Connectionurl in interface Connectionurl - URL to connect to.public Connection call(String call)
Connection
If no call is set, the Connection.url(String) is invoked unchanged.
call in interface Connectioncall - Signature of the call to be invokedpublic Connection token(AccessToken token)
ConnectionAccessToken is set, the call will be placed anonymously.token in interface Connectiontoken - AccessToken to be usedpublic Connection key(ConsumerKey key)
Connectionkey in interface Connectionkey - ConsumerKey to be usedpublic Connection parameter(String name, String value)
Connectionparameter in interface Connectionname - Parameter name, without colon prependedvalue - Value to be used. Will be URL encoded.public Connection parameterArray(String name, String[] value)
ConnectionparameterArray in interface Connectionname - Parameter name, without colon prependedvalue - Values to be used.public Connection query(String name, String value)
Connectionquery in interface Connectionname - Parameter namevalue - Parameter valuepublic Connection data(FlattrObject data)
ConnectionRequestType.POST or
RequestType.PATCH, otherwise an exception will be thrown.data in interface Connectiondata - Data to be sentpublic Connection form(String name, String value)
ConnectionRequestType.POST, otherwise an
exception will be thrown. Do not mix with Connection.data(FlattrObject).form in interface Connectionname - Parameter namevalue - Parameter valuepublic Connection rateLimit(RateLimit limit)
ConnectionRateLimit object to keep updated.rateLimit in interface Connectionlimit - RateLimit objectpublic Collection<FlattrObject> result() throws FlattrException
ConnectionFlattrObject as response.result in interface ConnectionFlattrObject, may be empty but never
nullFlattrException - if the call could not be invoked or the web service returned an errorpublic FlattrObject singleResult() throws FlattrException
ConnectionFlattrObject as response.singleResult in interface ConnectionFlattrObject, never nullFlattrException - if the call could not be invoked or the web service returned an errorprotected HttpURLConnection createConnection(URL url) throws IOException
HttpURLConnection to the given url. Override to configure the
connection.url - URL to connect toHttpURLConnection that is connected to the url and is
preconfigured.IOExceptionprotected Charset getCharset(String contentType)
Charset from the content-type header. If there is no charset, the
default charset is returned instead.contentType - content-type header, may be nullCharsetCopyright © 2010–2014. All rights reserved.