List of usage examples for com.google.gson JsonElement toString
@Override
public String toString()
From source file:com.google.appinventor.components.runtime.RunningApplications.java
License:Open Source License
@Override public void registerDataRequest(int interval, int duration) { // TODO Auto-generated method stub Log.i(TAG, "Registering data requests."); JsonElement dataRequest = null; dataRequest = getDataRequest(interval, duration, RUNNINGAPPLICATIONS_PROBE); Log.i(TAG, "Data request: " + dataRequest.toString()); mBoundFunfManager.requestData(listener, dataRequest); }
From source file:com.google.appinventor.components.runtime.ScreenStatus.java
License:Open Source License
@Override public void registerDataRequest(int interval, int duration) { Log.i(TAG, "Registering data requests."); JsonElement dataRequest = null; dataRequest = getDataRequest(interval, duration, SCREENSTATUS_PROBE); Log.i(TAG, "Data request: " + dataRequest.toString()); mBoundFunfManager.requestData(listener, dataRequest); }
From source file:com.google.appinventor.components.runtime.SmsHistory.java
License:Open Source License
@Override public void registerDataRequest(int interval, int duration) { // TODO Auto-generated method stub Log.i(TAG, "Registering sms requests."); JsonElement dataRequest = null; dataRequest = getDataRequest(interval, duration, SMS_PROBE); if (afterDate != 0) ((JsonObject) dataRequest).addProperty("afterDate", afterDate); ((JsonObject) dataRequest).addProperty("hideSensitiveData", privacySafe); Log.i(TAG, "CallLog request: " + dataRequest.toString()); mBoundFunfManager.requestData(listener, dataRequest); }
From source file:com.google.appinventor.components.runtime.SocialProximitySensor.java
License:Open Source License
@Override public void registerDataRequest(int interval, int duration) { // TODO Auto-generated method stub Log.i(TAG, "Registering data requests."); JsonElement dataRequest = null; dataRequest = getDataRequest(interval, duration); Log.i(TAG, "Data request: " + dataRequest.toString()); mBoundFunfManager.requestData(listener, dataRequest); // Funf will overwrite with the new dataRequest configuration for // the same listener }
From source file:com.google.appinventor.components.runtime.TelephonyInfo.java
License:Open Source License
@Override public void registerDataRequest(int interval, int duration) { // TODO Auto-generated method stub Log.i(TAG, "Registering data requests."); JsonElement dataRequest = null; dataRequest = getDataRequest(interval, duration, TELEPHONY_PROBE); ((JsonObject) dataRequest).addProperty("hideSensitiveData", privacySafe); Log.i(TAG, "Data request: " + dataRequest.toString()); mBoundFunfManager.requestData(listener, dataRequest); }
From source file:com.google.appinventor.components.runtime.WifiSensor.java
License:Open Source License
@Override public void registerDataRequest(int interval, int duration) { // TODO Auto-generated method stub Log.i(TAG, "Registering data requests."); JsonElement dataRequest = null; dataRequest = getDataRequest(interval, duration, WIFI_PROBE); Log.i(TAG, "Data request: " + dataRequest.toString()); mBoundFunfManager.requestData(listener, dataRequest); }
From source file:com.google.code.bing.search.client.impl.BingSearchJsonClientImpl.java
License:Apache License
@SuppressWarnings("unchecked") protected <T> T unmarshallObject(Class<T> clazz, InputStream jsonContent) { try {//from w w w .ja v a2s .co m JsonElement response = parser.parse(new InputStreamReader(jsonContent, UTF_8_CHAR_SET)); if (response.isJsonObject()) { if (response.getAsJsonObject().get("SearchResponse") != null) { Gson gson = getGsonBuilder().create(); return (T) gson.fromJson(response.getAsJsonObject().get("SearchResponse"), clazz); } } throw new BingSearchException("Unknown content found in response:" + response.toString()); } catch (Exception e) { throw new BingSearchException(e); } }
From source file:com.google.code.stackexchange.client.impl.StackExchangeApiJsonClient.java
License:Apache License
protected <T> PagedList<T> unmarshallList(Class<T> clazz, InputStream jsonContent) { try {//from w w w .j a va 2 s.c o m JsonElement response = parser.parse(new InputStreamReader(jsonContent, UTF_8_CHAR_SET)); if (response.isJsonObject()) { JsonObject adaptee = response.getAsJsonObject(); PagedList<T> list = new PagedArrayList<T>(); if (adaptee.has("total")) { list.setTotal(adaptee.get("total").getAsLong()); } if (adaptee.has("page")) { list.setPage(adaptee.get("page").getAsInt()); } if (adaptee.has("pagesize")) { list.setPageSize(adaptee.get("pagesize").getAsInt()); } String placeHolder = LIST_PLACE_HOLDERS.get(clazz); if (adaptee.has(placeHolder)) { JsonArray elements = adaptee.get(placeHolder).getAsJsonArray(); if (elements != null) { Gson gson = getGsonBuilder().create(); for (JsonElement o : elements) { list.add(gson.fromJson(o, clazz)); } } } return list; } throw new StackExchangeApiException("Unknown content found in response:" + response.toString()); } catch (Exception e) { throw new StackExchangeApiException(e); } }
From source file:com.google.code.stackexchange.client.query.impl.BaseStackOverflowApiQuery.java
License:Apache License
@Override public PagedList<T> list() { InputStream jsonContent = null; try {//from ww w . j a v a 2 s . c om jsonContent = callApiMethod(apiUrlBuilder.buildUrl()); JsonElement response = parser.parse(new InputStreamReader(jsonContent, UTF_8_CHAR_SET)); if (response.isJsonObject()) { PagedList<T> responseList = unmarshall(response.getAsJsonObject()); notifyObservers(responseList); return responseList; } throw new StackExchangeApiException("Unknown content found in response:" + response.toString()); } catch (Exception e) { throw new StackExchangeApiException(e); } finally { closeStream(jsonContent); } }
From source file:com.google.code.stackexchange.client.query.impl.BaseStackOverflowApiQuery.java
License:Apache License
@Override public T singleResult() { InputStream jsonContent = null; try {//from w w w. j av a 2s .c om jsonContent = callApiMethod(apiUrlBuilder.buildUrl()); JsonElement response = parser.parse(new InputStreamReader(jsonContent, UTF_8_CHAR_SET)); if (response.isJsonObject()) { PagedList<T> responseList = unmarshall(response.getAsJsonObject()); notifyObservers(responseList); return getFirstElement(responseList); } throw new StackExchangeApiException("Unknown content found in response:" + response.toString()); } catch (Exception e) { throw new StackExchangeApiException(e); } finally { closeStream(jsonContent); } }