本文整理汇总了Java中com.google.gwt.json.client.JSONValue类的典型用法代码示例。如果您正苦于以下问题:Java JSONValue类的具体用法?Java JSONValue怎么用?Java JSONValue使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
JSONValue类属于com.google.gwt.json.client包,在下文中一共展示了JSONValue类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: create
import com.google.gwt.json.client.JSONValue; //导入依赖的package包/类
public IFlowRequest create(JSONArray state, Integer initialItemIndex) {
IFlowRequest flowRequest = null;
if (initialItemIndex != null) {
flowRequest = new FlowRequest.NavigateGotoItem(initialItemIndex);
} else if (state != null) {
JSONValue firstState = state.get(0);
if (firstState.isNumber() != null) {
flowRequest = getFlowRequestFromNumber(firstState);
} else if (firstState.isString() != null) {
flowRequest = getFlowRequestFromString(firstState);
}
}
return flowRequest;
}
示例2: toJSON
import com.google.gwt.json.client.JSONValue; //导入依赖的package包/类
@Override
public JSONValue toJSON() {
JSONArray jsonArr = new JSONArray();
jsonArr.set(0, new JSONString(OUTCOME));
jsonArr.set(1, new JSONString(identifier));
jsonArr.set(2, new JSONString(cardinality.toString()));
jsonArr.set(3, new JSONString(""));
JSONArray valuesArr = new JSONArray();
for (int v = 0; v < values.size(); v++) {
valuesArr.set(v, new JSONString(values.get(v)));
}
jsonArr.set(4, valuesArr);
jsonArr.set(5, new JSONString(interpretation));
jsonArr.set(6, new JSONNumber(normalMaximum));
return jsonArr;
}
示例3: 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();
}
}
示例4: 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);
}
}
}
}
}
示例5: 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;
}
示例6: getStyle
import com.google.gwt.json.client.JSONValue; //导入依赖的package包/类
public static ProjectLayerStyle getStyle(String geoJSONCSS) {
ProjectLayerStyle style = null;
final JSONValue jsonValue = JSONParser.parseLenient(geoJSONCSS);
final JSONObject geoJSONCssObject = jsonValue.isObject();
if (geoJSONCssObject.containsKey(GeoJSONCSS.STYLE_NAME)) {
JSONObject styleObject = geoJSONCssObject
.get(GeoJSONCSS.STYLE_NAME).isObject();
String fillColor = getStringValue(styleObject, FILL_COLOR_NAME);
Double fillOpacity = getDoubleValue(styleObject, FILL_OPACITY_NAME);
if(fillOpacity == null) {
fillOpacity = getDoubleValue(styleObject, FILL_OPACITY2_NAME);
}
String strokeColor = getStringValue(styleObject, STROKE_COLOR_NAME);
Double strokeWidth = getDoubleValue(styleObject, STROKE_WIDTH_NAME);
style = new ProjectLayerStyle(fillColor, fillOpacity, strokeColor,
strokeWidth);
}
return style;
}
示例7: extractFormName
import com.google.gwt.json.client.JSONValue; //导入依赖的package包/类
private static String extractFormName(RpcResult result) {
String extraString = result.getExtra();
if (extraString != null) {
JSONValue extraJSONValue = JSONParser.parseStrict(extraString);
JSONObject extraJSONObject = extraJSONValue.isObject();
if (extraJSONObject != null) {
JSONValue formNameJSONValue = extraJSONObject.get("formName");
if (formNameJSONValue != null) {
JSONString formNameJSONString = formNameJSONValue.isString();
if (formNameJSONString != null) {
return formNameJSONString.stringValue();
}
}
}
}
return "Screen1";
}
示例8: setOption
import com.google.gwt.json.client.JSONValue; //导入依赖的package包/类
private void setOption(JSONObject rootObject, String path, Object value) {
if (path == null) {
return;
}
if (path.startsWith("/")) {
path = path.substring(1);
}
if (path.length() <= 0) {
return;
}
String nodeName = path;
if (nodeName.contains("/")) {
nodeName = nodeName.substring(0, nodeName.indexOf("/"));
JSONValue objectAsValue = rootObject.get(nodeName);
if (objectAsValue == null || objectAsValue.isObject() == null) {
rootObject.put(nodeName, new JSONObject());
}
JSONObject object = (JSONObject) rootObject.get(nodeName);
setOption(object, path.substring(path.indexOf("/") + 1), value);
} else {
rootObject.put(nodeName, convertToJSONValue(value));
}
}
示例9: parseDefaultValues
import com.google.gwt.json.client.JSONValue; //导入依赖的package包/类
/**
* Extracts default preference values from the gadget metadata JSON object
* returned from GGS.
*
* @param prefs the preference JSON object received from GGS.
*/
public void parseDefaultValues(JSONObject prefs) {
if (prefs != null) {
for (String pref : prefs.keySet()) {
if (!has(pref)) {
JSONObject prefJson = prefs.get(pref).isObject();
if (prefJson != null) {
JSONValue value = prefJson.get("default");
if ((value != null) && (value.isString() != null)) {
put(pref, value.isString().stringValue());
log("Gadget pref '" + pref + "' = '" + get(pref) + "'");
}
} else {
log("Invalid pref '" + pref + "' value in Gadget metadata.");
}
}
}
}
}
示例10: 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;
}
示例11: parseGadgetInfo
import com.google.gwt.json.client.JSONValue; //导入依赖的package包/类
private GadgetInfo parseGadgetInfo(JSONValue item) {
JSONObject object = item.isObject();
if (object != null) {
String name = object.get("name").isString().stringValue();
String desc = object.get("desc").isString().stringValue();
GadgetCategoryType primaryCategory =
GadgetCategoryType.of(object.get("primaryCategory").isString().stringValue());
GadgetCategoryType secondaryCategory =
GadgetCategoryType.of(object.get("secondaryCategory").isString().stringValue());
String gadgetUrl = object.get("gadgetUrl").isString().stringValue();
String author = object.get("author").isString().stringValue();
String submittedBy = object.get("submittedBy").isString().stringValue();
String imageUrl = object.get("imageUrl").isString().stringValue();
return new GadgetInfo(name, desc, primaryCategory, secondaryCategory, gadgetUrl, author,
submittedBy, imageUrl);
}
return null;
}
示例12: parseMap
import com.google.gwt.json.client.JSONValue; //导入依赖的package包/类
public static <T extends Enum<T>> Map<T, Double> parseMap(Class<T> clazz,
String text) {
if (text == null) {
return new TreeMap<T, Double>();
} else {
JSONValue v = JSONParser.parseLenient(text);
Map<String, String> smap = JsonUtil.parseMap(v);
Map<T, Double> map = new TreeMap<T, Double>();
for (Map.Entry<String, String> e : smap.entrySet()) {
T type = Enum.valueOf(clazz, e.getKey());
Double d = Double.parseDouble(e.getValue());
map.put(type, d);
}
return map;
}
}
示例13: updateVariables
import com.google.gwt.json.client.JSONValue; //导入依赖的package包/类
private void updateVariables(JSONValue updatedVariablesJsonValue) {
JSONObject obj = updatedVariablesJsonValue.isObject();
if (obj != null) {
for (String varName : obj.keySet()) {
JobVariable variable = variables.get(varName);
if (variable != null) {
JSONValue variableJsonValue = obj.get(varName);
JSONString variableJsonString = variableJsonValue.isString();
if (variableJsonString != null) {
variable.setValue(variableJsonString.stringValue());
}
}
}
}
}
示例14: deleteItem
import com.google.gwt.json.client.JSONValue; //导入依赖的package包/类
@Override
protected void deleteItem(final ListGridRecord rollOverRecord) {
SC.ask(constants.deleteThisRun().replace("***", rollOverRecord.getAttributeAsString(RunModel.RUNTITLE_FIELD)), new BooleanCallback() {
public void execute(Boolean value) {
if (value != null && value) {
RunClient.getInstance().deleteItemsForRun(rollOverRecord.getAttributeAsLong("runId"), new JsonCallback() {
@Override
public void onJsonReceived(JSONValue jsonValue) {
RunDataSource.getInstance().loadDataFromWeb();
}
});
}
}
});
}
示例15: deserialize
import com.google.gwt.json.client.JSONValue; //导入依赖的package包/类
@Override
public Object deserialize(String payload, Type expected)
throws SerializerException {
JSONValue jsonValue = JSONParser.parseStrict(payload);
try {
Object object = fromJSONValue(jsonValue, expected);
if (object == null) {
throw new SerializerException(
SerializerException.Error.NOT_DESERIALIZABLE);
}
return object;
} catch (NoSuitableSerializableFactory exception) {
throw new SerializerException(
SerializerException.Error.NOT_DESERIALIZABLE, exception);
}
}