/** * Get the optional string value associated with an index.<p> * * It returns an empty string if there is no value at that index. If the value * is not a string and is not null, then it is coverted to a string.<p> * * @param index the index must be between 0 and length() - 1 * @return a String value */ public String optString(int index) { return optString(index, ""); }
/** * Get the optional string value associated with an index.<p> * * It returns an empty string if there is no value at that index. If the value * is not a string and is not null, then it is coverted to a string.<p> * * @param index the index must be between 0 and length() - 1 * @return a String value */ public String optString(int index) { return optString(index, ""); }
/** * Converts the given JSON object into a valid parameter map.<p> * * @param params the JSON object to convert * * @return the parameter map from the given JSON object */ public static Map<String, String[]> getParameterMapFromJSON(JSONObject params) { Map<String, String[]> result = new HashMap<String, String[]>(); Iterator<String> itKeys = params.keys(); while (itKeys.hasNext()) { String key = itKeys.next(); JSONArray paramValue = params.optJSONArray(key); result.put(key, new String[paramValue.length()]); for (int i = 0, l = paramValue.length(); i < l; i++) { result.get(key)[i] = paramValue.optString(i); } } return result; }
List<String> formatValueList = new ArrayList<String>(formatValues.length()); for (int i = 0; i < formatValues.length(); i++) { formatValueList.add(formatValues.optString(i));
List formatValueList = new ArrayList(formatValues.length()); for (int i = 0; i < formatValues.length(); i++) { formatValueList.add(formatValues.optString(i));