本文整理汇总了Java中com.google.gwt.json.client.JSONValue.isString方法的典型用法代码示例。如果您正苦于以下问题:Java JSONValue.isString方法的具体用法?Java JSONValue.isString怎么用?Java JSONValue.isString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.gwt.json.client.JSONValue
的用法示例。
在下文中一共展示了JSONValue.isString方法的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: 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;
}
示例3: 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";
}
示例4: 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.");
}
}
}
}
}
示例5: 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());
}
}
}
}
}
示例6: toMap
import com.google.gwt.json.client.JSONValue; //导入方法依赖的package包/类
public static Map<String, String> toMap(String jsonStr) {
Map<String, String> map = new HashMap<String, String>();
JSONValue parsed = JSONParser.parseStrict(jsonStr);
JSONObject jsonObj = parsed.isObject();
if (jsonObj != null) {
for (String key : jsonObj.keySet()) {
JSONValue jsonValue = jsonObj.get(key);
JSONString jsonString = jsonValue.isString();
// if the json value is a string, set the unescaped value, else set the json representation
// of the value
String stringValue = (jsonString == null) ? jsonValue.toString() : jsonString.stringValue();
map.put(key, stringValue);
}
}
return map;
}
示例7: parseMap
import com.google.gwt.json.client.JSONValue; //导入方法依赖的package包/类
public static Map<String, String> parseMap(JSONValue jsonValue) {
JSONObject obj = jsonValue.isObject();
Map<String, String> map = new TreeMap<String, String>();
if (obj != null) {
for (String key : obj.keySet()) {
JSONValue value = obj.get(key);
if (value != null) {
JSONString str = value.isString();
if (str != null) {
map.put(key, str.stringValue());
}
}
}
}
return map;
}
示例8: parseVersion
import com.google.gwt.json.client.JSONValue; //导入方法依赖的package包/类
public static Version parseVersion(JSONValue jsonValue) {
JSONObject obj = jsonValue.isObject();
Version version = new Version();
if (obj != null) {
JSONValue value = obj.get("version");
if (value != null) {
JSONString str = value.isString();
if (str != null) {
version.version = str.stringValue();
}
}
}
return version;
}
示例9: setState
import com.google.gwt.json.client.JSONValue; //导入方法依赖的package包/类
@Override
public void setState(JSONArray newState) {
if (newState.isArray() instanceof JSONArray) {
JSONArray arr = newState.isArray();
JSONValue v = arr.get(0);
if (v.isString() instanceof JSONString) {
String s = v.isString().stringValue();
setStateJs(extensionJsObject, s);
}
}
}
示例10: 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());
}
}
示例11: getString
import com.google.gwt.json.client.JSONValue; //导入方法依赖的package包/类
private static String getString(JSONValue value) throws JSONException {
if (value.isNull() != null) {
return null;
}
JSONString string = value.isString();
if (string == null) {
throw new JSONException("Expected JSON String: " + value.toString());
}
return string.stringValue();
}
示例12: retrieveErrorMessage
import com.google.gwt.json.client.JSONValue; //导入方法依赖的package包/类
private static String retrieveErrorMessage(JSONObject exc) {
JSONValue val = exc.get("errorMessage");
if (val == null || val.isString() == null) {
return "<no reason>";
} else {
return val.isString().stringValue();
}
}
示例13: 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;
}
示例14: getValue
import com.google.gwt.json.client.JSONValue; //导入方法依赖的package包/类
public static String getValue( JSONValue val, String key, String def ) {
if( val == null ) return def;
JSONObject object = val.isObject();
if( object == null ) return def;
JSONValue v = object.get( key );
if( v == null ) return def;
if( v.isString() == null ) return def;
return v.isString().stringValue();
}
示例15: getPrimaryKey
import com.google.gwt.json.client.JSONValue; //导入方法依赖的package包/类
public Object getPrimaryKey(AbstractRecord record) {
if (record.getCorrespondingJsonObject().containsKey(pkAttribute)) {
JSONValue value = record.getCorrespondingJsonObject().get(pkAttribute);
if (value.isNumber() != null) {
return new Long((long) value.isNumber().doubleValue());
}
if (value.isString() != null) {
return value.isString().stringValue();
}
}
return null;
}