use of android.util.JsonReader in project android_frameworks_base by ResurrectionRemix.
the class AbstractAsset method create.
/**
* Creates a new Asset from its JSON string representation.
*
* @throws AssociationServiceException if the assetJson is not well formatted.
*/
public static AbstractAsset create(String assetJson) throws AssociationServiceException {
JsonReader reader = new JsonReader(new StringReader(assetJson));
reader.setLenient(false);
try {
return AssetFactory.create(JsonParser.parse(reader));
} catch (JSONException | IOException e) {
throw new AssociationServiceException("Input is not a well formatted asset descriptor.", e);
}
}
use of android.util.JsonReader in project android_frameworks_base by ResurrectionRemix.
the class StatementParser method parseStatement.
/**
* Parses a single JSON statement.
*/
static ParsedStatement parseStatement(String statementString, AbstractAsset source) throws AssociationServiceException, IOException, JSONException {
JsonReader reader = new JsonReader(new StringReader(statementString));
reader.setLenient(false);
return parseStatement(reader, source);
}
use of android.util.JsonReader in project DrupalCloud by INsReady.
the class RESTServerClient method viewsGet.
/*
* public String userLogout(String sessionID) throws
* ServiceNotAvailableException { // TODO Auto-generated method stub
* BasicNameValuePair[] parameters = new BasicNameValuePair[0]; //
* parameters[0] = new BasicNameValuePair("sessid", sessionID); String uri =
* mENDPOIN + "user/logout"; return call(uri, parameters); }
*/
public JsonReader viewsGet(String view_name, String display_id, String args, int offset, int limit) throws ServiceNotAvailableException, ClientProtocolException, IOException {
String uri = mENDPOIN + "views/" + view_name + "?" + "limit=" + limit + "&offset=" + offset;
if (args != null) {
uri += "&args=" + args;
}
if (display_id != null) {
uri += "&display_id=" + display_id;
}
JsonReader result = new JsonReader(callGet(uri));
return result;
}
use of android.util.JsonReader in project DrupalCloud by INsReady.
the class RESTServerClient method nodeGet.
/*
* private void systemConnect() throws ServiceNotAvailableException { //
* Cloud server hand shake String uri = mENDPOIN + "system/connect";
* mSERVERPOST = new HttpPost(uri); try { HttpResponse response =
* mClient.execute(mSERVERPOST); InputStream result =
* response.getEntity().getContent(); BufferedReader br = new
* BufferedReader( new InputStreamReader(result)); String tmp =
* br.readLine(); if (tmp == null) { // TODO throw new
* ServiceNotAvailableException(this, // "Invalid method"); } JSONObject jso
* = new JSONObject(tmp); // Save the sessionid to storage SharedPreferences
* auth = mCtx.getSharedPreferences(mPREFS_AUTH, 0);
* SharedPreferences.Editor editor = auth.edit();
* editor.putString("sessionid", jso.getString("sessid"));
* editor.putLong("sessionid_timestamp", new Date().getTime() / 100);
* editor.commit();
*
* } catch (UnsupportedEncodingException e) { e.printStackTrace(); } catch
* (ClientProtocolException e) { e.printStackTrace(); } catch (IOException
* e) { e.printStackTrace(); } catch (JSONException e) { // TODO
* Auto-generated catch block e.printStackTrace(); } }
*/
public JsonReader nodeGet(int nid, String fields) throws ServiceNotAvailableException, ClientProtocolException, IOException {
String uri = mENDPOIN + "node/" + nid;
JsonReader jsr = new JsonReader(callGet(uri));
return jsr;
}
use of android.util.JsonReader in project DrupalCloud by INsReady.
the class RESTServerClient method taxonomyVocabGetTree.
public JsonReader taxonomyVocabGetTree(int vid, int parent, int maxdepth) throws ServiceNotAvailableException, ClientProtocolException, IOException {
String uri = mENDPOIN + "taxonomy_vocabulary/getTree";
int size = 2;
BasicNameValuePair[] parameters = null;
if (maxdepth != 0) {
size = 3;
parameters = new BasicNameValuePair[size];
parameters[2] = new BasicNameValuePair("maxdepth", String.valueOf(maxdepth));
} else {
parameters = new BasicNameValuePair[size];
}
parameters[0] = new BasicNameValuePair("vid", String.valueOf(vid));
parameters[1] = new BasicNameValuePair("parent", String.valueOf(parent));
JsonReader jsr = new JsonReader(callPost(uri, parameters));
return jsr;
}
Aggregations