Exemple #1
0
  @Override
  protected void init() {
    String versionName = "version";
    String statusName = "status";
    String contributeName = "contribute";
    JSONObject versionJSON = JSONUtil.getJSONObject(json, versionName);
    if (versionJSON != null) version = new Version(versionJSON);

    JSONObject statusJSON = JSONUtil.getJSONObject(json, statusName);
    if (statusJSON != null) status = new Status(statusJSON);

    JSONObject contributeJSON = JSONUtil.getJSONObject(json, contributeName);
    if (contributeJSON == null) {
      JSONArray contributeArray = JSONUtil.getJSONArray(json, contributeName);
      if (contributeArray != null) {
        for (int i = 0; i < contributeArray.length(); i++) {
          JSONObject object = contributeArray.optJSONObject(i);
          if (object != null)
            addContribute(new Contribute(object, Contribute.CONTRIBUTETYPE.LIFECYCLE));
        }
      }
    } else {
      addContribute(new Contribute(contributeJSON, Contribute.CONTRIBUTETYPE.LIFECYCLE));
    }
  }
Exemple #2
0
 /**
  * Produce a comma delimited text from a JSONArray of JSONObjects. The first row will be a list of
  * names obtained by inspecting the first JSONObject.
  *
  * @param ja A JSONArray of JSONObjects.
  * @return A comma delimited text.
  * @throws JSONException
  */
 public static String toString(JSONArray ja) throws JSONException {
   JSONObject jo = ja.optJSONObject(0);
   if (jo != null) {
     JSONArray names = jo.names();
     if (names != null) {
       return rowToString(names) + toString(names, ja);
     }
   }
   return null;
 }
Exemple #3
0
 /**
  * Produce a comma delimited text from a JSONArray of JSONObjects using a provided list of names.
  * The list of names is not included in the output.
  *
  * @param names A JSONArray of strings.
  * @param ja A JSONArray of JSONObjects.
  * @return A comma delimited text.
  * @throws JSONException
  */
 public static String toString(JSONArray names, JSONArray ja) throws JSONException {
   if (names == null || names.length() == 0) {
     return null;
   }
   StringBuffer sb = new StringBuffer();
   for (int i = 0; i < ja.length(); i += 1) {
     JSONObject jo = ja.optJSONObject(i);
     if (jo != null) {
       sb.append(rowToString(jo.toJSONArray(names)));
     }
   }
   return sb.toString();
 }