Esempio n. 1
0
 /**
  * Construct a JSONArray from a Collection.
  *
  * @param collection A Collection.
  */
 public JSONArray(Collection<?> collection) {
   this.myArrayList = new ArrayList<Object>();
   if (collection != null) {
     for (Object o : collection) {
       this.myArrayList.add(JSONObject.wrap(o));
     }
   }
 }
Esempio n. 2
0
 /**
  * Construct a JSONArray from a Collection.
  *
  * @param collection A Collection.
  */
 public JSONArray(Collection collection) {
   this.myArrayList = new ArrayList();
   if (collection != null) {
     for (Object aCollection : collection) {
       this.myArrayList.add(JSONObject.wrap(aCollection));
     }
   }
 }
Esempio n. 3
0
 public JSONArray(Object paramObject) throws JSONException {
   this();
   if (paramObject.getClass().isArray()) {
     int i = Array.getLength(paramObject);
     for (int j = 0; j < i; j++) put(JSONObject.wrap(Array.get(paramObject, j)));
   }
   throw new JSONException("JSONArray initial value should be a string or collection or array.");
 }
Esempio n. 4
0
 /**
  * Construct a JSONArray from a Collection.
  *
  * @param collection A Collection.
  */
 public JSONArray(Collection<Object> collection) {
   this.myArrayList = new ArrayList<>();
   if (collection != null) {
     Iterator<Object> iter = collection.iterator();
     while (iter.hasNext()) {
       this.myArrayList.add(JSONObject.wrap(iter.next()));
     }
   }
 }
Esempio n. 5
0
 public JSONArray(Collection paramCollection) {
   if (paramCollection != null) {
     Iterator localIterator = paramCollection.iterator();
     while (localIterator.hasNext()) {
       Object localObject = localIterator.next();
       this.myArrayList.add(JSONObject.wrap(localObject));
     }
   }
 }
Esempio n. 6
0
 /**
  * Construct a JSONArray from an array
  *
  * @throws JSONException If not an array.
  */
 public JSONArray(Object array) throws JSONException {
   this();
   if (array.getClass().isArray()) {
     int length = Array.getLength(array);
     for (int i = 0; i < length; i += 1) {
       this.put(JSONObject.wrap(Array.get(array, i)));
     }
   } else
     throw new JSONException("JSONArray initial value should be a string or collection or array.");
 }
 /**
  * Construct a JSONArray from a Collection.
  *
  * @param collection A Collection.
  */
 public JSONArray(Collection collection) {
   this.myArrayList = new ArrayList();
   if (collection != null) {
     Iterator iter = collection.iterator();
     while (iter.hasNext()) {
       Object o = iter.next();
       this.myArrayList.add(JSONObject.wrap(o));
     }
   }
 }
Esempio n. 8
0
 /**
  * Construct a JSONArray from an array
  *
  * @throws JSONException If not an array.
  */
 protected JSONArray(Object array) {
   this();
   if (array.getClass().isArray()) {
     int length = Array.getLength(array);
     for (int i = 0; i < length; i += 1) {
       this.append(JSONObject.wrap(Array.get(array, i)));
     }
   } else {
     throw new RuntimeException(
         "JSONArray initial value should be a string or collection or array.");
   }
 }