Public Member Functions | Public Attributes | Static Public Attributes | Protected Member Functions | Protected Attributes | Static Protected Attributes | Private Member Functions | Private Attributes | Static Private Attributes
org.xbmc.android.jsonrpc.api.AbstractCall< T > Class Reference
Inheritance diagram for org.xbmc.android.jsonrpc.api.AbstractCall< T >:
Inheritance graph
[legend]

List of all members.

Public Member Functions

void copyResponse (AbstractCall<?> call)
int describeContents ()
String getId ()
abstract String getName ()
ObjectNode getRequest ()
T getResult ()
ArrayList< TgetResults ()
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< TparseMany (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< TmResults = 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())

Detailed Description

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:

  1. Creation of the JSON request object sent to XBMC's JSON-RPC API
  2. Parsing of the JSON response and serialization into our model

Type

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.

Lists vs. single items

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:

  1. returnsList() returning true or false depending on if the API returns a list or not
  2. Depending on if a list is returned:

The rest is taken care of in this abstract class.

Author:
freezy <freezy@xbmc.org>

Definition at line 77 of file AbstractCall.java.


Constructor & Destructor Documentation

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.


Member Function Documentation

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).

Parameters:
nameName of the parameter
valueValue 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).

Parameters:
nameName of the parameter
valueValue 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).

Parameters:
nameName of the parameter
valueValue 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).

Parameters:
nameName of the parameter
valuesString 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).

Parameters:
nameName of the parmeter
mapString 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.

String org.xbmc.android.jsonrpc.api.AbstractCall< T >.getId ( ) [inline]

Returns the generated ID of the request.

Returns:
Generated ID of the request

Definition at line 214 of file AbstractCall.java.

abstract String org.xbmc.android.jsonrpc.api.AbstractCall< T >.getName ( ) [pure virtual]

Returns the name of the method.

Returns:
Full name of the method, e.g. "AudioLibrary.GetSongDetails".
ObjectNode org.xbmc.android.jsonrpc.api.AbstractCall< T >.getParameters ( ) [inline, private]

Returns the parameters array. Use this to add any parameters.

Parameters:
request
Returns:

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.

Returns:
Request object

Definition at line 150 of file AbstractCall.java.

T org.xbmc.android.jsonrpc.api.AbstractCall< T >.getResult ( ) [inline]

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.

Returns:
Result of the API method as a single item

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.

Returns:
Result of the API method as list

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.

Parameters:
objThe result node of the JSON response object.
Returns:
Result of the API call

Definition at line 256 of file AbstractCall.java.

T org.xbmc.android.jsonrpc.api.AbstractCall< T >.parseOne ( JsonNode  obj) [inline, protected]

Parses the result if the API method returns a single item.

Either this or parseMany(JsonNode) must be overridden by every sub class.

Parameters:
objThe result node of the JSON response object.
Returns:
Result of the API call

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.

Parameters:
obj
Returns:

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.

Returns:
True if API call returns a list, false if only one item
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.

Parameters:
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.

Parameters:
parcelthe Parcel in which the object should be written
flagsadditional flags about how the object should be written

Implements android.os.Parcelable.

Definition at line 360 of file AbstractCall.java.


Member Data Documentation

final String org.xbmc.android.jsonrpc.api.AbstractCall< T >.mId [private]

The ID of the request.

Definition at line 131 of file AbstractCall.java.

ObjectNode org.xbmc.android.jsonrpc.api.AbstractCall< T >.mRequest = OM.createObjectNode()

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.

T org.xbmc.android.jsonrpc.api.AbstractCall< T >.mResult = null [protected]

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" }

Todo:
fix example

Definition at line 125 of file AbstractCall.java.

ArrayList<T> org.xbmc.android.jsonrpc.api.AbstractCall< T >.mResults = null [protected]

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.

final String org.xbmc.android.jsonrpc.api.AbstractCall< T >.PARAMS = "params" [static, private]

Name of the node containing parameters in the JSON-RPC request

Definition at line 89 of file AbstractCall.java.

final String org.xbmc.android.jsonrpc.api.AbstractCall< T >.RESULT = "result" [static]

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.


The documentation for this class was generated from the following file:


smarthome_media_kodi_driver
Author(s): Mickael Gaillard , Erwan Le Huitouze
autogenerated on Thu Jun 6 2019 21:03:49