XbmcJson.java
Go to the documentation of this file.
00001 
00009 package org.rosmultimedia.player.xbmc.jsonrpc;
00010 
00011 import java.util.List;
00012 
00013 import org.codehaus.jackson.node.ObjectNode;
00014 import org.xbmc.android.jsonrpc.api.AbstractCall;
00015 import org.xbmc.android.jsonrpc.io.ApiException;
00016 import org.xbmc.android.jsonrpc.io.JsonApiRequest;
00017 
00024 public class XbmcJson {
00028         private String url;
00032         private String user;
00036         private String password;
00037 
00044         public XbmcJson(String url, String user, String password) {
00045                 this.url = url;
00046                 this.user = user;
00047                 this.password = password;
00048         }
00049 
00055         public <T> T getResult(AbstractCall<T> caller) {
00056                 T result = null;
00057 
00058                 this.executeCall(caller);
00059                 result = caller.getResult();
00060 
00061                 return result;
00062         }
00063 
00069         public <T> List<T> getResults(AbstractCall<T> caller) {
00070                 List<T> result = null;
00071 
00072                 this.executeCall(caller);
00073                 result = caller.getResults();
00074 
00075                 return result;
00076         }
00077 
00082         private void executeCall(AbstractCall<?> caller) {
00083                 try {
00084                         ObjectNode object = JsonApiRequest.execute(
00085                                         this.url,
00086                                         this.user,
00087                                         this.password,
00088                                         caller.getRequest());
00089 
00090                         caller.setResponse(object);
00091                 } catch (ApiException e) {
00092 
00093                 }
00094         }
00095 }


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