本文整理汇总了Java中com.google.gwt.json.client.JSONValue.isArray方法的典型用法代码示例。如果您正苦于以下问题:Java JSONValue.isArray方法的具体用法?Java JSONValue.isArray怎么用?Java JSONValue.isArray使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.gwt.json.client.JSONValue
的用法示例。
在下文中一共展示了JSONValue.isArray方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: fromJSON
import com.google.gwt.json.client.JSONValue; //导入方法依赖的package包/类
@Override
public void fromJSON(JSONValue value) {
JSONArray jsonArr = value.isArray();
if (jsonArr != null) {
identifier = jsonArr.get(1).isString().stringValue();
cardinality = Cardinality.valueOf(jsonArr.get(2).isString().stringValue());
JSONArray jsonValues = jsonArr.get(4).isArray();
values.clear();
if (jsonValues != null) {
for (int i = 0; i < jsonValues.size(); i++) {
values.add(jsonValues.get(i).isString().stringValue());
}
}
interpretation = jsonArr.get(5).isString().stringValue();
normalMaximum = jsonArr.get(6).isNumber().doubleValue();
}
}
示例2: fromJSON
import com.google.gwt.json.client.JSONValue; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public void fromJSON(JSONValue json) {
JSONArray jsonArr = json.isArray();
if (jsonArr != null) {
for (int i = 0; i < jsonArr.size(); i++) {
if (!(jsonArr.get(0) instanceof JSONNull) && !(jsonArr.get(i).isArray().get(0) instanceof JSONNull)) {
String type = jsonArr.get(i).isArray().get(0).isString().stringValue();
if (type.equals(Outcome.OLD_OUTCOME) || type.equals(Outcome.OUTCOME)) {
Outcome o = new Outcome();
o.fromJSON(jsonArr.get(i));
variables.put(o.identifier, o);
}
}
}
}
}
示例3: toList
import com.google.gwt.json.client.JSONValue; //导入方法依赖的package包/类
public List<String> toList(String jsonStr) {
JSONValue parsed = JSONParser.parseStrict(jsonStr);
JSONArray jsonArray = parsed.isArray();
if (jsonArray == null) {
return Collections.emptyList();
}
List<String> list = new ArrayList<>();
for (int i = 0; i < jsonArray.size(); i++) {
JSONValue jsonValue = jsonArray.get(i);
JSONString jsonString = jsonValue.isString();
String stringValue = (jsonString == null) ? jsonValue.toString() : jsonString.stringValue();
list.add(stringValue);
}
return list;
}
示例4: parseGadgetInfoJson
import com.google.gwt.json.client.JSONValue; //导入方法依赖的package包/类
@Override
public List<GadgetInfo> parseGadgetInfoJson(String json) {
List<GadgetInfo> gadgetList = new ArrayList<GadgetInfo>();
JSONValue value = JSONParser.parseStrict(json);
JSONArray array = value.isArray();
if (array != null) {
for (int i = 0; i < array.size(); i++) {
JSONValue item = array.get(i);
GadgetInfo info = parseGadgetInfo(item);
if (info != null) {
gadgetList.add(info);
}
}
}
return gadgetList;
}
示例5: parse
import com.google.gwt.json.client.JSONValue; //导入方法依赖的package包/类
public List<T> parse(JSONValue resp, Options options) {
List<T> result = new ArrayList<T>();
JSONArray array = resp != null && resp.isArray() != null ? resp.isArray() : new JSONArray();
if(resp != null && resp.isObject() != null) {
array.set(0, resp.isObject());
}
if(options == null)
options = new Options();
for (int i = 0; i < array.size(); i++) {
JSONValue jsonValue = array.get(i);
if (jsonValue != null && jsonValue.isObject() != null) {
T model = prepareModel(jsonValue.isObject(), options);
if (model != null) {
result.add(model);
}
}
}
return result;
}
示例6: getTagsFromJson
import com.google.gwt.json.client.JSONValue; //导入方法依赖的package包/类
/**
* @param arr list of tags as a JSON array
* @return the list of tags
*/
public static List<String> getTagsFromJson(String result) throws JSONException {
JSONValue val = parseJSON(result);
JSONArray arr = val.isArray();
if (arr == null) {
throw new JSONException("Expected JSON Array: " + val.toString());
}
List<String> tags = new ArrayList<String>(arr.size());
for (int i = 0; i < arr.size(); i++) {
tags.add(arr.get(i).isString().stringValue());
}
return tags;
}
示例7: extractMap
import com.google.gwt.json.client.JSONValue; //导入方法依赖的package包/类
private static Map<String, String> extractMap(JSONValue mapValue) {
if (mapValue != null) {
JSONArray keyValueArray = mapValue.isArray();
if (keyValueArray != null) {
int arraySize = keyValueArray.size();
Map<String, String> resultMap = new HashMap<>(arraySize);
for (int i = 0; i < keyValueArray.size(); i++) {
JSONObject object = keyValueArray.get(i).isObject();
String key = object.get("key").isString().stringValue();
String value = object.get("value").isString().stringValue();
resultMap.put(key, value);
}
return resultMap;
}
}
return Collections.emptyMap();
}
示例8: processResult
import com.google.gwt.json.client.JSONValue; //导入方法依赖的package包/类
@Override
public void processResult(String result) {
JSONValue json = controller.parseJSON(result);
JSONArray array = json.isArray();
if (array != null) {
String timeStamp = DateTimeFormat.getFormat(PredefinedFormat.HOUR24_MINUTE)
.format(new Date(System.currentTimeMillis()));
addRow();
loadTable.setValue(loadTable.getNumberOfRows() - 1, 0, timeStamp);
// getting primitive values of all attributes
for (int i = 0; i < attrs.length; i++) {
double value = array.get(i).isObject().get("value").isNumber().doubleValue();
loadTable.setValue(loadTable.getNumberOfRows() - 1, i + 1, value);
}
loadChart.draw(loadTable, loadOpts);
}
}
示例9: toMapOfLists
import com.google.gwt.json.client.JSONValue; //导入方法依赖的package包/类
public static Map<String, List<String>> toMapOfLists(String jsonStr) {
Map<String, List<String>> map = new HashMap<>();
JSONValue parsed = JSONParser.parseStrict(jsonStr);
JSONObject jsonObj = parsed.isObject();
if (jsonObj != null) {
for (String key : jsonObj.keySet()) {
JSONValue jsonValue = jsonObj.get(key);
JSONArray jsonArray = jsonValue.isArray();
List<String> values = new ArrayList<>();
for (int i = 0; i < jsonArray.size(); i++) {
values.add(jsonArray.get(i).isString().stringValue());
}
map.put(key, values);
}
}
return map;
}
示例10: setJSONValue
import com.google.gwt.json.client.JSONValue; //导入方法依赖的package包/类
@Override
public void setJSONValue(JSONValue value) {
JSONArray arr = value.isArray();
if (arr != null) {
for (int i = 0; i < arr.size(); i++) {
// We may have to create additional editors
if (i >= editors.size()) {
addItem();
}
SchemaEditor editor = editors.get(i);
editor.setJSONValue(arr.get(i));
}
} else {
throw new JSONException("Not a valid JSON array: " + value.toString());
}
}
示例11: getStateById
import com.google.gwt.json.client.JSONValue; //导入方法依赖的package包/类
@Override
public YJsonArray getStateById(String id) {
JSONValue object = state.get(0);
if (object != null) {
JSONValue stateValue = object.isObject().get(id);
JSONArray stateArray = stateValue.isArray();
return yJsJsonConverter.toYJson(stateArray);
}
return YJsJsonFactory.createArray();
}
示例12: setStoredTemplateUrls
import com.google.gwt.json.client.JSONValue; //导入方法依赖的package包/类
/**
* Sets the dynamic template Urls from a jsonStr. This method is
* called during start up where jsonStr is retrieved from User
* settings.
*
* @param jsonStr
*/
public static void setStoredTemplateUrls(String jsonStr) {
if (jsonStr == null || jsonStr.length() == 0)
return;
JSONValue jsonVal = JSONParser.parseLenient(jsonStr);
JSONArray jsonArr = jsonVal.isArray();
for (int i = 0; i < jsonArr.size(); i++) {
JSONValue value = jsonArr.get(i);
JSONString str = value.isString();
dynamicTemplateUrls.add(str.stringValue());
}
}
示例13: getTemplates
import com.google.gwt.json.client.JSONValue; //导入方法依赖的package包/类
/**
* Returns a list of Template objects containing data needed
* to load a template from a zip file. Each non-null template object
* is created from its Json string
*
* @return ArrayList of TemplateInfo objects
*/
protected static ArrayList<TemplateInfo> getTemplates() {
JSONValue jsonVal = JSONParser.parseLenient(templateDataString);
JSONArray jsonArr = jsonVal.isArray();
ArrayList<TemplateInfo> templates = new ArrayList<TemplateInfo>();
for (int i = 0; i < jsonArr.size(); i++) {
JSONValue value = jsonArr.get(i);
JSONObject obj = value.isObject();
if (obj != null)
templates.add(new TemplateInfo(obj)); // Create TemplateInfo from Json
}
return templates;
}
示例14: getArray
import com.google.gwt.json.client.JSONValue; //导入方法依赖的package包/类
private static JSONArray getArray(JSONValue value) throws JSONException {
JSONArray arr = value.isArray();
if (arr == null) {
throw new JSONException("Expected JSON Array: " + value.toString());
}
return arr;
}
示例15: matches
import com.google.gwt.json.client.JSONValue; //导入方法依赖的package包/类
private static boolean matches(JSONValue element, JsonDecision decision) {
if (decision == JsonDecision.LIST) {
return element.isArray() != null;
}
if (decision == JsonDecision.BOOLEAN) {
return element.isBoolean() != null;
}
if (decision == JsonDecision.NUMBER) {
return element.isNumber() != null;
}
if (decision == JsonDecision.STRING) {
return element.isString() != null;
}
return element.isObject() != null;
}