/** * Get the optional string value associated with an index. 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. * * @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. 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. * * @param index The index must be between 0 and length() - 1. * @return A String value. */ public String optString(int index) { return optString(index, ""); }
/** * Given an array of keys from the request object, return the desired returnKeys. * <p/> * Useful for when the return keys are being passed in as a parameter to an extension method. * * @param arrayOfKeys array of keys from the request object. * @param wildcard a value that represents the specification of all keys * @return the return keys */ public static Set<String> getReturnKeys(final JSONArray arrayOfKeys, final String wildcard) { Set<String> returnKeys = null; if (arrayOfKeys != null) { returnKeys = new HashSet<String>(); for (int ix = 0; ix < arrayOfKeys.length(); ix++) { returnKeys.add(arrayOfKeys.optString(ix)); } if (returnKeys.size() == 1 && returnKeys.contains(wildcard)) { returnKeys = null; } } else { returnKeys = null; } return returnKeys; }
public <T extends Element> Set<String> getIndexedKeys(Class<T> elementClass) { final String c = getKeyIndexClass(elementClass); final JSONArray jsonArray = RestHelper.getResultArray(this.graphURI + RexsterTokens.SLASH_KEY_INDICES_SLASH + c); final HashSet<String> keys = new HashSet<String>(); for (int ix = 0; ix < jsonArray.length(); ix++) { keys.add(jsonArray.optString(ix)); } return keys; }
final StringBuffer sb = new StringBuffer(); for (int ix = 0; ix < propertyArray.length(); ix++) { sb.append(propertyArray.optString(ix));
public static enum TYPE_STRICT {any,all,should};
private static Constraint parseSimilarityConstraint(JSONObject jConstraint, NamespacePrefixService nsPrefixService) throws JSONException { String context = jConstraint.optString("context"); if(context == null){ throw new IllegalArgumentException("SimilarityConstraints MUST define a \"context\": \n "+jConstraint.toString(4)); } JSONArray addFields = jConstraint.optJSONArray("addFields"); final List<String> fields; if(addFields != null && addFields.length() > 0){ fields = new ArrayList<String>(addFields.length()); for(int i=0;i<addFields.length();i++){ String field = addFields.optString(i); field = field != null ? nsPrefixService.getFullName(field) : null; if(field != null && !field.isEmpty()){ fields.add(field); } } } else { fields = null; } return new SimilarityConstraint(context,fields); }
/** * Asserts that the selected JSONArray of the field query returned within * the result list contains parsed selected fields * @param jQuery the query e.g. as returned by * {@link #assertQueryResults(RequestExecutor, QueryTestCase)} * @return the selected fields for further processing * @throws JSONException on any error while parsing the JSON */ public static JSONArray assertSelectedField(JSONObject jQuery,String...selected) throws JSONException { Set<String> selectedSet = new HashSet<String>(); if(selected == null || selected.length == 0) { selectedSet = Collections.emptySet(); } else { selectedSet = new HashSet<String>(Arrays.asList(selected)); } JSONArray jSelected = jQuery.optJSONArray("selected"); assertNotNull("Result Query is missing the 'selected' property",jSelected); assertTrue("Result Query is expected to have at least a single selected field", jSelected.length() > 0); boolean found = false; for(int i=0;i<jSelected.length() && !found;i++){ String selectedField = jSelected.optString(i,null); assertNotNull("Selected array contains a NULL element \n"+jSelected.toString(4), selectedField); selectedSet.remove(selectedField); } assertTrue("Fields "+selectedSet+" are not selected by\n"+jSelected.toString(4), selectedSet.isEmpty()); return jSelected; }
List<String> values = new ArrayList<String>(); for (int i = 0; i < jsonArray.length(); i++) { String value = jsonArray.optString(i); if (value != null) { values.add(value);
JSONObject fieldValue = jValues.optJSONObject(i); assertNotNull("Values for field "+key+" does contain an value " + "that is not an JSONObject "+jValues.optString(i), fieldValue); String[] value = new String[2];
String stringValue = listOrObject ? array.optJSONObject(i).toString() : array.optString(i);
List<String> values = new ArrayList<String>(); for (int i = 0; i < jsonArray.length(); i++) { String value = jsonArray.optString(i); if (value != null) { values.add(value); List<String> values = new ArrayList<String>(); for (int i = 0; i < jsonArray.length(); i++) { String value = jsonArray.optString(i); if (value != null) { values.add(value);
List<String> values = new ArrayList<String>(); for (int i = 0; i < jsonArray.length(); i++) { String value = jsonArray.optString(i); if (value != null) { values.add(value); List<String> values = new ArrayList<String>(); for (int i = 0; i < jsonArray.length(); i++) { String value = jsonArray.optString(i); if (value != null) { values.add(value); List<String> values = new ArrayList<String>(); for (int i = 0; i < jsonArray.length(); i++) { String value = jsonArray.optString(i); if (value != null) { values.add(value);
if (jsonArray != null) { for (int i = 0; i < jsonArray.length(); i++) { String value = jsonArray.optString(i); if (value != null) { values.add(value);
List<String> values = new ArrayList<String>(); for (int i = 0; i < jsonArray.length(); i++) { String value = jsonArray.optString(i); if (value != null) { values.add(value); List<String> values = new ArrayList<String>(); for (int i = 0; i < jsonArray.length(); i++) { String value = jsonArray.optString(i); if (value != null) { values.add(value);
List<String> values = new ArrayList<String>(); for (int i = 0; i < jsonArray.length(); i++) { String value = jsonArray.optString(i); if (value != null) { values.add(value); List<String> values = new ArrayList<String>(); for (int i = 0; i < jsonArray.length(); i++) { String value = jsonArray.optString(i); if (value != null) { values.add(value);
if (jsonArray != null) { for (int i = 0; i < jsonArray.length(); i++) { String value = jsonArray.optString(i); if (value != null) { values.add(value);
List<String> values = new ArrayList<String>(); for (int i = 0; i < jsonArray.length(); i++) { String value = jsonArray.optString(i); if (value != null) { values.add(value); List<String> values = new ArrayList<String>(); for (int i = 0; i < jsonArray.length(); i++) { String value = jsonArray.optString(i); if (value != null) { values.add(value);