Public Member Functions | |
void | copyResponse (AbstractCall<?> call) |
int | describeContents () |
String | getId () |
abstract String | getName () |
ObjectNode | getRequest () |
T | getResult () |
ArrayList< T > | getResults () |
void | setResponse (JsonNode response) |
void | writeToParcel (Parcel parcel, int flags) |
Public Attributes | |
ObjectNode | mRequest = OM.createObjectNode() |
Static Public Attributes | |
static final String | RESULT = "result" |
Protected Member Functions | |
AbstractCall () | |
AbstractCall (Parcel parcel) | |
void | addParameter (String name, String value) |
void | addParameter (String name, Integer value) |
void | addParameter (String name, Boolean value) |
void | addParameter (String name, Double value) |
void | addParameter (String name, AbstractModel value) |
void | addParameter (String name, String[] values) |
void | addParameter (String name, HashMap< String, String > map) |
ArrayList< T > | parseMany (JsonNode obj) |
T | parseOne (JsonNode obj) |
JsonNode | parseResult (JsonNode obj) |
ArrayNode | parseResults (JsonNode obj, String key) |
abstract boolean | returnsList () |
Protected Attributes | |
T | mResult = null |
ArrayList< T > | mResults = null |
Static Protected Attributes | |
static final ObjectMapper | OM = new ObjectMapper() |
Private Member Functions | |
ObjectNode | getParameters () |
Private Attributes | |
final String | mId |
Static Private Attributes | |
static final String | PARAMS = "params" |
static final Random | RND = new Random(System.currentTimeMillis()) |
Super class of all API call implementations.
Every sub class represents an API method of XBMC's JSON-RPC API. Basically it implements two things:
Every sub class is typed with the class of our model that is returned in the API method. The model aims to represent the types of the JSON-RPC API. All classes of the model extend AbstractModel.
API methods either return a single item or a list of items. We both define getResult() for a single result and getResults() for a bunch of results. Both work independently of what actual kind of result is returned by XBMC.
The difference is *what* those methods return. If the API returns a list, getResult() will return the first item. If the API returns a single item, getResults() returns a list containing only one item.
The subclass has therefore to implement particulary two things:
true
or false
depending on if the API returns a list or not The rest is taken care of in this abstract class.
Definition at line 77 of file AbstractCall.java.
org.xbmc.android.jsonrpc.api.AbstractCall< T >.AbstractCall | ( | ) | [inline, protected] |
Creates the standard structure of the JSON request.
Definition at line 137 of file AbstractCall.java.
org.xbmc.android.jsonrpc.api.AbstractCall< T >.AbstractCall | ( | Parcel | parcel | ) | [inline, protected] |
Definition at line 369 of file AbstractCall.java.
void org.xbmc.android.jsonrpc.api.AbstractCall< T >.addParameter | ( | String | name, |
String | value | ||
) | [inline, protected] |
Adds a string parameter to the request object (only if not null).
name | Name of the parameter |
value | Value of the parameter |
Definition at line 265 of file AbstractCall.java.
void org.xbmc.android.jsonrpc.api.AbstractCall< T >.addParameter | ( | String | name, |
Integer | value | ||
) | [inline, protected] |
Adds an integer parameter to the request object (only if not null).
name | Name of the parameter |
value | Value of the parameter |
Definition at line 276 of file AbstractCall.java.
void org.xbmc.android.jsonrpc.api.AbstractCall< T >.addParameter | ( | String | name, |
Boolean | value | ||
) | [inline, protected] |
Adds a boolean parameter to the request object (only if not null).
name | Name of the parameter |
value | Value of the parameter |
Definition at line 287 of file AbstractCall.java.
void org.xbmc.android.jsonrpc.api.AbstractCall< T >.addParameter | ( | String | name, |
Double | value | ||
) | [inline, protected] |
Definition at line 293 of file AbstractCall.java.
void org.xbmc.android.jsonrpc.api.AbstractCall< T >.addParameter | ( | String | name, |
AbstractModel | value | ||
) | [inline, protected] |
Definition at line 299 of file AbstractCall.java.
void org.xbmc.android.jsonrpc.api.AbstractCall< T >.addParameter | ( | String | name, |
String[] | values | ||
) | [inline, protected] |
Adds an array of strings to the request object (only if not null and not empty).
name | Name of the parameter |
values | String values |
Definition at line 310 of file AbstractCall.java.
void org.xbmc.android.jsonrpc.api.AbstractCall< T >.addParameter | ( | String | name, |
HashMap< String, String > | map | ||
) | [inline, protected] |
Adds a hashmap of strings to the request object (only if not null and not empty).
name | Name of the parmeter |
map | String map |
Definition at line 327 of file AbstractCall.java.
void org.xbmc.android.jsonrpc.api.AbstractCall< T >.copyResponse | ( | AbstractCall<?> | call | ) | [inline] |
Definition at line 170 of file AbstractCall.java.
int org.xbmc.android.jsonrpc.api.AbstractCall< T >.describeContents | ( | ) | [inline] |
Implements android.os.Parcelable.
Definition at line 365 of file AbstractCall.java.
Returns the generated ID of the request.
Definition at line 214 of file AbstractCall.java.
Returns the name of the method.
ObjectNode org.xbmc.android.jsonrpc.api.AbstractCall< T >.getParameters | ( | ) | [inline, private] |
Returns the parameters array. Use this to add any parameters.
request |
Definition at line 343 of file AbstractCall.java.
ObjectNode org.xbmc.android.jsonrpc.api.AbstractCall< T >.getRequest | ( | ) | [inline] |
Returns the JSON request object sent to XBMC.
Definition at line 150 of file AbstractCall.java.
Returns the result as a single item.
If the API method returned a list, this will return the first item, otherwise the one item returned by the API method is returned.
Definition at line 186 of file AbstractCall.java.
ArrayList<T> org.xbmc.android.jsonrpc.api.AbstractCall< T >.getResults | ( | ) | [inline] |
Returns the result as a list of items.
If the API method returned a single result, this will return a list containing the single result only, otherwise the whole list is returned.
Definition at line 201 of file AbstractCall.java.
ArrayList<T> org.xbmc.android.jsonrpc.api.AbstractCall< T >.parseMany | ( | JsonNode | obj | ) | [inline, protected] |
Parses the result if the API method returns a list of items.
Either this or parseOne(JsonNode) must be overridden by every sub class.
obj | The result node of the JSON response object. |
Definition at line 256 of file AbstractCall.java.
Parses the result if the API method returns a single item.
Either this or parseMany(JsonNode) must be overridden by every sub class.
obj | The result node of the JSON response object. |
Definition at line 243 of file AbstractCall.java.
JsonNode org.xbmc.android.jsonrpc.api.AbstractCall< T >.parseResult | ( | JsonNode | obj | ) | [inline, protected] |
Gets the result object from a response.
obj |
Definition at line 223 of file AbstractCall.java.
ArrayNode org.xbmc.android.jsonrpc.api.AbstractCall< T >.parseResults | ( | JsonNode | obj, |
String | key | ||
) | [inline, protected] |
Definition at line 227 of file AbstractCall.java.
abstract boolean org.xbmc.android.jsonrpc.api.AbstractCall< T >.returnsList | ( | ) | [protected, pure virtual] |
Returns true if the API method returns a list of items, false if the API method returns a single item.
Depending on this value, either parseOne(JsonNode) or parseMany(JsonNode) must be overridden by the sub class.
void org.xbmc.android.jsonrpc.api.AbstractCall< T >.setResponse | ( | JsonNode | response | ) | [inline] |
Sets the response object once the data has arrived. This must be the root object of the response, containing the result
object.
response |
Definition at line 161 of file AbstractCall.java.
void org.xbmc.android.jsonrpc.api.AbstractCall< T >.writeToParcel | ( | Parcel | parcel, |
int | flags | ||
) | [inline] |
Flatten this object into a Parcel.
parcel | the Parcel in which the object should be written |
flags | additional flags about how the object should be written |
Implements android.os.Parcelable.
Definition at line 360 of file AbstractCall.java.
The ID of the request.
Definition at line 131 of file AbstractCall.java.
JSON request object sent to the API
<u>Example</u>: {"jsonrpc": "2.0", "method": "Application.GetProperties", "id": "1", "params": { "properties": [ "version" ] } }
Definition at line 115 of file AbstractCall.java.
The response
node of the JSON response (the root node of the response)
<u>Example</u>: { "version": { "major": 11, "minor": 0, "revision": "20111210-f1ae0b6", "tag": "alpha" }
Definition at line 125 of file AbstractCall.java.
Definition at line 126 of file AbstractCall.java.
final ObjectMapper org.xbmc.android.jsonrpc.api.AbstractCall< T >.OM = new ObjectMapper() [static, protected] |
Definition at line 84 of file AbstractCall.java.
Name of the node containing parameters in the JSON-RPC request
Definition at line 89 of file AbstractCall.java.
Definition at line 81 of file AbstractCall.java.
final Random org.xbmc.android.jsonrpc.api.AbstractCall< T >.RND = new Random(System.currentTimeMillis()) [static, private] |
Definition at line 83 of file AbstractCall.java.